From a8ddd68698d107c6de2f4297ba18a9d1f4e41309 Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Wed, 16 Aug 2017 16:26:02 -0400 Subject: [PATCH] Reduce number of hardcoded parameters in the tripleo test case --- novajoin_tempest_plugin/config.py | 27 ++++++++++------- novajoin_tempest_plugin/plugin.py | 10 +++---- .../tests/scenario/novajoin_manager.py | 20 ++++++++++--- .../tests/scenario/test_tripleo_deployment.py | 29 +++++++------------ 4 files changed, 49 insertions(+), 37 deletions(-) diff --git a/novajoin_tempest_plugin/config.py b/novajoin_tempest_plugin/config.py index 3f4cd06..c338927 100644 --- a/novajoin_tempest_plugin/config.py +++ b/novajoin_tempest_plugin/config.py @@ -20,15 +20,22 @@ service_option = cfg.BoolOpt("novajoin", help="Whether or not novajoin is expected to be " "available") -ipa_group = cfg.OptGroup( - name="ipa", - title="IPA connection information") +novajoin_group = cfg.OptGroup( + name="novajoin", + title="Novajoin test plugin settings") -IpaGroup = [ - cfg.StrOpt('username', - default='admin', - help='User to connect to IPA'), - cfg.StrOpt('password', - default='password', - help='Password to connect to IPA'), +NovajoinGroup = [ + cfg.StrOpt('keytab', + default='/home/stack/novajoin.keytab', + help='Keytab to connect to IPA as the novajoin user'), + cfg.StrOpt('tripleo', + default='True', + help='Run triple-O config tests'), + cfg.ListOpt('tripleo_controllers', + default=['overcloud-controller-0'], + help='List of overcloud controller short host names'), + cfg.StrOpt('tripleo_undercloud', + default='undercloud', + help='Undercloud short host name' + ) ] diff --git a/novajoin_tempest_plugin/plugin.py b/novajoin_tempest_plugin/plugin.py index e5f4828..aadad66 100644 --- a/novajoin_tempest_plugin/plugin.py +++ b/novajoin_tempest_plugin/plugin.py @@ -33,11 +33,11 @@ class NovajoinTempestPlugin(plugins.TempestPlugin): conf.register_opt(project_config.service_option, group='service_available') - # Register ipa connection options - conf.register_group(project_config.ipa_group) - conf.register_opts(project_config.IpaGroup, - project_config.ipa_group) + conf.register_group(project_config.novajoin_group) + conf.register_opts(project_config.NovajoinGroup, + project_config.novajoin_group) def get_opt_lists(self): return [('service_available', [project_config.service_option]), - (project_config.ipa_group.name, project_config.IpaGroup)] + (project_config.novajoin_group.name, + project_config.NovajoinGroup)] diff --git a/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py b/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py index fe58fef..56d379e 100644 --- a/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py +++ b/novajoin_tempest_plugin/tests/scenario/novajoin_manager.py @@ -48,15 +48,27 @@ class NovajoinScenarioTest(manager.ScenarioTest): super(NovajoinScenarioTest, cls).setup_clients() cls.ipa_client = ipa_client.IPAClient() - def verify_host_registered_with_ipa(self, host): + def verify_host_registered_with_ipa(self, host, add_domain=True): + if add_domain: + host = self.add_domain_to_host(host) result = self.ipa_client.find_host(host) self.assertTrue(result['count'] > 0) - def verify_host_not_registered_with_ipa(self, host): + def verify_host_not_registered_with_ipa(self, host, add_domain=True): + if add_domain: + host = self.add_domain_to_host(host) result = self.ipa_client.find_host(host) self.assertFalse(result['count'] > 0) - def verify_host_has_keytab(self, host): + def add_domain_to_host(self, host): + host = '{host}.{domain}'.format( + host=host, + domain=self.ipa_client.domain) + return host + + def verify_host_has_keytab(self, host, add_domain=True): + if add_domain: + host = self.add_domain_to_host(host) result = self.ipa_client.show_host(host)['result'] start = int(time.time()) keytab_status = result['has_keytab'] @@ -139,7 +151,7 @@ class NovajoinScenarioTest(manager.ScenarioTest): self.verify_service(service, subhost, verify_certs) def verify_service(self, service, host, verify_certs=False): - self.verify_host_registered_with_ipa(host) + self.verify_host_registered_with_ipa(host, add_domain=False) self.verify_service_created(service, host) self.verify_service_managed_by_host(service, host) if verify_certs: diff --git a/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py b/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py index f1a4361..1d8289f 100644 --- a/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py +++ b/novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py @@ -20,13 +20,6 @@ from tempest import config CONF = config.CONF LOG = logging.getLogger(__name__) -DOMAIN = 'tripleodomain.example.com' - -HOSTS = [ - 'undercloud', - 'overcloud-controller-0' -] - CONTROLLER_CERT_TAGS = [ 'mysql', 'rabbitmq', @@ -41,8 +34,6 @@ CONTROLLER_CERT_TAGS = [ 'haproxy-storage_mgmt-cert' ] -CONTROLLERS = ['overcloud-controller-0'] - class TripleOTest(novajoin_manager.NovajoinScenarioTest): @@ -67,7 +58,8 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest): @classmethod def skip_checks(cls): super(TripleOTest, cls).skip_checks() - pass + if not CONF.novajoin.tripleo: + raise cls.skipException('Tripleo configuration is not enabled') def _get_server_id(self, name): # params = {'name': name} @@ -82,13 +74,14 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest): return None def test_hosts_are_registered(self): - for host in HOSTS: - hostname = "{host}.{domain}".format(host=host, domain=DOMAIN) - self.verify_host_registered_with_ipa(hostname) - self.verify_host_has_keytab(hostname) + hosts = CONF.novajoin.tripleo_controllers.append( + CONF.novajoin.tripleo_undercloud) + for host in hosts: + self.verify_host_registered_with_ipa(host) + self.verify_host_has_keytab(host) def test_verify_compact_services_created(self): - for host in CONTROLLERS: + for host in CONF.novajoin.tripleo_controllers: metadata = self.servers_client.list_server_metadata( self._get_server_id(host))['metadata'] services = metadata['compact_services'] @@ -101,7 +94,7 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest): ) def test_verify_controller_managed_services(self): - for host in CONTROLLERS: + for host in CONF.novajoin.tripleo_controllers: metadata = self.servers_client.list_server_metadata( self._get_server_id(host))['metadata'] managed_services = [metadata[key] for key in metadata.keys() @@ -112,7 +105,7 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest): verify_certs=True) def test_verify_service_certs_are_tracked(self): - for host in CONTROLLERS: + for host in CONF.novajoin.tripleo_controllers: server_id = self._get_server_id(host) server = self.servers_client.show_server(server_id)['server'] server_ip = self.get_server_ip(server) @@ -125,7 +118,7 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest): ) def test_overcloud_is_ipaclient(self): - for host in CONTROLLERS: + for host in CONF.novajoin.tripleo_controllers: server_id = self._get_server_id(host) server = self.servers_client.show_server(server_id)['server'] server_ip = self.get_server_ip(server)