diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py index 07423ff70..da9d54894 100644 --- a/tempest/api/compute/servers/test_create_server.py +++ b/tempest/api/compute/servers/test_create_server.py @@ -136,7 +136,10 @@ class ServersTestJSON(base.BaseV2ComputeTest): self.validation_resources['keypair']['private_key'], server=self.server, servers_client=self.client) - self.assertTrue(linux_client.hostname_equals_servername(self.name)) + hostname = linux_client.get_hostname() + msg = ('Failed while verifying servername equals hostname. Expected ' + 'hostname "%s" but got "%s".' % (self.name, hostname)) + self.assertEqual(self.name, hostname, msg) @test.idempotent_id('ed20d3fb-9d1f-4329-b160-543fbd5d9811') def test_create_server_with_scheduler_hint_group(self): diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py index 0a3e8d384..7cb9ebee8 100644 --- a/tempest/common/utils/linux/remote_client.py +++ b/tempest/common/utils/linux/remote_client.py @@ -99,10 +99,10 @@ class RemoteClient(object): """ self.ssh_client.test_connection_auth() - def hostname_equals_servername(self, expected_hostname): + def get_hostname(self): # Get host name using command "hostname" actual_hostname = self.exec_command("hostname").rstrip() - return expected_hostname == actual_hostname + return actual_hostname def get_ram_size_in_mb(self): output = self.exec_command('free -m | grep Mem') diff --git a/tempest/tests/common/utils/linux/test_remote_client.py b/tempest/tests/common/utils/linux/test_remote_client.py index 7d625cf70..e59e08f52 100644 --- a/tempest/tests/common/utils/linux/test_remote_client.py +++ b/tempest/tests/common/utils/linux/test_remote_client.py @@ -67,14 +67,9 @@ class TestRemoteClient(base.TestCase): self.ssh_mock = self.useFixture(mockpatch.PatchObject(self.conn, 'ssh_client')) - def test_hostname_equals_servername_for_expected_names(self): + def test_get_hostname(self): self.ssh_mock.mock.exec_command.return_value = 'fake_hostname' - self.assertTrue(self.conn.hostname_equals_servername('fake_hostname')) - - def test_hostname_equals_servername_for_unexpected_names(self): - self.ssh_mock.mock.exec_command.return_value = 'fake_hostname' - self.assertFalse( - self.conn.hostname_equals_servername('unexpected_hostname')) + self.assertEqual(self.conn.get_hostname(), 'fake_hostname') def test_get_ram_size(self): free_output = "Mem: 48294 45738 2555 0" \