From c54a911004011e20494cd132c2577496c9401a15 Mon Sep 17 00:00:00 2001 From: Weronika Sikora Date: Wed, 18 Sep 2019 13:55:07 +0000 Subject: [PATCH] Set image_alt_ssh_user during stack At this moment, only image_ssh_user is present in the config of Tempest. It's set to cirros by default and used for SSH connections in tests. However, several tests build instances with image_ref_alt, but still use image_ssh_user to connect, which results in failure if image_ref_alt is set to a non-cirros image. They should use image_alt_ssh_user instead, which can be set to whichever user the image_ref_alt needs in either local.conf or during plugin installation. This change replaces image_ssh_user with image_alt_ssh_user and modifies Tempest's config to have access to said variable. It also adds a password variable in Tempest's config for the alternative image. Change-Id: Ibe81a068c6fdeb7cd1eedf1df76ce62737160a01 Closes-Bug: #1844535 Depends-On: https://review.opendev.org/682902/ --- ...-ssh-user-config-option-1b775af2f468aa5b.yaml | 10 ++++++++++ tempest/api/compute/base.py | 3 +++ .../api/compute/servers/test_server_actions.py | 4 ++-- tempest/config.py | 7 +++++++ .../scenario/test_network_advanced_server_ops.py | 16 +++++++++------- 5 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/add-image-alt-ssh-user-config-option-1b775af2f468aa5b.yaml diff --git a/releasenotes/notes/add-image-alt-ssh-user-config-option-1b775af2f468aa5b.yaml b/releasenotes/notes/add-image-alt-ssh-user-config-option-1b775af2f468aa5b.yaml new file mode 100644 index 0000000000..159bbe80a2 --- /dev/null +++ b/releasenotes/notes/add-image-alt-ssh-user-config-option-1b775af2f468aa5b.yaml @@ -0,0 +1,10 @@ +--- +features: + - A new config option in the validation section, image_alt_ssh_user, + to specify the user name used to authenticate to an alternative + instance (instance using image_ref_alt) in tests. By default this + is set to root. + - A new config option in the validation section, image_alt_ssh_password, + to specify the password used to authenticate to an alternative + instance (instance using image_ref_alt) in tests. By default this + is set to password. diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index 8b847fc5bb..d19b4cdd6a 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -171,8 +171,11 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, cls.flavor_ref = CONF.compute.flavor_ref cls.flavor_ref_alt = CONF.compute.flavor_ref_alt cls.ssh_user = CONF.validation.image_ssh_user + cls.ssh_alt_user = CONF.validation.image_alt_ssh_user cls.image_ssh_user = CONF.validation.image_ssh_user + cls.image_alt_ssh_user = CONF.validation.image_alt_ssh_user cls.image_ssh_password = CONF.validation.image_ssh_password + cls.image_alt_ssh_password = CONF.validation.image_alt_ssh_password @classmethod def is_requested_microversion_compatible(cls, max_version): diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py index 343d3eef33..4527aa930b 100644 --- a/tempest/api/compute/servers/test_server_actions.py +++ b/tempest/api/compute/servers/test_server_actions.py @@ -228,7 +228,7 @@ class ServerActionsTestJSON(base.BaseV2ComputeTest): # 4.Plain username/password auth, if a password was given. linux_client = remote_client.RemoteClient( self.get_server_ip(rebuilt_server, validation_resources), - self.ssh_user, + self.ssh_alt_user, password, validation_resources['keypair']['private_key'], server=rebuilt_server, @@ -310,7 +310,7 @@ class ServerActionsTestJSON(base.BaseV2ComputeTest): self.os_primary) linux_client = remote_client.RemoteClient( self.get_server_ip(server, validation_resources), - self.ssh_user, + self.ssh_alt_user, password=None, pkey=validation_resources['keypair']['private_key'], server=server, diff --git a/tempest/config.py b/tempest/config.py index 28a70c2ecf..26a7fabf51 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -865,10 +865,17 @@ ValidationGroup = [ cfg.StrOpt('image_ssh_user', default="root", help="User name used to authenticate to an instance."), + cfg.StrOpt('image_alt_ssh_user', + default="root", + help="User name used to authenticate to an alt instance."), cfg.StrOpt('image_ssh_password', default="password", help="Password used to authenticate to an instance.", secret=True), + cfg.StrOpt('image_alt_ssh_password', + default="password", + help="Password used to authenticate to an alt instance.", + secret=True), cfg.StrOpt('ssh_shell_prologue', default="set -eu -o pipefail; PATH=$$PATH:/sbin:/usr/sbin;", help="Shell fragments to use before executing a command " diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py index e26dc9d0e8..dbab212acd 100644 --- a/tempest/scenario/test_network_advanced_server_ops.py +++ b/tempest/scenario/test_network_advanced_server_ops.py @@ -80,8 +80,8 @@ class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest): return floating_ip def _check_network_connectivity(self, server, keypair, floating_ip, - should_connect=True): - username = CONF.validation.image_ssh_user + should_connect=True, + username=CONF.validation.image_ssh_user): private_key = keypair['private_key'] self.check_tenant_network_connectivity( server, username, private_key, @@ -95,12 +95,13 @@ class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest): 'Public network connectivity check failed', server) - def _wait_server_status_and_check_network_connectivity(self, server, - keypair, - floating_ip): + def _wait_server_status_and_check_network_connectivity( + self, server, keypair, floating_ip, + username=CONF.validation.image_ssh_user): waiters.wait_for_server_status(self.servers_client, server['id'], 'ACTIVE') - self._check_network_connectivity(server, keypair, floating_ip) + self._check_network_connectivity(server, keypair, floating_ip, + username=username) @decorators.idempotent_id('61f1aa9a-1573-410e-9054-afa557cab021') @decorators.attr(type='slow') @@ -137,10 +138,11 @@ class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest): server = self._setup_server(keypair) floating_ip = self._setup_network(server, keypair) image_ref_alt = CONF.compute.image_ref_alt + username_alt = CONF.validation.image_alt_ssh_user self.servers_client.rebuild_server(server['id'], image_ref=image_ref_alt) self._wait_server_status_and_check_network_connectivity( - server, keypair, floating_ip) + server, keypair, floating_ip, username_alt) @decorators.idempotent_id('2b2642db-6568-4b35-b812-eceed3fa20ce') @testtools.skipUnless(CONF.compute_feature_enabled.pause,