Skip to content

Commit 9e6b44b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Adds a repoducer for post_live_migration_at_destination failures"
2 parents 897a91b + 9584d0a commit 9e6b44b

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import nova
14+
15+
from nova import test
16+
from nova.tests import fixtures as nova_fixtures
17+
from nova.tests.functional import fixtures as func_fixtures
18+
from nova.tests.functional import integrated_helpers
19+
import oslo_messaging as messaging
20+
from unittest import mock
21+
22+
23+
class PostLiveMigrationFail(
24+
test.TestCase, integrated_helpers.InstanceHelperMixin):
25+
"""Regression test for bug 2143972
26+
"""
27+
28+
def setUp(self):
29+
super().setUp()
30+
self.useFixture(nova_fixtures.NeutronFixture(self))
31+
self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
32+
self.useFixture(func_fixtures.PlacementFixture())
33+
self.useFixture(nova_fixtures.HostNameWeigherFixture())
34+
35+
self.start_service('conductor')
36+
self.start_service('scheduler')
37+
38+
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
39+
api_version='v2.1'))
40+
41+
self.api = api_fixture.admin_api
42+
self.api.microversion = 'latest'
43+
44+
self.src = self._start_compute(host='host1')
45+
self.dest = self._start_compute(host='host2')
46+
47+
def test_post_live_migration_keystone_fails(self):
48+
"""Test for bug 2143972.
49+
This test simulate a service failure during post live migration.
50+
"""
51+
orig_function = nova.network.neutron.API.setup_networks_on_host
52+
service_exception = messaging.RemoteError(
53+
exc_type="Remote Error",
54+
value="ServiceUnavailable The server is currently "
55+
"unavailable.")
56+
self.count_call = 0
57+
58+
# Fist setup_networks_on_host call is in the pre_live_migration method.
59+
# Second setup_networks_on_host call is in the post_live_migration
60+
# method.
61+
def fake_setup_networks_on_host(*args, **kwargs):
62+
"""Call the original function first and then raise an exception
63+
simulating keystone or neutron not available.
64+
"""
65+
self.count_call += 1
66+
if self.count_call > 1:
67+
raise service_exception
68+
return orig_function(*args, **kwargs)
69+
70+
server = self._create_server(networks=[])
71+
self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])
72+
73+
with mock.patch(
74+
'nova.network.neutron.API.setup_networks_on_host',
75+
side_effect=fake_setup_networks_on_host
76+
):
77+
78+
# FIXME(Uggla) A failure with post_live_migration_at_destination
79+
# leave the instance in MIGRATING status and
80+
# migration_expected_state to completed because the exception
81+
# is not raised by the compute manager. This is mainly due to
82+
# the previous behavior that would not want to break, allowing a
83+
# migration cleanup. A recent patch allows better handling of post
84+
# migration errors, so we can now raise an exception in such cases.
85+
server = self._live_migrate(
86+
server, migration_expected_state='completed',
87+
server_expected_state='MIGRATING')
88+
89+
self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])

0 commit comments

Comments
 (0)