summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Muresan <amuresan@cloudbasesolutions.com>2017-07-18 11:53:08 +0300
committerAlexandru Muresan <amuresan@cloudbasesolutions.com>2017-08-31 14:55:49 +0300
commit11f87904b2a1a6320f25463ac53b21b8874fee7b (patch)
tree9843ae4065ff283a8f20b8b406627e85dcd95a69
parent377943cb0d932b3552906b2cfde3bc50d7d3801e (diff)
Add Live Migration Mixin
Mixin does a live migration and checks if old host is different from destination host. Mixin is used in test_cluster.py and test_vnuma.py. Change-Id: Ia647b78b24feeba4e6b74ed08a21e8ac0955920d
Notes
Notes (review): Code-Review+2: Lucian Petrut <lpetrut@cloudbasesolutions.com> Code-Review+2: Claudiu Belu <cbelu@cloudbasesolutions.com> Workflow+1: Claudiu Belu <cbelu@cloudbasesolutions.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 06 Sep 2017 10:26:57 +0000 Reviewed-on: https://review.openstack.org/489240 Project: openstack/oswin-tempest-plugin Branch: refs/heads/master
-rw-r--r--oswin_tempest_plugin/tests/_mixins/migrate.py62
-rw-r--r--oswin_tempest_plugin/tests/scenario/test_cluster.py6
-rw-r--r--oswin_tempest_plugin/tests/scenario/test_vnuma.py1
-rw-r--r--oswin_tempest_plugin/tests/test_base.py5
4 files changed, 69 insertions, 5 deletions
diff --git a/oswin_tempest_plugin/tests/_mixins/migrate.py b/oswin_tempest_plugin/tests/_mixins/migrate.py
index 564ec51..9dad6e1 100644
--- a/oswin_tempest_plugin/tests/_mixins/migrate.py
+++ b/oswin_tempest_plugin/tests/_mixins/migrate.py
@@ -13,6 +13,7 @@
13# License for the specific language governing permissions and limitations 13# License for the specific language governing permissions and limitations
14# under the License. 14# under the License.
15 15
16from tempest.common import waiters
16import testtools 17import testtools
17 18
18from oswin_tempest_plugin import config 19from oswin_tempest_plugin import config
@@ -43,3 +44,64 @@ class _MigrateMixin(object):
43 server_tuple = self._create_server() 44 server_tuple = self._create_server()
44 self._migrate_server(server_tuple) 45 self._migrate_server(server_tuple)
45 self._check_server_connectivity(server_tuple) 46 self._check_server_connectivity(server_tuple)
47
48
49class _LiveMigrateMixin(object):
50 """Live migration mixin.
51
52 This mixin will add a live migration test. It will perform the
53 following operations:
54
55 * Spawn instance.
56 * Live migrate the instance.
57 * Check the server connectivity.
58 """
59
60 # TODO(amuresan): Different mixins may be used at the same time.
61 # Each of them may override some fields such as
62 # 'max_microversion'. This has to be sorted out.
63 max_microversion = '2.24'
64
65 def _live_migrate_server(self, server_tuple, destination_host=None,
66 state='ACTIVE', volume_backed=False):
67 server = server_tuple.server
68 admin_server = self._get_server_as_admin(server)
69 current_host = admin_server['OS-EXT-SRV-ATTR:host']
70
71 block_migration = (CONF.compute_feature_enabled.
72 block_migration_for_live_migration and
73 not volume_backed)
74
75 self.admin_servers_client.live_migrate_server(
76 server['id'],
77 host=destination_host,
78 block_migration=block_migration,
79 disk_over_commit=False)
80
81 waiters.wait_for_server_status(self.admin_servers_client, server['id'],
82 state)
83
84 admin_server = self._get_server_as_admin(server)
85 after_migration_host = admin_server['OS-EXT-SRV-ATTR:host']
86
87 migration_list = (self.admin_migrations_client.list_migrations()
88 ['migrations'])
89
90 msg = ("Live Migration failed. Migrations list for Instance "
91 "%s: [" % server['id'])
92 for live_migration in migration_list:
93 if live_migration['instance_uuid'] == server['id']:
94 msg += "\n%s" % live_migration
95 msg += "]"
96
97 if destination_host:
98 self.assertEqual(destination_host, after_migration_host, msg)
99 else:
100 self.assertNotEqual(current_host, after_migration_host, msg)
101
102 @testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
103 'Live migration option enabled.')
104 def test_live_migration(self):
105 server_tuple = self._create_server()
106 self._live_migrate_server(server_tuple)
107 self._check_server_connectivity(server_tuple)
diff --git a/oswin_tempest_plugin/tests/scenario/test_cluster.py b/oswin_tempest_plugin/tests/scenario/test_cluster.py
index 0a68963..5dec3d4 100644
--- a/oswin_tempest_plugin/tests/scenario/test_cluster.py
+++ b/oswin_tempest_plugin/tests/scenario/test_cluster.py
@@ -31,6 +31,7 @@ LOG = logging.getLogger(__name__)
31 31
32class HyperVClusterTest(test_base.TestBase, 32class HyperVClusterTest(test_base.TestBase,
33 migrate._MigrateMixin, 33 migrate._MigrateMixin,
34 migrate._LiveMigrateMixin,
34 resize._ResizeMixin): 35 resize._ResizeMixin):
35 36
36 """The test suite for the Hyper-V Cluster. 37 """The test suite for the Hyper-V Cluster.
@@ -134,11 +135,6 @@ class HyperVClusterTest(test_base.TestBase,
134 res_type='hypervisor') 135 res_type='hypervisor')
135 return hypervisor[0] 136 return hypervisor[0]
136 137
137 def _get_server_as_admin(self, server):
138 # only admins have access to certain instance properties.
139 return self.admin_servers_client.show_server(
140 server['id'])['server']
141
142 def _create_server(self): 138 def _create_server(self):
143 server_tuple = super(HyperVClusterTest, self)._create_server() 139 server_tuple = super(HyperVClusterTest, self)._create_server()
144 server = server_tuple.server 140 server = server_tuple.server
diff --git a/oswin_tempest_plugin/tests/scenario/test_vnuma.py b/oswin_tempest_plugin/tests/scenario/test_vnuma.py
index 2b95294..5e95646 100644
--- a/oswin_tempest_plugin/tests/scenario/test_vnuma.py
+++ b/oswin_tempest_plugin/tests/scenario/test_vnuma.py
@@ -21,6 +21,7 @@ from oswin_tempest_plugin.tests import test_base
21 21
22class HyperVvNumaTestCase(test_base.TestBase, 22class HyperVvNumaTestCase(test_base.TestBase,
23 migrate._MigrateMixin, 23 migrate._MigrateMixin,
24 migrate._LiveMigrateMixin,
24 optional_feature._OptionalFeatureMixin, 25 optional_feature._OptionalFeatureMixin,
25 resize._ResizeMixin): 26 resize._ResizeMixin):
26 """Hyper-V vNUMA test suite. 27 """Hyper-V vNUMA test suite.
diff --git a/oswin_tempest_plugin/tests/test_base.py b/oswin_tempest_plugin/tests/test_base.py
index c99dd9e..480cf9d 100644
--- a/oswin_tempest_plugin/tests/test_base.py
+++ b/oswin_tempest_plugin/tests/test_base.py
@@ -186,6 +186,11 @@ class TestBase(tempest.test.BaseTestCase):
186 186
187 return server_tuple 187 return server_tuple
188 188
189 def _get_server_as_admin(self, server):
190 # only admins have access to certain instance properties.
191 return self.admin_servers_client.show_server(
192 server['id'])['server']
193
189 def _create_security_group(self): 194 def _create_security_group(self):
190 sg_name = data_utils.rand_name(self.__class__.__name__) 195 sg_name = data_utils.rand_name(self.__class__.__name__)
191 sg_desc = sg_name + " description" 196 sg_desc = sg_name + " description"