Merge "Change hostname_equals_servername to get_hostname"

This commit is contained in:
Jenkins 2016-06-21 10:07:20 +00:00 committed by Gerrit Code Review
commit 73c449834b
3 changed files with 8 additions and 10 deletions

View File

@ -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):

View File

@ -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')

View File

@ -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" \