cli_installer_tests.py 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. # TODO: Temporarily disabled due to importing old code into openshift-ansible
  2. # repo. We will work on these over time.
  3. # pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,too-many-lines
  4. import copy
  5. import os
  6. import ConfigParser
  7. import ooinstall.cli_installer as cli
  8. from test.fixture import OOCliFixture, SAMPLE_CONFIG, build_input, read_yaml
  9. from mock import patch
  10. MOCK_FACTS = {
  11. '10.0.0.1': {
  12. 'common': {
  13. 'ip': '10.0.0.1',
  14. 'public_ip': '10.0.0.1',
  15. 'hostname': 'master-private.example.com',
  16. 'public_hostname': 'master.example.com'
  17. }
  18. },
  19. '10.0.0.2': {
  20. 'common': {
  21. 'ip': '10.0.0.2',
  22. 'public_ip': '10.0.0.2',
  23. 'hostname': 'node1-private.example.com',
  24. 'public_hostname': 'node1.example.com'
  25. }
  26. },
  27. '10.0.0.3': {
  28. 'common': {
  29. 'ip': '10.0.0.3',
  30. 'public_ip': '10.0.0.3',
  31. 'hostname': 'node2-private.example.com',
  32. 'public_hostname': 'node2.example.com'
  33. }
  34. },
  35. '10.1.0.1': {
  36. 'common': {
  37. 'ip': '10.1.0.1',
  38. 'public_ip': '10.1.0.1',
  39. 'hostname': 'storage-private.example.com',
  40. 'public_hostname': 'storage.example.com'
  41. }
  42. },
  43. }
  44. MOCK_FACTS_QUICKHA = {
  45. '10.0.0.1': {
  46. 'common': {
  47. 'ip': '10.0.0.1',
  48. 'public_ip': '10.0.0.1',
  49. 'hostname': 'master-private.example.com',
  50. 'public_hostname': 'master.example.com'
  51. }
  52. },
  53. '10.0.0.2': {
  54. 'common': {
  55. 'ip': '10.0.0.2',
  56. 'public_ip': '10.0.0.2',
  57. 'hostname': 'node1-private.example.com',
  58. 'public_hostname': 'node1.example.com'
  59. }
  60. },
  61. '10.0.0.3': {
  62. 'common': {
  63. 'ip': '10.0.0.3',
  64. 'public_ip': '10.0.0.3',
  65. 'hostname': 'node2-private.example.com',
  66. 'public_hostname': 'node2.example.com'
  67. }
  68. },
  69. '10.0.0.4': {
  70. 'common': {
  71. 'ip': '10.0.0.4',
  72. 'public_ip': '10.0.0.4',
  73. 'hostname': 'node3-private.example.com',
  74. 'public_hostname': 'node3.example.com'
  75. }
  76. },
  77. '10.0.0.5': {
  78. 'common': {
  79. 'ip': '10.0.0.5',
  80. 'public_ip': '10.0.0.5',
  81. 'hostname': 'proxy-private.example.com',
  82. 'public_hostname': 'proxy.example.com'
  83. }
  84. },
  85. '10.1.0.1': {
  86. 'common': {
  87. 'ip': '10.1.0.1',
  88. 'public_ip': '10.1.0.1',
  89. 'hostname': 'storage-private.example.com',
  90. 'public_hostname': 'storage.example.com'
  91. }
  92. },
  93. }
  94. # Missing connect_to on some hosts:
  95. BAD_CONFIG = """
  96. variant: %s
  97. version: v2
  98. deployment:
  99. ansible_ssh_user: root
  100. hosts:
  101. - connect_to: 10.0.0.1
  102. ip: 10.0.0.1
  103. hostname: master-private.example.com
  104. public_ip: 24.222.0.1
  105. public_hostname: master.example.com
  106. roles:
  107. - master
  108. - node
  109. - ip: 10.0.0.2
  110. hostname: node1-private.example.com
  111. public_ip: 24.222.0.2
  112. public_hostname: node1.example.com
  113. roles:
  114. - node
  115. - connect_to: 10.0.0.3
  116. ip: 10.0.0.3
  117. hostname: node2-private.example.com
  118. public_ip: 24.222.0.3
  119. public_hostname: node2.example.com
  120. roles:
  121. - node
  122. roles:
  123. master:
  124. node:
  125. """
  126. QUICKHA_CONFIG = """
  127. variant: %s
  128. version: v2
  129. deployment:
  130. ansible_ssh_user: root
  131. hosts:
  132. - connect_to: 10.0.0.1
  133. ip: 10.0.0.1
  134. hostname: master-private.example.com
  135. public_ip: 24.222.0.1
  136. public_hostname: master.example.com
  137. roles:
  138. - master
  139. - node
  140. - connect_to: 10.0.0.2
  141. ip: 10.0.0.2
  142. hostname: node1-private.example.com
  143. public_ip: 24.222.0.2
  144. public_hostname: node1.example.com
  145. roles:
  146. - master
  147. - node
  148. - connect_to: 10.0.0.3
  149. ip: 10.0.0.3
  150. hostname: node2-private.example.com
  151. public_ip: 24.222.0.3
  152. public_hostname: node2.example.com
  153. roles:
  154. - master
  155. - node
  156. - connect_to: 10.0.0.4
  157. ip: 10.0.0.4
  158. hostname: node3-private.example.com
  159. public_ip: 24.222.0.4
  160. public_hostname: node3.example.com
  161. roles:
  162. - node
  163. - connect_to: 10.0.0.5
  164. ip: 10.0.0.5
  165. hostname: proxy-private.example.com
  166. public_ip: 24.222.0.5
  167. public_hostname: proxy.example.com
  168. roles:
  169. - master_lb
  170. - connect_to: 10.1.0.1
  171. ip: 10.1.0.1
  172. hostname: storage-private.example.com
  173. public_ip: 24.222.0.6
  174. public_hostname: storage.example.com
  175. roles:
  176. - storage
  177. roles:
  178. master:
  179. master_lb:
  180. node:
  181. storage:
  182. """
  183. QUICKHA_2_MASTER_CONFIG = """
  184. variant: %s
  185. version: v2
  186. deployment:
  187. ansible_ssh_user: root
  188. hosts:
  189. - connect_to: 10.0.0.1
  190. ip: 10.0.0.1
  191. hostname: master-private.example.com
  192. public_ip: 24.222.0.1
  193. public_hostname: master.example.com
  194. roles:
  195. - master
  196. - node
  197. - connect_to: 10.0.0.2
  198. ip: 10.0.0.2
  199. hostname: node1-private.example.com
  200. public_ip: 24.222.0.2
  201. public_hostname: node1.example.com
  202. roles:
  203. - master
  204. - node
  205. - connect_to: 10.0.0.4
  206. ip: 10.0.0.4
  207. hostname: node3-private.example.com
  208. public_ip: 24.222.0.4
  209. public_hostname: node3.example.com
  210. roles:
  211. - node
  212. - connect_to: 10.0.0.5
  213. ip: 10.0.0.5
  214. hostname: proxy-private.example.com
  215. public_ip: 24.222.0.5
  216. public_hostname: proxy.example.com
  217. roles:
  218. - master_lb
  219. - connect_to: 10.1.0.1
  220. ip: 10.1.0.1
  221. hostname: storage-private.example.com
  222. public_ip: 24.222.0.6
  223. public_hostname: storage.example.com
  224. roles:
  225. - storage
  226. roles:
  227. master:
  228. master_lb:
  229. node:
  230. storage:
  231. """
  232. QUICKHA_CONFIG_REUSED_LB = """
  233. variant: %s
  234. version: v2
  235. deployment:
  236. ansible_ssh_user: root
  237. hosts:
  238. - connect_to: 10.0.0.1
  239. ip: 10.0.0.1
  240. hostname: master-private.example.com
  241. public_ip: 24.222.0.1
  242. public_hostname: master.example.com
  243. roles:
  244. - master
  245. - node
  246. - connect_to: 10.0.0.2
  247. ip: 10.0.0.2
  248. hostname: node1-private.example.com
  249. public_ip: 24.222.0.2
  250. public_hostname: node1.example.com
  251. roles:
  252. - master
  253. - node
  254. - master_lb
  255. - connect_to: 10.0.0.3
  256. ip: 10.0.0.3
  257. hostname: node2-private.example.com
  258. public_ip: 24.222.0.3
  259. public_hostname: node2.example.com
  260. roles:
  261. - master
  262. - node
  263. - connect_to: 10.1.0.1
  264. ip: 10.1.0.1
  265. hostname: storage-private.example.com
  266. public_ip: 24.222.0.6
  267. public_hostname: storage.example.com
  268. roles:
  269. - storage
  270. roles:
  271. master:
  272. node:
  273. storage:
  274. """
  275. QUICKHA_CONFIG_NO_LB = """
  276. variant: %s
  277. version: v2
  278. deployment:
  279. ansible_ssh_user: root
  280. hosts:
  281. - connect_to: 10.0.0.1
  282. ip: 10.0.0.1
  283. hostname: master-private.example.com
  284. public_ip: 24.222.0.1
  285. public_hostname: master.example.com
  286. roles:
  287. - master
  288. - node
  289. - connect_to: 10.0.0.2
  290. ip: 10.0.0.2
  291. hostname: node1-private.example.com
  292. public_ip: 24.222.0.2
  293. public_hostname: node1.example.com
  294. roles:
  295. - master
  296. - node
  297. - connect_to: 10.0.0.3
  298. ip: 10.0.0.3
  299. hostname: node2-private.example.com
  300. public_ip: 24.222.0.3
  301. public_hostname: node2.example.com
  302. roles:
  303. - master
  304. - node
  305. - connect_to: 10.1.0.1
  306. ip: 10.1.0.1
  307. hostname: storage-private.example.com
  308. public_ip: 24.222.0.6
  309. public_hostname: storage.example.com
  310. roles:
  311. - storage
  312. roles:
  313. master:
  314. node:
  315. storage:
  316. """
  317. QUICKHA_CONFIG_PRECONFIGURED_LB = """
  318. variant: %s
  319. version: v2
  320. deployment:
  321. ansible_ssh_user: root
  322. hosts:
  323. - connect_to: 10.0.0.1
  324. ip: 10.0.0.1
  325. hostname: master-private.example.com
  326. public_ip: 24.222.0.1
  327. public_hostname: master.example.com
  328. roles:
  329. - master
  330. - node
  331. - connect_to: 10.0.0.2
  332. ip: 10.0.0.2
  333. hostname: node1-private.example.com
  334. public_ip: 24.222.0.2
  335. public_hostname: node1.example.com
  336. roles:
  337. - master
  338. - node
  339. - connect_to: 10.0.0.3
  340. ip: 10.0.0.3
  341. hostname: node2-private.example.com
  342. public_ip: 24.222.0.3
  343. public_hostname: node2.example.com
  344. roles:
  345. - master
  346. - node
  347. - connect_to: 10.0.0.4
  348. ip: 10.0.0.4
  349. hostname: node3-private.example.com
  350. public_ip: 24.222.0.4
  351. public_hostname: node3.example.com
  352. roles:
  353. - node
  354. - connect_to: proxy-private.example.com
  355. hostname: proxy-private.example.com
  356. public_hostname: proxy.example.com
  357. preconfigured: true
  358. roles:
  359. - master_lb
  360. - connect_to: 10.1.0.1
  361. ip: 10.1.0.1
  362. hostname: storage-private.example.com
  363. public_ip: 24.222.0.6
  364. public_hostname: storage.example.com
  365. roles:
  366. - storage
  367. roles:
  368. master:
  369. master_lb:
  370. node:
  371. storage:
  372. """
  373. class UnattendedCliTests(OOCliFixture):
  374. def setUp(self):
  375. OOCliFixture.setUp(self)
  376. self.cli_args.append("-u")
  377. # unattended with config file and all installed hosts (without --force)
  378. @patch('ooinstall.openshift_ansible.run_main_playbook')
  379. @patch('ooinstall.openshift_ansible.load_system_facts')
  380. def test_get_hosts_to_run_on1(self, load_facts_mock, run_playbook_mock):
  381. mock_facts = copy.deepcopy(MOCK_FACTS)
  382. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  383. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  384. mock_facts['10.0.0.3']['common']['version'] = "3.0.0"
  385. load_facts_mock.return_value = (mock_facts, 0)
  386. run_playbook_mock.return_value = 0
  387. config_file = self.write_config(os.path.join(self.work_dir,
  388. 'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise')
  389. self.cli_args.extend(["-c", config_file, "install"])
  390. result = self.runner.invoke(cli.cli, self.cli_args)
  391. if result.exception is None or result.exit_code != 1:
  392. print "Exit code: %s" % result.exit_code
  393. self.fail("Unexpected CLI return")
  394. # unattended with config file and all installed hosts (with --force)
  395. @patch('ooinstall.openshift_ansible.run_main_playbook')
  396. @patch('ooinstall.openshift_ansible.load_system_facts')
  397. def test_get_hosts_to_run_on2(self, load_facts_mock, run_playbook_mock):
  398. mock_facts = copy.deepcopy(MOCK_FACTS)
  399. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  400. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  401. mock_facts['10.0.0.3']['common']['version'] = "3.0.0"
  402. self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock, run_playbook_mock,
  403. cli_input=None,
  404. exp_hosts_len=3,
  405. exp_hosts_to_run_on_len=3,
  406. force=True)
  407. # unattended with config file and no installed hosts (without --force)
  408. @patch('ooinstall.openshift_ansible.run_main_playbook')
  409. @patch('ooinstall.openshift_ansible.load_system_facts')
  410. def test_get_hosts_to_run_on3(self, load_facts_mock, run_playbook_mock):
  411. load_facts_mock.return_value = (MOCK_FACTS, 0)
  412. run_playbook_mock.return_value = 0
  413. self._verify_get_hosts_to_run_on(MOCK_FACTS, load_facts_mock, run_playbook_mock,
  414. cli_input=None,
  415. exp_hosts_len=3,
  416. exp_hosts_to_run_on_len=3,
  417. force=False)
  418. # unattended with config file and no installed hosts (with --force)
  419. @patch('ooinstall.openshift_ansible.run_main_playbook')
  420. @patch('ooinstall.openshift_ansible.load_system_facts')
  421. def test_get_hosts_to_run_on4(self, load_facts_mock, run_playbook_mock):
  422. load_facts_mock.return_value = (MOCK_FACTS, 0)
  423. run_playbook_mock.return_value = 0
  424. self._verify_get_hosts_to_run_on(MOCK_FACTS, load_facts_mock, run_playbook_mock,
  425. cli_input=None,
  426. exp_hosts_len=3,
  427. exp_hosts_to_run_on_len=3,
  428. force=True)
  429. # unattended with config file and some installed some uninstalled hosts (without --force)
  430. @patch('ooinstall.openshift_ansible.run_main_playbook')
  431. @patch('ooinstall.openshift_ansible.load_system_facts')
  432. def test_get_hosts_to_run_on5(self, load_facts_mock, run_playbook_mock):
  433. mock_facts = copy.deepcopy(MOCK_FACTS)
  434. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  435. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  436. self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock, run_playbook_mock,
  437. cli_input=None,
  438. exp_hosts_len=3,
  439. exp_hosts_to_run_on_len=2,
  440. force=False)
  441. # unattended with config file and some installed some uninstalled hosts (with --force)
  442. @patch('ooinstall.openshift_ansible.run_main_playbook')
  443. @patch('ooinstall.openshift_ansible.load_system_facts')
  444. def test_get_hosts_to_run_on6(self, load_facts_mock, run_playbook_mock):
  445. mock_facts = copy.deepcopy(MOCK_FACTS)
  446. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  447. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  448. self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock, run_playbook_mock,
  449. cli_input=None,
  450. exp_hosts_len=3,
  451. exp_hosts_to_run_on_len=3,
  452. force=True)
  453. @patch('ooinstall.openshift_ansible.run_main_playbook')
  454. @patch('ooinstall.openshift_ansible.load_system_facts')
  455. def test_cfg_full_run(self, load_facts_mock, run_playbook_mock):
  456. load_facts_mock.return_value = (MOCK_FACTS, 0)
  457. run_playbook_mock.return_value = 0
  458. config_file = self.write_config(os.path.join(self.work_dir,
  459. 'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise')
  460. self.cli_args.extend(["-c", config_file, "install"])
  461. result = self.runner.invoke(cli.cli, self.cli_args)
  462. self.assert_result(result, 0)
  463. load_facts_args = load_facts_mock.call_args[0]
  464. self.assertEquals(os.path.join(self.work_dir, "hosts"),
  465. load_facts_args[0])
  466. self.assertEquals(os.path.join(self.work_dir,
  467. "playbooks/byo/openshift_facts.yml"), load_facts_args[1])
  468. env_vars = load_facts_args[2]
  469. self.assertEquals(os.path.join(self.work_dir,
  470. '.ansible/callback_facts.yaml'),
  471. env_vars['OO_INSTALL_CALLBACK_FACTS_YAML'])
  472. self.assertEqual('/tmp/ansible.log', env_vars['ANSIBLE_LOG_PATH'])
  473. # If user running test has rpm installed, this might be set to default:
  474. self.assertTrue('ANSIBLE_CONFIG' not in env_vars or
  475. env_vars['ANSIBLE_CONFIG'] == cli.DEFAULT_ANSIBLE_CONFIG)
  476. # Make sure we ran on the expected masters and nodes:
  477. hosts = run_playbook_mock.call_args[0][1]
  478. hosts_to_run_on = run_playbook_mock.call_args[0][2]
  479. self.assertEquals(3, len(hosts))
  480. self.assertEquals(3, len(hosts_to_run_on))
  481. @patch('ooinstall.openshift_ansible.run_main_playbook')
  482. @patch('ooinstall.openshift_ansible.load_system_facts')
  483. def test_inventory_write(self, load_facts_mock, run_playbook_mock):
  484. merged_config = SAMPLE_CONFIG % 'openshift-enterprise'
  485. load_facts_mock.return_value = (MOCK_FACTS, 0)
  486. run_playbook_mock.return_value = 0
  487. config_file = self.write_config(os.path.join(self.work_dir,
  488. 'ooinstall.conf'), merged_config)
  489. self.cli_args.extend(["-c", config_file, "install"])
  490. result = self.runner.invoke(cli.cli, self.cli_args)
  491. self.assert_result(result, 0)
  492. # Check the inventory file looks as we would expect:
  493. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  494. inventory.read(os.path.join(self.work_dir, 'hosts'))
  495. self.assertEquals('root',
  496. inventory.get('OSEv3:vars', 'ansible_ssh_user'))
  497. self.assertEquals('openshift-enterprise',
  498. inventory.get('OSEv3:vars', 'deployment_type'))
  499. # Check the masters:
  500. self.assertEquals(1, len(inventory.items('masters')))
  501. self.assertEquals(3, len(inventory.items('nodes')))
  502. for item in inventory.items('masters'):
  503. # ansible host lines do NOT parse nicely:
  504. master_line = item[0]
  505. if item[1] is not None:
  506. master_line = "%s=%s" % (master_line, item[1])
  507. self.assertTrue('openshift_ip' in master_line)
  508. self.assertTrue('openshift_public_ip' in master_line)
  509. self.assertTrue('openshift_hostname' in master_line)
  510. self.assertTrue('openshift_public_hostname' in master_line)
  511. @patch('ooinstall.openshift_ansible.run_main_playbook')
  512. @patch('ooinstall.openshift_ansible.load_system_facts')
  513. def test_variant_version_latest_assumed(self, load_facts_mock,
  514. run_playbook_mock):
  515. load_facts_mock.return_value = (MOCK_FACTS, 0)
  516. run_playbook_mock.return_value = 0
  517. config_file = self.write_config(os.path.join(self.work_dir,
  518. 'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise')
  519. self.cli_args.extend(["-c", config_file, "install"])
  520. result = self.runner.invoke(cli.cli, self.cli_args)
  521. self.assert_result(result, 0)
  522. written_config = read_yaml(config_file)
  523. self.assertEquals('openshift-enterprise', written_config['variant'])
  524. # We didn't specify a version so the latest should have been assumed,
  525. # and written to disk:
  526. self.assertEquals('3.3', written_config['variant_version'])
  527. # Make sure the correct value was passed to ansible:
  528. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  529. inventory.read(os.path.join(self.work_dir, 'hosts'))
  530. self.assertEquals('openshift-enterprise',
  531. inventory.get('OSEv3:vars', 'deployment_type'))
  532. @patch('ooinstall.openshift_ansible.run_main_playbook')
  533. @patch('ooinstall.openshift_ansible.load_system_facts')
  534. def test_variant_version_preserved(self, load_facts_mock,
  535. run_playbook_mock):
  536. load_facts_mock.return_value = (MOCK_FACTS, 0)
  537. run_playbook_mock.return_value = 0
  538. config = SAMPLE_CONFIG % 'openshift-enterprise'
  539. config = '%s\n%s' % (config, 'variant_version: 3.3')
  540. config_file = self.write_config(os.path.join(self.work_dir,
  541. 'ooinstall.conf'), config)
  542. self.cli_args.extend(["-c", config_file, "install"])
  543. result = self.runner.invoke(cli.cli, self.cli_args)
  544. self.assert_result(result, 0)
  545. written_config = read_yaml(config_file)
  546. self.assertEquals('openshift-enterprise', written_config['variant'])
  547. # Make sure our older version was preserved:
  548. # and written to disk:
  549. self.assertEquals('3.3', written_config['variant_version'])
  550. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  551. inventory.read(os.path.join(self.work_dir, 'hosts'))
  552. self.assertEquals('openshift-enterprise',
  553. inventory.get('OSEv3:vars', 'deployment_type'))
  554. # 2016-09-26 - tbielawa - COMMENTING OUT these tests FOR NOW while
  555. # we wait to see if anyone notices that we took away their ability
  556. # to set the ansible_config parameter in the command line options
  557. # and in the installer config file.
  558. #
  559. # We have removed the ability to set the ansible config file
  560. # manually so that our new quieter output mode is the default and
  561. # only output mode.
  562. #
  563. # RE: https://trello.com/c/DSwwizwP - atomic-openshift-install
  564. # should only output relevant information.
  565. # @patch('ooinstall.openshift_ansible.run_ansible')
  566. # @patch('ooinstall.openshift_ansible.load_system_facts')
  567. # def test_no_ansible_config_specified(self, load_facts_mock, run_ansible_mock):
  568. # load_facts_mock.return_value = (MOCK_FACTS, 0)
  569. # run_ansible_mock.return_value = 0
  570. # config = SAMPLE_CONFIG % 'openshift-enterprise'
  571. # self._ansible_config_test(load_facts_mock, run_ansible_mock,
  572. # config, None, None)
  573. # @patch('ooinstall.openshift_ansible.run_ansible')
  574. # @patch('ooinstall.openshift_ansible.load_system_facts')
  575. # def test_ansible_config_specified_cli(self, load_facts_mock, run_ansible_mock):
  576. # load_facts_mock.return_value = (MOCK_FACTS, 0)
  577. # run_ansible_mock.return_value = 0
  578. # config = SAMPLE_CONFIG % 'openshift-enterprise'
  579. # ansible_config = os.path.join(self.work_dir, 'ansible.cfg')
  580. # self._ansible_config_test(load_facts_mock, run_ansible_mock,
  581. # config, ansible_config, ansible_config)
  582. # @patch('ooinstall.openshift_ansible.run_ansible')
  583. # @patch('ooinstall.openshift_ansible.load_system_facts')
  584. # def test_ansible_config_specified_in_installer_config(self,
  585. # load_facts_mock, run_ansible_mock):
  586. # load_facts_mock.return_value = (MOCK_FACTS, 0)
  587. # run_ansible_mock.return_value = 0
  588. # ansible_config = os.path.join(self.work_dir, 'ansible.cfg')
  589. # config = SAMPLE_CONFIG % 'openshift-enterprise'
  590. # config = "%s\nansible_config: %s" % (config, ansible_config)
  591. # self._ansible_config_test(load_facts_mock, run_ansible_mock,
  592. # config, None, ansible_config)
  593. # #pylint: disable=too-many-arguments
  594. # # This method allows for drastically simpler tests to write, and the args
  595. # # are all useful.
  596. # def _ansible_config_test(self, load_facts_mock, run_ansible_mock,
  597. # installer_config, ansible_config_cli=None, expected_result=None):
  598. # """
  599. # Utility method for testing the ways you can specify the ansible config.
  600. # """
  601. # load_facts_mock.return_value = (MOCK_FACTS, 0)
  602. # run_ansible_mock.return_value = 0
  603. # config_file = self.write_config(os.path.join(self.work_dir,
  604. # 'ooinstall.conf'), installer_config)
  605. # self.cli_args.extend(["-c", config_file])
  606. # if ansible_config_cli:
  607. # self.cli_args.extend(["--ansible-config", ansible_config_cli])
  608. # self.cli_args.append("install")
  609. # result = self.runner.invoke(cli.cli, self.cli_args)
  610. # self.assert_result(result, 0)
  611. # # Test the env vars for facts playbook:
  612. # facts_env_vars = load_facts_mock.call_args[0][2]
  613. # if expected_result:
  614. # self.assertEquals(expected_result, facts_env_vars['ANSIBLE_CONFIG'])
  615. # else:
  616. # # If user running test has rpm installed, this might be set to default:
  617. # self.assertTrue('ANSIBLE_CONFIG' not in facts_env_vars or
  618. # facts_env_vars['ANSIBLE_CONFIG'] == cli.DEFAULT_ANSIBLE_CONFIG)
  619. # # Test the env vars for main playbook:
  620. # env_vars = run_ansible_mock.call_args[0][2]
  621. # if expected_result:
  622. # self.assertEquals(expected_result, env_vars['ANSIBLE_CONFIG'])
  623. # else:
  624. # # If user running test has rpm installed, this might be set to default:
  625. # #
  626. # # By default we will use the quiet config
  627. # self.assertTrue('ANSIBLE_CONFIG' not in env_vars or
  628. # env_vars['ANSIBLE_CONFIG'] == cli.QUIET_ANSIBLE_CONFIG)
  629. # unattended with bad config file and no installed hosts (without --force)
  630. @patch('ooinstall.openshift_ansible.run_main_playbook')
  631. @patch('ooinstall.openshift_ansible.load_system_facts')
  632. def test_bad_config(self, load_facts_mock, run_playbook_mock):
  633. load_facts_mock.return_value = (MOCK_FACTS, 0)
  634. run_playbook_mock.return_value = 0
  635. config_file = self.write_config(os.path.join(self.work_dir,
  636. 'ooinstall.conf'), BAD_CONFIG % 'openshift-enterprise')
  637. self.cli_args.extend(["-c", config_file, "install"])
  638. result = self.runner.invoke(cli.cli, self.cli_args)
  639. self.assertEquals(1, result.exit_code)
  640. self.assertTrue("You must specify either an ip or hostname"
  641. in result.output)
  642. #unattended with three masters, one node, and haproxy
  643. @patch('ooinstall.openshift_ansible.run_main_playbook')
  644. @patch('ooinstall.openshift_ansible.load_system_facts')
  645. def test_quick_ha_full_run(self, load_facts_mock, run_playbook_mock):
  646. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  647. run_playbook_mock.return_value = 0
  648. config_file = self.write_config(os.path.join(self.work_dir,
  649. 'ooinstall.conf'), QUICKHA_CONFIG % 'openshift-enterprise')
  650. self.cli_args.extend(["-c", config_file, "install"])
  651. result = self.runner.invoke(cli.cli, self.cli_args)
  652. self.assert_result(result, 0)
  653. # Make sure we ran on the expected masters and nodes:
  654. hosts = run_playbook_mock.call_args[0][1]
  655. hosts_to_run_on = run_playbook_mock.call_args[0][2]
  656. self.assertEquals(6, len(hosts))
  657. self.assertEquals(6, len(hosts_to_run_on))
  658. #unattended with two masters, one node, and haproxy
  659. @patch('ooinstall.openshift_ansible.run_main_playbook')
  660. @patch('ooinstall.openshift_ansible.load_system_facts')
  661. def test_quick_ha_only_2_masters(self, load_facts_mock, run_playbook_mock):
  662. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  663. run_playbook_mock.return_value = 0
  664. config_file = self.write_config(os.path.join(self.work_dir,
  665. 'ooinstall.conf'), QUICKHA_2_MASTER_CONFIG % 'openshift-enterprise')
  666. self.cli_args.extend(["-c", config_file, "install"])
  667. result = self.runner.invoke(cli.cli, self.cli_args)
  668. # This is an invalid config:
  669. self.assert_result(result, 1)
  670. self.assertTrue("A minimum of 3 masters are required" in result.output)
  671. #unattended with three masters, one node, but no load balancer specified:
  672. @patch('ooinstall.openshift_ansible.run_main_playbook')
  673. @patch('ooinstall.openshift_ansible.load_system_facts')
  674. def test_quick_ha_no_lb(self, load_facts_mock, run_playbook_mock):
  675. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  676. run_playbook_mock.return_value = 0
  677. config_file = self.write_config(os.path.join(self.work_dir,
  678. 'ooinstall.conf'), QUICKHA_CONFIG_NO_LB % 'openshift-enterprise')
  679. self.cli_args.extend(["-c", config_file, "install"])
  680. result = self.runner.invoke(cli.cli, self.cli_args)
  681. # This is not a valid input:
  682. self.assert_result(result, 1)
  683. self.assertTrue('No master load balancer specified in config' in result.output)
  684. #unattended with three masters, one node, and one of the masters reused as load balancer:
  685. @patch('ooinstall.openshift_ansible.run_main_playbook')
  686. @patch('ooinstall.openshift_ansible.load_system_facts')
  687. def test_quick_ha_reused_lb(self, load_facts_mock, run_playbook_mock):
  688. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  689. run_playbook_mock.return_value = 0
  690. config_file = self.write_config(os.path.join(self.work_dir,
  691. 'ooinstall.conf'), QUICKHA_CONFIG_REUSED_LB % 'openshift-enterprise')
  692. self.cli_args.extend(["-c", config_file, "install"])
  693. result = self.runner.invoke(cli.cli, self.cli_args)
  694. # This is not a valid configuration:
  695. self.assert_result(result, 1)
  696. #unattended with preconfigured lb
  697. @patch('ooinstall.openshift_ansible.run_main_playbook')
  698. @patch('ooinstall.openshift_ansible.load_system_facts')
  699. def test_quick_ha_preconfigured_lb(self, load_facts_mock, run_playbook_mock):
  700. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  701. run_playbook_mock.return_value = 0
  702. config_file = self.write_config(os.path.join(self.work_dir,
  703. 'ooinstall.conf'), QUICKHA_CONFIG_PRECONFIGURED_LB % 'openshift-enterprise')
  704. self.cli_args.extend(["-c", config_file, "install"])
  705. result = self.runner.invoke(cli.cli, self.cli_args)
  706. self.assert_result(result, 0)
  707. # Make sure we ran on the expected masters and nodes:
  708. hosts = run_playbook_mock.call_args[0][1]
  709. hosts_to_run_on = run_playbook_mock.call_args[0][2]
  710. self.assertEquals(6, len(hosts))
  711. self.assertEquals(6, len(hosts_to_run_on))
  712. class AttendedCliTests(OOCliFixture):
  713. def setUp(self):
  714. OOCliFixture.setUp(self)
  715. # Doesn't exist but keeps us from reading the local users config:
  716. self.config_file = os.path.join(self.work_dir, 'config.yml')
  717. self.cli_args.extend(["-c", self.config_file])
  718. @patch('ooinstall.openshift_ansible.run_main_playbook')
  719. @patch('ooinstall.openshift_ansible.load_system_facts')
  720. def test_full_run(self, load_facts_mock, run_playbook_mock):
  721. load_facts_mock.return_value = (MOCK_FACTS, 0)
  722. run_playbook_mock.return_value = 0
  723. cli_input = build_input(hosts=[
  724. ('10.0.0.1', True, False),
  725. ('10.0.0.2', False, False),
  726. ('10.0.0.3', False, False)],
  727. ssh_user='root',
  728. variant_num=1,
  729. confirm_facts='y',
  730. storage='10.1.0.1',)
  731. self.cli_args.append("install")
  732. result = self.runner.invoke(cli.cli, self.cli_args,
  733. input=cli_input)
  734. self.assert_result(result, 0)
  735. self._verify_load_facts(load_facts_mock)
  736. self._verify_run_playbook(run_playbook_mock, 4, 4)
  737. written_config = read_yaml(self.config_file)
  738. self._verify_config_hosts(written_config, 4)
  739. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  740. inventory.read(os.path.join(self.work_dir, 'hosts'))
  741. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  742. 'openshift_schedulable=False')
  743. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
  744. 'openshift_schedulable=True')
  745. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
  746. 'openshift_schedulable=True')
  747. # interactive with config file and some installed some uninstalled hosts
  748. @patch('ooinstall.openshift_ansible.run_main_playbook')
  749. @patch('ooinstall.openshift_ansible.load_system_facts')
  750. def test_add_nodes(self, load_facts_mock, run_playbook_mock):
  751. # Modify the mock facts to return a version indicating OpenShift
  752. # is already installed on our master, and the first node.
  753. mock_facts = copy.deepcopy(MOCK_FACTS)
  754. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  755. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  756. load_facts_mock.return_value = (mock_facts, 0)
  757. run_playbook_mock.return_value = 0
  758. cli_input = build_input(hosts=[
  759. ('10.0.0.1', True, False),
  760. ('10.0.0.2', False, False),
  761. ],
  762. add_nodes=[('10.0.0.3', False, False)],
  763. ssh_user='root',
  764. variant_num=1,
  765. confirm_facts='y',
  766. storage='10.0.0.1',)
  767. self.cli_args.append("install")
  768. result = self.runner.invoke(cli.cli,
  769. self.cli_args,
  770. input=cli_input)
  771. self.assert_result(result, 0)
  772. self._verify_load_facts(load_facts_mock)
  773. self._verify_run_playbook(run_playbook_mock, 3, 2)
  774. written_config = read_yaml(self.config_file)
  775. self._verify_config_hosts(written_config, 3)
  776. @patch('ooinstall.openshift_ansible.run_main_playbook')
  777. @patch('ooinstall.openshift_ansible.load_system_facts')
  778. def test_fresh_install_with_config(self, load_facts_mock, run_playbook_mock):
  779. load_facts_mock.return_value = (MOCK_FACTS, 0)
  780. run_playbook_mock.return_value = 0
  781. config_file = self.write_config(os.path.join(self.work_dir,
  782. 'ooinstall.conf'),
  783. SAMPLE_CONFIG % 'openshift-enterprise')
  784. cli_input = build_input(confirm_facts='y')
  785. self.cli_args.extend(["-c", config_file])
  786. self.cli_args.append("install")
  787. result = self.runner.invoke(cli.cli,
  788. self.cli_args,
  789. input=cli_input)
  790. self.assert_result(result, 0)
  791. self._verify_load_facts(load_facts_mock)
  792. self._verify_run_playbook(run_playbook_mock, 3, 3)
  793. written_config = read_yaml(config_file)
  794. self._verify_config_hosts(written_config, 3)
  795. #interactive with config file and all installed hosts
  796. @patch('ooinstall.openshift_ansible.run_main_playbook')
  797. @patch('ooinstall.openshift_ansible.load_system_facts')
  798. def test_get_hosts_to_run_on(self, load_facts_mock, run_playbook_mock):
  799. mock_facts = copy.deepcopy(MOCK_FACTS)
  800. mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  801. mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  802. cli_input = build_input(hosts=[
  803. ('10.0.0.1', True, False),
  804. ],
  805. add_nodes=[('10.0.0.2', False, False)],
  806. ssh_user='root',
  807. variant_num=1,
  808. schedulable_masters_ok=True,
  809. confirm_facts='y',
  810. storage='10.0.0.1',)
  811. self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock,
  812. run_playbook_mock,
  813. cli_input,
  814. exp_hosts_len=2,
  815. exp_hosts_to_run_on_len=2,
  816. force=False)
  817. #interactive multimaster: one more node than master
  818. @patch('ooinstall.openshift_ansible.run_main_playbook')
  819. @patch('ooinstall.openshift_ansible.load_system_facts')
  820. def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):
  821. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  822. run_playbook_mock.return_value = 0
  823. cli_input = build_input(hosts=[
  824. ('10.0.0.1', True, False),
  825. ('10.0.0.2', True, False),
  826. ('10.0.0.3', True, False),
  827. ('10.0.0.4', False, False)],
  828. ssh_user='root',
  829. variant_num=1,
  830. confirm_facts='y',
  831. master_lb=('10.0.0.5', False),
  832. storage='10.1.0.1',)
  833. self.cli_args.append("install")
  834. result = self.runner.invoke(cli.cli, self.cli_args,
  835. input=cli_input)
  836. self.assert_result(result, 0)
  837. self._verify_load_facts(load_facts_mock)
  838. self._verify_run_playbook(run_playbook_mock, 6, 6)
  839. written_config = read_yaml(self.config_file)
  840. self._verify_config_hosts(written_config, 6)
  841. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  842. inventory.read(os.path.join(self.work_dir, 'hosts'))
  843. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  844. 'openshift_schedulable=False')
  845. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
  846. 'openshift_schedulable=False')
  847. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
  848. 'openshift_schedulable=False')
  849. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.4',
  850. 'openshift_schedulable=True')
  851. self.assertTrue(inventory.has_section('etcd'))
  852. self.assertEquals(3, len(inventory.items('etcd')))
  853. #interactive multimaster: identical masters and nodes
  854. @patch('ooinstall.openshift_ansible.run_main_playbook')
  855. @patch('ooinstall.openshift_ansible.load_system_facts')
  856. def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):
  857. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  858. run_playbook_mock.return_value = 0
  859. cli_input = build_input(hosts=[
  860. ('10.0.0.1', True, False),
  861. ('10.0.0.2', True, False),
  862. ('10.0.0.3', True, False)],
  863. ssh_user='root',
  864. variant_num=1,
  865. confirm_facts='y',
  866. master_lb=('10.0.0.5', False),
  867. storage='10.1.0.1',)
  868. self.cli_args.append("install")
  869. result = self.runner.invoke(cli.cli, self.cli_args,
  870. input=cli_input)
  871. self.assert_result(result, 0)
  872. self._verify_load_facts(load_facts_mock)
  873. self._verify_run_playbook(run_playbook_mock, 5, 5)
  874. written_config = read_yaml(self.config_file)
  875. self._verify_config_hosts(written_config, 5)
  876. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  877. inventory.read(os.path.join(self.work_dir, 'hosts'))
  878. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  879. 'openshift_schedulable=True')
  880. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
  881. 'openshift_schedulable=True')
  882. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
  883. 'openshift_schedulable=True')
  884. # Checks the inventory (as a ConfigParser) for the given host, host
  885. # variable, and expected value.
  886. def assert_inventory_host_var(self, inventory, section, host, variable):
  887. # Config parser splits on the first "=", so we end up with:
  888. # 'hostname key1' -> 'val1 key2=val2 key3=val3'
  889. #
  890. # Convert to something easier to test:
  891. for (a, b) in inventory.items(section):
  892. full_line = "%s=%s" % (a, b)
  893. tokens = full_line.split()
  894. if tokens[0] == host:
  895. found = False
  896. for token in tokens:
  897. if token == variable:
  898. found = True
  899. continue
  900. self.assertTrue("Unable to find %s in line: %s" %
  901. (variable, full_line), found)
  902. return
  903. self.fail("unable to find host %s in inventory" % host)
  904. def assert_inventory_host_var_unset(self, inventory, section, host, variable):
  905. # Config parser splits on the first "=", so we end up with:
  906. # 'hostname key1' -> 'val1 key2=val2 key3=val3'
  907. #
  908. # Convert to something easier to test:
  909. for (a, b) in inventory.items(section):
  910. full_line = "%s=%s" % (a, b)
  911. tokens = full_line.split()
  912. if tokens[0] == host:
  913. self.assertFalse(("%s=" % variable) in full_line,
  914. msg='%s host variable was set: %s' %
  915. (variable, full_line))
  916. return
  917. self.fail("unable to find host %s in inventory" % host)
  918. #interactive multimaster: attempting to use a master as the load balancer should fail:
  919. @patch('ooinstall.openshift_ansible.run_main_playbook')
  920. @patch('ooinstall.openshift_ansible.load_system_facts')
  921. def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):
  922. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  923. run_playbook_mock.return_value = 0
  924. cli_input = build_input(hosts=[
  925. ('10.0.0.1', True, False),
  926. ('10.0.0.2', True, False),
  927. ('10.0.0.3', False, False),
  928. ('10.0.0.4', True, False)],
  929. ssh_user='root',
  930. variant_num=1,
  931. confirm_facts='y',
  932. master_lb=(['10.0.0.2', '10.0.0.5'], False),
  933. storage='10.1.0.1')
  934. self.cli_args.append("install")
  935. result = self.runner.invoke(cli.cli, self.cli_args,
  936. input=cli_input)
  937. self.assert_result(result, 0)
  938. #interactive all-in-one
  939. @patch('ooinstall.openshift_ansible.run_main_playbook')
  940. @patch('ooinstall.openshift_ansible.load_system_facts')
  941. def test_all_in_one(self, load_facts_mock, run_playbook_mock):
  942. load_facts_mock.return_value = (MOCK_FACTS, 0)
  943. run_playbook_mock.return_value = 0
  944. cli_input = build_input(hosts=[
  945. ('10.0.0.1', True, False)],
  946. ssh_user='root',
  947. variant_num=1,
  948. confirm_facts='y',
  949. storage='10.0.0.1')
  950. self.cli_args.append("install")
  951. result = self.runner.invoke(cli.cli, self.cli_args,
  952. input=cli_input)
  953. self.assert_result(result, 0)
  954. self._verify_load_facts(load_facts_mock)
  955. self._verify_run_playbook(run_playbook_mock, 1, 1)
  956. written_config = read_yaml(self.config_file)
  957. self._verify_config_hosts(written_config, 1)
  958. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  959. inventory.read(os.path.join(self.work_dir, 'hosts'))
  960. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  961. 'openshift_schedulable=True')
  962. @patch('ooinstall.openshift_ansible.run_main_playbook')
  963. @patch('ooinstall.openshift_ansible.load_system_facts')
  964. def test_gen_inventory(self, load_facts_mock, run_playbook_mock):
  965. load_facts_mock.return_value = (MOCK_FACTS, 0)
  966. run_playbook_mock.return_value = 0
  967. cli_input = build_input(hosts=[
  968. ('10.0.0.1', True, False),
  969. ('10.0.0.2', False, False),
  970. ('10.0.0.3', False, False)],
  971. ssh_user='root',
  972. variant_num=1,
  973. confirm_facts='y',
  974. storage='10.1.0.1',)
  975. self.cli_args.append("install")
  976. self.cli_args.append("--gen-inventory")
  977. result = self.runner.invoke(cli.cli, self.cli_args,
  978. input=cli_input)
  979. self.assert_result(result, 0)
  980. self._verify_load_facts(load_facts_mock)
  981. # Make sure run playbook wasn't called:
  982. self.assertEquals(0, len(run_playbook_mock.mock_calls))
  983. written_config = read_yaml(self.config_file)
  984. self._verify_config_hosts(written_config, 4)
  985. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  986. inventory.read(os.path.join(self.work_dir, 'hosts'))
  987. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  988. 'openshift_schedulable=False')
  989. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
  990. 'openshift_schedulable=True')
  991. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
  992. 'openshift_schedulable=True')
  993. # TODO: test with config file, attended add node
  994. # TODO: test with config file, attended new node already in config file
  995. # TODO: test with config file, attended new node already in config file, plus manually added nodes
  996. # TODO: test with config file, attended reject facts