f94b2d41f6
With commit f7a50a24b9d68866da615939136e84e460f4df62 (Change ID: I99541d36aed6d4b9f83746c1cd1a5521b310f1f6, https://review.openstack.org/#/c/369485/) the inventory configuration was split into multiple files to enable scenario AIO testing. This had the side effect of no longer populating inventory with a full config file - the tests/inventory/openstack_user_config.yml file was a symlink to etc/openstack_deploy/openstack_user_config.yml.aio, which only had a handful of groups. The result was that only 7 host entries appeared in inventory: aio1, galera, rabbitmq, memcache, log, repo, and haproxy containers. These coincide with the groups defined only in the openstack_user_config.yml.aio file. To make the inventory tests more robust against changes like these, this patch adds some module-level fixtures that generate the test configuration file from all the files ending with '.aio'. This file is dynamically constructed at the beginning of each test run, and deleted afterwards. The symlink to the openstack_user_config.yml.aio file is removed in favor of this dynamically created file, though a placeholder file remains to keep the directory in git. A test was added to ensure any configured groups have hosts added; this should serve as a safeguard against similar reconstructions. No check is made for groups defined by the environment but unpopulated by config, such as cinder_volumes_containers. The original file could have been kept as a placeholder, but it would be marked as changed by git after every test run. The management tests were also updated to make use of the dynamic configuration creation. Change-Id: Ie4ba9c50315736a0b86e0caa2cccb0908c452a49
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
|
|
import os
|
|
from os import path
|
|
import sys
|
|
import test_inventory
|
|
import unittest
|
|
|
|
MANAGE_DIR = path.join(os.getcwd(), 'scripts')
|
|
|
|
sys.path.append(MANAGE_DIR)
|
|
|
|
import manage_inventory as mi
|
|
|
|
|
|
def setUpModule():
|
|
test_inventory.make_config()
|
|
|
|
|
|
def tearDownModule():
|
|
os.remove(test_inventory.USER_CONFIG_FILE)
|
|
|
|
|
|
class TestExportFunction(unittest.TestCase):
|
|
def setUp(self):
|
|
self.inv = test_inventory.get_inventory()
|
|
|
|
def tearDown(self):
|
|
test_inventory.cleanup()
|
|
|
|
def test_host_is_present(self):
|
|
host_inv = mi.export_host_info(self.inv)['hosts']
|
|
self.assertIn('aio1', host_inv.keys())
|
|
|
|
def test_groups_added(self):
|
|
host_inv = mi.export_host_info(self.inv)['hosts']
|
|
self.assertIn('groups', host_inv['aio1'].keys())
|
|
|
|
def test_variables_added(self):
|
|
host_inv = mi.export_host_info(self.inv)['hosts']
|
|
self.assertIn('hostvars', host_inv['aio1'].keys())
|
|
|
|
def test_number_of_hosts(self):
|
|
host_inv = mi.export_host_info(self.inv)['hosts']
|
|
|
|
self.assertEqual(len(self.inv['_meta']['hostvars']),
|
|
len(host_inv))
|
|
|
|
def test_all_information_added(self):
|
|
all_info = mi.export_host_info(self.inv)['all']
|
|
self.assertIn('provider_networks', all_info)
|
|
|
|
def test_all_lb_information(self):
|
|
all_info = mi.export_host_info(self.inv)['all']
|
|
inv_all = self.inv['all']['vars']
|
|
self.assertEqual(inv_all['internal_lb_vip_address'],
|
|
all_info['internal_lb_vip_address'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|