def test_relative_cert_path(self): conf = config_fixture.Config() self.useFixture(conf) conf.config(undercloud_service_certificate='test.pem') env = undercloud._generate_environment('.') self.assertEqual(os.path.join(os.getcwd(), 'test.pem'), env['UNDERCLOUD_SERVICE_CERTIFICATE'])
def test_absolute_cert_path(self): conf = config_fixture.Config() self.useFixture(conf) conf.config(undercloud_service_certificate='/home/stack/test.pem') env = undercloud._generate_environment('.') self.assertEqual('/home/stack/test.pem', env['UNDERCLOUD_SERVICE_CERTIFICATE'])
def test_centos7_distro(self): self.useFixture(fixtures.EnvironmentVariable('NODE_DIST', None)) self.mock_distro.mock.return_value = ['CentOS Linux release 7.1'] env = undercloud._generate_environment('.') self.assertEqual('centos7', env['NODE_DIST']) self.assertEqual('./json-files/centos-7-undercloud-packages.json', env['JSONFILE'])
def test_opts_in_env(self): env = undercloud._generate_environment('.') # Just spot check, we don't want to replicate the entire opt list here self.assertEqual(env['INSPECTION_COLLECTORS'], 'default,extra-hardware,logs') self.assertEqual('192.0.2.1/24', env['PUBLIC_INTERFACE_IP']) self.assertEqual('192.0.2.1', env['LOCAL_IP'])
def test_default_elements_path(self): env = undercloud._generate_environment('.') test_path = ('%s:%s:/usr/share/tripleo-image-elements:' '/usr/share/diskimage-builder/elements' % (os.path.join(os.getcwd(), 'tripleo-puppet-elements', 'elements'), './elements')) self.assertEqual(test_path, env['ELEMENTS_PATH'])
def test_rhel7_distro(self): self.useFixture(fixtures.EnvironmentVariable('NODE_DIST', None)) env = undercloud._generate_environment('.') self.assertEqual('rhel7', env['NODE_DIST']) self.assertEqual('./json-files/rhel-7-undercloud-packages.json', env['JSONFILE']) self.assertEqual('disable', env['REG_METHOD']) self.assertEqual('1', env['REG_HALT_UNREGISTER'])
def test_opts_in_env(self): env = undercloud._generate_environment('.') # Just spot check, we don't want to replicate the entire opt list here self.assertEqual(env['INSPECTION_COLLECTORS'], 'default,extra-hardware,logs') self.assertEqual('192.168.24.1/24', env['PUBLIC_INTERFACE_IP']) self.assertEqual('192.168.24.1', env['LOCAL_IP']) # The list is generated from a set, so we can't rely on ordering. # Instead make sure that it looks like a valid list by parsing it. drivers = json.loads(env['ENABLED_DRIVERS']) self.assertEqual(sorted(drivers), ['pxe_drac', 'pxe_ilo', 'pxe_ipmitool', 'pxe_ssh'])
def test_generate_endpoints_ssl_auto(self): conf = config_fixture.Config() self.useFixture(conf) conf.config(generate_service_certificate=True) env = undercloud._generate_environment('.') # Spot check one service self.assertEqual('https://192.0.2.2:13000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_PUBLIC']) self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_INTERNAL']) self.assertEqual('http://192.0.2.1:35357', env['UNDERCLOUD_ENDPOINT_KEYSTONE_ADMIN']) # Also check that the tenant id part is preserved self.assertEqual('https://192.0.2.2:13808/v1/AUTH_%(tenant_id)s', env['UNDERCLOUD_ENDPOINT_SWIFT_PUBLIC'])
def test_generate_endpoints_ssl(self): conf = config_fixture.Config() self.useFixture(conf) conf.config(undercloud_service_certificate='test.pem') env = undercloud._generate_environment('.') # Spot check one service self.assertEqual('https://192.0.2.2:13000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_PUBLIC']) self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_INTERNAL']) self.assertEqual('http://192.0.2.1:35357', env['UNDERCLOUD_ENDPOINT_KEYSTONE_ADMIN']) # Also check that the tenant id part is preserved self.assertEqual('https://192.0.2.2:13808/v1/AUTH_%(tenant_id)s', env['UNDERCLOUD_ENDPOINT_SWIFT_PUBLIC'])
def test_generate_endpoints(self): env = undercloud._generate_environment('.') endpoint_vars = {k: v for (k, v) in env.items() if k.startswith('UNDERCLOUD_ENDPOINT')} self.assertEqual(30, len(endpoint_vars)) # Spot check one service self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_PUBLIC']) self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_INTERNAL']) self.assertEqual('http://192.0.2.1:35357', env['UNDERCLOUD_ENDPOINT_KEYSTONE_ADMIN']) # Also check that the tenant id part is preserved self.assertEqual('http://192.0.2.1:8080/v1/AUTH_%(tenant_id)s', env['UNDERCLOUD_ENDPOINT_SWIFT_PUBLIC'])
def test_generate_endpoints(self): env = undercloud._generate_environment('.') endpoint_vars = { k: v for (k, v) in env.items() if k.startswith('UNDERCLOUD_ENDPOINT') } self.assertEqual(39, len(endpoint_vars)) # Spot check one service self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_PUBLIC']) self.assertEqual('http://192.0.2.1:5000', env['UNDERCLOUD_ENDPOINT_KEYSTONE_INTERNAL']) self.assertEqual('http://192.0.2.1:35357', env['UNDERCLOUD_ENDPOINT_KEYSTONE_ADMIN']) # Also check that the tenant id part is preserved self.assertEqual('http://192.0.2.1:8080/v1/AUTH_%(tenant_id)s', env['UNDERCLOUD_ENDPOINT_SWIFT_PUBLIC'])
def test_no_cert_path(self): env = undercloud._generate_environment('.') self.assertEqual('', env['UNDERCLOUD_SERVICE_CERTIFICATE'])
def test_elements_path_input(self): test_path = '/test/elements/path' self.useFixture( fixtures.EnvironmentVariable('ELEMENTS_PATH', test_path)) env = undercloud._generate_environment('.') self.assertEqual(test_path, env['ELEMENTS_PATH'])
def test_hostname_set(self, mock_gethostname): fake_hostname = 'crazy-test-hostname-!@#$%12345' mock_gethostname.return_value = fake_hostname env = undercloud._generate_environment('.') self.assertEqual(fake_hostname, env['HOSTNAME'])
def test_answers_file_support(self): with open(undercloud.PATHS.ANSWERS_PATH, 'w') as f: f.write('LOCAL_INTERFACE=eno1\n') env = undercloud._generate_environment('.') self.assertEqual('eno1', env['LOCAL_INTERFACE'])
def test_elements_path_input(self): test_path = '/test/elements/path' self.useFixture(fixtures.EnvironmentVariable('ELEMENTS_PATH', test_path)) env = undercloud._generate_environment('.') self.assertEqual(test_path, env['ELEMENTS_PATH'])
def test_opts_in_env(self): env = undercloud._generate_environment('.') # Just spot check, we don't want to replicate the entire opt list here self.assertEqual(env['INSPECTION_RUNBENCH'], '0') self.assertEqual('192.0.2.1/24', env['PUBLIC_INTERFACE_IP']) self.assertEqual('192.0.2.1', env['LOCAL_IP'])
def test_remove_dib_yum_repo_conf(self): self.useFixture( fixtures.EnvironmentVariable('DIB_YUM_REPO_CONF', 'rum_yepo.conf')) env = undercloud._generate_environment('.') self.assertNotIn(env, 'DIB_YUM_REPO_CONF')
def test_remove_dib_yum_repo_conf(self): self.useFixture(fixtures.EnvironmentVariable('DIB_YUM_REPO_CONF', 'rum_yepo.conf')) env = undercloud._generate_environment('.') self.assertNotIn(env, 'DIB_YUM_REPO_CONF')
def test_opts_in_env(self): env = undercloud._generate_environment('.') # Just spot check, we don't want to replicate the entire opt list here self.assertEqual(env['DISCOVERY_RUNBENCH'], '0') self.assertEqual('192.0.2.1/24', env['PUBLIC_INTERFACE_IP']) self.assertEqual('192.0.2.1', env['LOCAL_IP'])