cli_installer_tests.py 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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_scaleup_hint(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. # This is testing the install workflow so we want to make sure we
  772. # exit with the appropriate hint.
  773. self.assertTrue('scaleup' in result.output)
  774. self.assert_result(result, 1)
  775. @patch('ooinstall.openshift_ansible.run_main_playbook')
  776. @patch('ooinstall.openshift_ansible.load_system_facts')
  777. def test_fresh_install_with_config(self, load_facts_mock, run_playbook_mock):
  778. load_facts_mock.return_value = (MOCK_FACTS, 0)
  779. run_playbook_mock.return_value = 0
  780. config_file = self.write_config(os.path.join(self.work_dir,
  781. 'ooinstall.conf'),
  782. SAMPLE_CONFIG % 'openshift-enterprise')
  783. cli_input = build_input(confirm_facts='y')
  784. self.cli_args.extend(["-c", config_file])
  785. self.cli_args.append("install")
  786. result = self.runner.invoke(cli.cli,
  787. self.cli_args,
  788. input=cli_input)
  789. self.assert_result(result, 0)
  790. self._verify_load_facts(load_facts_mock)
  791. self._verify_run_playbook(run_playbook_mock, 3, 3)
  792. written_config = read_yaml(config_file)
  793. self._verify_config_hosts(written_config, 3)
  794. # #interactive with config file and all installed hosts
  795. # @patch('ooinstall.openshift_ansible.run_main_playbook')
  796. # @patch('ooinstall.openshift_ansible.load_system_facts')
  797. # def test_get_hosts_to_run_on(self, load_facts_mock, run_playbook_mock):
  798. # mock_facts = copy.deepcopy(MOCK_FACTS)
  799. # mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
  800. # mock_facts['10.0.0.2']['common']['version'] = "3.0.0"
  801. #
  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. #
  812. # self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock,
  813. # run_playbook_mock,
  814. # cli_input,
  815. # exp_hosts_len=2,
  816. # exp_hosts_to_run_on_len=2,
  817. # force=False)
  818. #interactive multimaster: one more node than master
  819. @patch('ooinstall.openshift_ansible.run_main_playbook')
  820. @patch('ooinstall.openshift_ansible.load_system_facts')
  821. def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):
  822. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  823. run_playbook_mock.return_value = 0
  824. cli_input = build_input(hosts=[
  825. ('10.0.0.1', True, False),
  826. ('10.0.0.2', True, False),
  827. ('10.0.0.3', True, False),
  828. ('10.0.0.4', False, False)],
  829. ssh_user='root',
  830. variant_num=1,
  831. confirm_facts='y',
  832. master_lb=('10.0.0.5', False),
  833. storage='10.1.0.1',)
  834. self.cli_args.append("install")
  835. result = self.runner.invoke(cli.cli, self.cli_args,
  836. input=cli_input)
  837. self.assert_result(result, 0)
  838. self._verify_load_facts(load_facts_mock)
  839. self._verify_run_playbook(run_playbook_mock, 6, 6)
  840. written_config = read_yaml(self.config_file)
  841. self._verify_config_hosts(written_config, 6)
  842. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  843. inventory.read(os.path.join(self.work_dir, 'hosts'))
  844. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  845. 'openshift_schedulable=False')
  846. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
  847. 'openshift_schedulable=False')
  848. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
  849. 'openshift_schedulable=False')
  850. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.4',
  851. 'openshift_schedulable=True')
  852. self.assertTrue(inventory.has_section('etcd'))
  853. self.assertEquals(3, len(inventory.items('etcd')))
  854. #interactive multimaster: identical masters and nodes
  855. @patch('ooinstall.openshift_ansible.run_main_playbook')
  856. @patch('ooinstall.openshift_ansible.load_system_facts')
  857. def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):
  858. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  859. run_playbook_mock.return_value = 0
  860. cli_input = build_input(hosts=[
  861. ('10.0.0.1', True, False),
  862. ('10.0.0.2', True, False),
  863. ('10.0.0.3', True, False)],
  864. ssh_user='root',
  865. variant_num=1,
  866. confirm_facts='y',
  867. master_lb=('10.0.0.5', False),
  868. storage='10.1.0.1',)
  869. self.cli_args.append("install")
  870. result = self.runner.invoke(cli.cli, self.cli_args,
  871. input=cli_input)
  872. self.assert_result(result, 0)
  873. self._verify_load_facts(load_facts_mock)
  874. self._verify_run_playbook(run_playbook_mock, 5, 5)
  875. written_config = read_yaml(self.config_file)
  876. self._verify_config_hosts(written_config, 5)
  877. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  878. inventory.read(os.path.join(self.work_dir, 'hosts'))
  879. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  880. 'openshift_schedulable=True')
  881. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
  882. 'openshift_schedulable=True')
  883. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
  884. 'openshift_schedulable=True')
  885. # Checks the inventory (as a ConfigParser) for the given host, host
  886. # variable, and expected value.
  887. def assert_inventory_host_var(self, inventory, section, host, variable):
  888. # Config parser splits on the first "=", so we end up with:
  889. # 'hostname key1' -> 'val1 key2=val2 key3=val3'
  890. #
  891. # Convert to something easier to test:
  892. for (a, b) in inventory.items(section):
  893. full_line = "%s=%s" % (a, b)
  894. tokens = full_line.split()
  895. if tokens[0] == host:
  896. found = False
  897. for token in tokens:
  898. if token == variable:
  899. found = True
  900. continue
  901. self.assertTrue("Unable to find %s in line: %s" %
  902. (variable, full_line), found)
  903. return
  904. self.fail("unable to find host %s in inventory" % host)
  905. def assert_inventory_host_var_unset(self, inventory, section, host, variable):
  906. # Config parser splits on the first "=", so we end up with:
  907. # 'hostname key1' -> 'val1 key2=val2 key3=val3'
  908. #
  909. # Convert to something easier to test:
  910. for (a, b) in inventory.items(section):
  911. full_line = "%s=%s" % (a, b)
  912. tokens = full_line.split()
  913. if tokens[0] == host:
  914. self.assertFalse(("%s=" % variable) in full_line,
  915. msg='%s host variable was set: %s' %
  916. (variable, full_line))
  917. return
  918. self.fail("unable to find host %s in inventory" % host)
  919. #interactive multimaster: attempting to use a master as the load balancer should fail:
  920. @patch('ooinstall.openshift_ansible.run_main_playbook')
  921. @patch('ooinstall.openshift_ansible.load_system_facts')
  922. def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):
  923. load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
  924. run_playbook_mock.return_value = 0
  925. cli_input = build_input(hosts=[
  926. ('10.0.0.1', True, False),
  927. ('10.0.0.2', True, False),
  928. ('10.0.0.3', False, False),
  929. ('10.0.0.4', True, False)],
  930. ssh_user='root',
  931. variant_num=1,
  932. confirm_facts='y',
  933. master_lb=(['10.0.0.2', '10.0.0.5'], False),
  934. storage='10.1.0.1')
  935. self.cli_args.append("install")
  936. result = self.runner.invoke(cli.cli, self.cli_args,
  937. input=cli_input)
  938. self.assert_result(result, 0)
  939. #interactive all-in-one
  940. @patch('ooinstall.openshift_ansible.run_main_playbook')
  941. @patch('ooinstall.openshift_ansible.load_system_facts')
  942. def test_all_in_one(self, load_facts_mock, run_playbook_mock):
  943. load_facts_mock.return_value = (MOCK_FACTS, 0)
  944. run_playbook_mock.return_value = 0
  945. cli_input = build_input(hosts=[
  946. ('10.0.0.1', True, False)],
  947. ssh_user='root',
  948. variant_num=1,
  949. confirm_facts='y',
  950. storage='10.0.0.1')
  951. self.cli_args.append("install")
  952. result = self.runner.invoke(cli.cli, self.cli_args,
  953. input=cli_input)
  954. self.assert_result(result, 0)
  955. self._verify_load_facts(load_facts_mock)
  956. self._verify_run_playbook(run_playbook_mock, 1, 1)
  957. written_config = read_yaml(self.config_file)
  958. self._verify_config_hosts(written_config, 1)
  959. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  960. inventory.read(os.path.join(self.work_dir, 'hosts'))
  961. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  962. 'openshift_schedulable=True')
  963. @patch('ooinstall.openshift_ansible.run_main_playbook')
  964. @patch('ooinstall.openshift_ansible.load_system_facts')
  965. def test_gen_inventory(self, load_facts_mock, run_playbook_mock):
  966. load_facts_mock.return_value = (MOCK_FACTS, 0)
  967. run_playbook_mock.return_value = 0
  968. cli_input = build_input(hosts=[
  969. ('10.0.0.1', True, False),
  970. ('10.0.0.2', False, False),
  971. ('10.0.0.3', False, False)],
  972. ssh_user='root',
  973. variant_num=1,
  974. confirm_facts='y',
  975. storage='10.1.0.1',)
  976. self.cli_args.append("install")
  977. self.cli_args.append("--gen-inventory")
  978. result = self.runner.invoke(cli.cli, self.cli_args,
  979. input=cli_input)
  980. self.assert_result(result, 0)
  981. self._verify_load_facts(load_facts_mock)
  982. # Make sure run playbook wasn't called:
  983. self.assertEquals(0, len(run_playbook_mock.mock_calls))
  984. written_config = read_yaml(self.config_file)
  985. self._verify_config_hosts(written_config, 4)
  986. inventory = ConfigParser.ConfigParser(allow_no_value=True)
  987. inventory.read(os.path.join(self.work_dir, 'hosts'))
  988. self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
  989. 'openshift_schedulable=False')
  990. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
  991. 'openshift_schedulable=True')
  992. self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
  993. 'openshift_schedulable=True')
  994. # TODO: test with config file, attended add node
  995. # TODO: test with config file, attended new node already in config file
  996. # TODO: test with config file, attended new node already in config file, plus manually added nodes
  997. # TODO: test with config file, attended reject facts