From 4b1b9dff58edf8f0034c7038ae787b63d1d42600 Mon Sep 17 00:00:00 2001 From: zhufl Date: Tue, 13 Mar 2018 16:02:50 +0800 Subject: [PATCH] Fix test_host_name_is_same_as_server_name Some images will add postfix for the hostname, e.g., if hostname is "aaa", postfix ".novalocal" may be added to it, and the hostname will be "aaa.novalocal" then, so we should ignore the postfix when checking whether hostname equals self.name. Change-Id: Ie3d603875c029ca705ee58e0f4e9d11950f509aa Closes-Bug: #1755398 --- tempest/api/compute/servers/test_create_server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py index c660821840..122c4f5848 100644 --- a/tempest/api/compute/servers/test_create_server.py +++ b/tempest/api/compute/servers/test_create_server.py @@ -135,8 +135,13 @@ class ServersTestJSON(base.BaseV2ComputeTest): servers_client=self.client) hostname = linux_client.exec_command("hostname").rstrip() msg = ('Failed while verifying servername equals hostname. Expected ' - 'hostname "%s" but got "%s".' % (self.name, hostname)) - self.assertEqual(self.name.lower(), hostname, msg) + 'hostname "%s" but got "%s".' % + (self.name, hostname.split(".")[0])) + # NOTE(zhufl): Some images will add postfix for the hostname, e.g., + # if hostname is "aaa", postfix ".novalocal" may be added to it, and + # the hostname will be "aaa.novalocal" then, so we should ignore the + # postfix when checking whether hostname equals self.name. + self.assertEqual(self.name.lower(), hostname.split(".")[0], msg) class ServersTestManualDisk(ServersTestJSON):