summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Zoeller <mzoeller@de.ibm.com>2016-06-30 11:12:02 +0200
committerMarkus Zoeller (markus_z) <mzoeller@linux.vnet.ibm.com>2016-09-14 14:00:52 +0000
commit845adc652862a72c4c46f516ed02c4e05af358d9 (patch)
tree856c40b13f00abb4927858d08c6e25d55b7cbc98
parentdaf4cc6b242f14d5fac8c351c24c561deb7f51e9 (diff)
Add functional regression test for bug 1595962
If the graphical consoles VNC and SPICE are disabled, the live-migration of an instance will result in an ERROR state. VNC and SPICE are usually disabled on IBM z systems platforms where graphical consoles are not available. The serial console is then enabled and VNC + SPICE are disabled. The logged error message will be: "Migration error: Your libvirt version does not support the VIR_DOMAIN_XML_MIGRATABLE flag or your destination node does not support retrieving listen addresses. In order for live migration to work properly you must either disable serial console or upgrade your libvirt version." This functional test executes the live migration flow with enabled serial console and disabled VNC + SPICE and reproduces bug 1595962. Related-Bug: 1595962 Change-Id: Ib1b22ce77d8a36e55944acc1fbca042906aa41ef
Notes
Notes (review): Code-Review+1: Pawel Koniszewski <pawel.koniszewski@intel.com> Code-Review+2: Andrew Laski <andrew@lascii.com> Verified+1: Intel NFV CI <openstack-nfv-ci@intel.com> Code-Review+2: Sylvain Bauza <sbauza@redhat.com> Workflow+1: Sylvain Bauza <sbauza@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 27 Sep 2016 16:47:28 +0000 Reviewed-on: https://review.openstack.org/338416 Project: openstack/nova Branch: refs/heads/master
-rw-r--r--nova/tests/functional/regressions/test_bug_1595962.py147
1 files changed, 147 insertions, 0 deletions
diff --git a/nova/tests/functional/regressions/test_bug_1595962.py b/nova/tests/functional/regressions/test_bug_1595962.py
new file mode 100644
index 0000000..0dd7b5f
--- /dev/null
+++ b/nova/tests/functional/regressions/test_bug_1595962.py
@@ -0,0 +1,147 @@
1# Copyright 2016 IBM Corp.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import fixtures
16import mock
17import time
18
19import nova.conf
20from nova import test
21from nova.tests import fixtures as nova_fixtures
22from nova.tests.unit import cast_as_call
23from nova.tests.unit import policy_fixture
24from nova.tests.unit.virt.libvirt import fake_libvirt_utils
25from nova.tests.unit.virt.libvirt import fakelibvirt
26from nova.virt.libvirt import guest as libvirt_guest
27
28
29CONF = nova.conf.CONF
30
31
32class TestSerialConsoleLiveMigrate(test.TestCase):
33 REQUIRES_LOCKING = True
34
35 def setUp(self):
36 super(TestSerialConsoleLiveMigrate, self).setUp()
37 self.useFixture(policy_fixture.RealPolicyFixture())
38 api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
39 api_version='v2.1'))
40 # Replace libvirt with fakelibvirt
41 self.useFixture(fixtures.MonkeyPatch(
42 'nova.virt.libvirt.driver.libvirt_utils',
43 fake_libvirt_utils))
44 self.useFixture(fixtures.MonkeyPatch(
45 'nova.virt.libvirt.driver.libvirt',
46 fakelibvirt))
47 self.useFixture(fixtures.MonkeyPatch(
48 'nova.virt.libvirt.host.libvirt',
49 fakelibvirt))
50 self.useFixture(fixtures.MonkeyPatch(
51 'nova.virt.libvirt.guest.libvirt',
52 fakelibvirt))
53 self.useFixture(fakelibvirt.FakeLibvirtFixture())
54
55 self.admin_api = api_fixture.admin_api
56 self.api = api_fixture.api
57
58 # the image fake backend needed for image discovery
59 nova.tests.unit.image.fake.stub_out_image_service(self)
60 nova.tests.unit.fake_network.set_stub_network_methods(self)
61
62 self.flags(compute_driver='libvirt.LibvirtDriver')
63 self.flags(enabled=True, group="serial_console")
64 self.flags(enabled=False, group="vnc")
65 self.flags(enabled=False, group="spice")
66 self.flags(use_usb_tablet=False, group="libvirt")
67 self.flags(host="test_compute1")
68
69 self.start_service('conductor', manager=CONF.conductor.manager)
70 self.flags(scheduler_driver='chance_scheduler')
71 self.start_service('scheduler')
72 self.network = self.start_service('network')
73 self.compute = self.start_service('compute', host='test_compute1')
74 self.consoleauth = self.start_service('consoleauth')
75
76 self.useFixture(cast_as_call.CastAsCall(self.stubs))
77 self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)
78
79 self.image_id = self.api.get_images()[0]['id']
80 self.flavor_id = self.api.get_flavors()[0]['id']
81
82 @mock.patch('nova.virt.libvirt.LibvirtDriver.get_volume_connector')
83 @mock.patch('nova.virt.libvirt.guest.Guest.get_job_info')
84 @mock.patch.object(fakelibvirt.Domain, 'migrateToURI2')
85 @mock.patch('nova.virt.libvirt.host.Host.get_connection')
86 @mock.patch('nova.virt.disk.api.get_disk_size', return_value=1024)
87 @mock.patch('os.path.getsize', return_value=1024)
88 @mock.patch('nova.conductor.tasks.live_migrate.LiveMigrationTask.'
89 '_check_destination_is_not_source', return_value=False)
90 @mock.patch('nova.virt.libvirt.LibvirtDriver._create_image')
91 def test_serial_console_live_migrate(self, mock_create_image,
92 mock_conductor_source_check,
93 mock_path_get_size,
94 mock_get_disk_size,
95 mock_host_get_connection,
96 mock_migrate_to_uri,
97 mock_get_job_info,
98 mock_get_volume_connector):
99 """Regression test for bug #1595962.
100
101 If the graphical consoles VNC and SPICE are disabled, the
102 live-migration of an instance will result in an ERROR state.
103 VNC and SPICE are usually disabled on IBM z systems platforms
104 where graphical consoles are not available. The serial console
105 is then enabled and VNC + SPICE are disabled.
106
107 The error will be raised at
108 https://github.com/openstack/nova/blob/
109 4f33047d07f5a11b208c344fe206aba01cd8e6fe/
110 nova/virt/libvirt/driver.py#L5842-L5852
111 """
112 mock_get_job_info.return_value = libvirt_guest.JobInfo(
113 type=fakelibvirt.VIR_DOMAIN_JOB_COMPLETED)
114 fake_connection = fakelibvirt.Connection('qemu:///system',
115 version=1002007,
116 hv_version=2001000)
117 mock_host_get_connection.return_value = fake_connection
118
119 server_attr = dict(name='server1',
120 imageRef=self.image_id,
121 flavorRef=self.flavor_id)
122 server = self.api.post_server({'server': server_attr})
123 server_id = server['id']
124 self.wait_till_active_or_timeout(server_id)
125
126 post = {"os-migrateLive": {
127 "block_migration": False,
128 "disk_over_commit": False,
129 "host": "test_compute1"
130 }}
131
132 try:
133 # This should succeed
134 self.admin_api.post_server_action(server_id, post)
135 self.wait_till_active_or_timeout(server_id)
136 except Exception as ex:
137 self.fail(ex.response.content)
138
139 def wait_till_active_or_timeout(self, server_id):
140 timeout = 0.0
141 server = self.api.get_server(server_id)
142 while server['status'] != "ACTIVE" and timeout < 10.0:
143 time.sleep(.1)
144 timeout += .1
145 server = self.api.get_server(server_id)
146 if server['status'] != "ACTIVE":
147 self.fail("The server is not active after the timeout.")