diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_vrrp.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_vrrp.py index cd7b339..5e50bc4 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_vrrp.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_vrrp.py @@ -15,6 +15,7 @@ from neutron_lib import constants from neutron_tempest_plugin.common import ssh +from neutron_tempest_plugin.common import utils as common_utils from neutron_tempest_plugin import config from neutron_tempest_plugin import exceptions from oslo_log import log @@ -50,26 +51,9 @@ def get_keepalived_config(interface, vip_ip): return keepalived_config_template % (interface, vip_ip) -class VrrpTest(base.BaseTempestWhiteboxTestCase): +class VrrpTest(base.BaseTempestTestCaseAdvanced): credentials = ['primary', 'admin'] - @classmethod - def skip_checks(cls): - super(VrrpTest, cls).skip_checks() - if CONF.neutron_plugin_options.default_image_is_advanced: - cls.flavor_ref = CONF.compute.flavor_ref - cls.image_ref = CONF.compute.image_ref - cls.username = CONF.validation.image_ssh_user - else: - cls.flavor_ref = \ - CONF.neutron_plugin_options.advanced_image_flavor_ref - cls.image_ref = CONF.neutron_plugin_options.advanced_image_ref - cls.username = CONF.neutron_plugin_options.advanced_image_ssh_user - - if (not cls.flavor_ref) or (not cls.image_ref): - raise cls.skipException( - 'No advanced image/flavor available for these tests') - @classmethod @utils.requires_ext(extension="router", service="network") def resource_setup(cls): @@ -113,6 +97,11 @@ class VrrpTest(base.BaseTempestWhiteboxTestCase): raise self.skipException( "keepalived is not available on server %s" % (server_id)) + @staticmethod + def _is_keepalived_service_active(ssh_client): + output = ssh_client.exec_command("sudo systemctl is-active keepalived") + return 'active' == output.splitlines()[0] + def _prepare_server(self, ssh_client, interface, vip_ip): config_text = get_keepalived_config(interface, vip_ip) config_file = 'keepalived.conf' @@ -120,8 +109,12 @@ class VrrpTest(base.BaseTempestWhiteboxTestCase): 'echo "{0}" > /tmp/{1};' 'sudo mv -Z /tmp/{1} /etc/keepalived/'.format( config_text, config_file)) - # restart and make sure keepalived is active - self.reset_node_service('keepalived', ssh_client) + ssh_client.exec_command("sudo systemctl restart keepalived") + # make sure keepalived is active + common_utils.wait_until_true( + lambda: self._is_keepalived_service_active(ssh_client=ssh_client), + timeout=20, + exception=RuntimeError("Timed out waiting for keepalived active")) @staticmethod def _get_vm_id_by_name(name, vms):