summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Uniyal <auniyal@redhat.com>2022-08-25 05:08:44 +0000
committerAmit Uniyal <auniyal@redhat.com>2023-01-16 07:10:19 +0000
commit3969228eebac197fc9bbb700c5d6999e06dd71c5 (patch)
tree69e341d6a2cfc04832407a4c9f60fbe8560a0df0
parent4029b7b9f1b6d420fc470b8540162eec9d2303e8 (diff)
downloadnova-3969228eebac197fc9bbb700c5d6999e06dd71c5.tar.gz
Adds a repoducer for post live migration fail
Adds a regression test or repoducer for post live migration fail at destination, the possible casue can be fail to get instance network info or block device info changes: adds return server from _live_migrate in _integrated_helpers NOTE(auniyal): Differences * Replaced GlanceFixture with fake.stub_out_image_service in regression test, as GlanceFixture does not exist in Ussuri NOTE(auniyal): Differences from ussuri to train * integrated_helpers: Added self.api parameter while calling wait_for_state_change. * regression: imported mock module, as unitetest.mock is addted post train release. as _create_server is not present in train used _build_minimal_create_server instead to _create_server. Related-Bug: #1628606 Change-Id: I48dbe0aae8a3943fdde69cda1bd663d70ea0eb19 (cherry picked from commit a20baeca1f5ebb0dfe9607335a6986e9ed0e1725) (cherry picked from commit 74a618a8118642c9fd32c4e0d502d12ac826affe) (cherry picked from commit 71e5a1dbcc22aeaa798d3d06ce392cf73364b8db) (cherry picked from commit 5efcc3f695e02d61cb8b881e009308c2fef3aa58) (cherry picked from commit ed1ea71489b60c0f95d76ab05f554cd046c60bac) (cherry picked from commit 6dda4f7ca3f25a11cd0178352ad24fe2e8b74785) (cherry picked from commit 5e955b62fa63b72816369a21af283a2b64f4af27)
-rw-r--r--nova/tests/functional/integrated_helpers.py7
-rw-r--r--nova/tests/functional/regressions/test_bug_1628606.py72
2 files changed, 76 insertions, 3 deletions
diff --git a/nova/tests/functional/integrated_helpers.py b/nova/tests/functional/integrated_helpers.py
index 0ecafbe81d..35b422f7e5 100644
--- a/nova/tests/functional/integrated_helpers.py
+++ b/nova/tests/functional/integrated_helpers.py
@@ -380,10 +380,11 @@ class InstanceHelperMixin(object):
server_expected_state='ACTIVE'):
self.api.post_server_action(
server['id'],
- {'os-migrateLive': {'host': None,
- 'block_migration': 'auto'}})
- self._wait_for_state_change(self.api, server, server_expected_state)
+ {'os-migrateLive': {'host': None, 'block_migration': 'auto'}})
+ server = self._wait_for_state_change(
+ self.api, server, server_expected_state)
self._wait_for_migration_status(server, [migration_expected_state])
+ return server
class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
diff --git a/nova/tests/functional/regressions/test_bug_1628606.py b/nova/tests/functional/regressions/test_bug_1628606.py
new file mode 100644
index 0000000000..ba51d2e071
--- /dev/null
+++ b/nova/tests/functional/regressions/test_bug_1628606.py
@@ -0,0 +1,72 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import mock
+from nova import test
+from nova.tests import fixtures as nova_fixtures
+from nova.tests.functional.api import client
+from nova.tests.functional import fixtures as func_fixtures
+from nova.tests.functional import integrated_helpers
+from nova.tests.unit.image import fake
+
+
+class PostLiveMigrationFail(
+ test.TestCase, integrated_helpers.InstanceHelperMixin):
+ """Regression test for bug 1628606
+ """
+
+ def setUp(self):
+ super(PostLiveMigrationFail, self).setUp()
+ self.useFixture(nova_fixtures.NeutronFixture(self))
+ fake.stub_out_image_service(self)
+ self.useFixture(func_fixtures.PlacementFixture())
+ self.useFixture(nova_fixtures.HostNameWeigherFixture())
+
+ self.start_service('conductor')
+ self.start_service('scheduler')
+
+ api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
+ api_version='v2.1'))
+
+ self.admin_api = api_fixture.admin_api
+ self.api = api_fixture.api
+
+ # retrieve image already so we can set api.microversion as latest
+ self.image_id = self.api.get_images()[0]['id']
+
+ self.admin_api.microversion = 'latest'
+ self.api.microversion = 'latest'
+
+ self.src = self._start_compute(host='host1')
+ self.dest = self._start_compute(host='host2')
+
+ @mock.patch(
+ 'nova.compute.manager.ComputeManager'
+ '._post_live_migration_remove_source_vol_connections')
+ def test_post_live_migration(self, mock_migration):
+ server = self.admin_api.post_server(
+ dict(server=self._build_minimal_create_server_request(
+ self.api, 'test_post_live_migration', self.image_id,
+ networks='none')))
+ server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
+ self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])
+
+ error = client.OpenStackApiException(
+ "Failed to remove source vol connection post live migration")
+ mock_migration.side_effect = error
+
+ server = self._live_migrate(
+ server, migration_expected_state='error',
+ server_expected_state='ERROR')
+ # FIXME(amit): this should point to the dest as after migration
+ # but does not because of bug 1628606
+ self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])