summaryrefslogtreecommitdiff
path: root/nova/tests/functional
diff options
context:
space:
mode:
authorLee Yarwood <lyarwood@redhat.com>2021-03-31 12:23:23 +0100
committerLee Yarwood <lyarwood@redhat.com>2021-04-01 19:28:18 +0100
commitdb333070b61caef62ea5b68e5bf75f92d879db74 (patch)
treeabd6b9ece132f6ad0b2fe48dc77434f1beedfaac /nova/tests/functional
parent50fdbc752a9ca9c31488140ef2997ed59d861a41 (diff)
downloadnova-db333070b61caef62ea5b68e5bf75f92d879db74.tar.gz
Add regression test for bug #1922053
Related-Bug: #1922053 Change-Id: I7fa75a0d2e2555d99c3d2c16b333a21462837580
Diffstat (limited to 'nova/tests/functional')
-rw-r--r--nova/tests/functional/regressions/test_bug_1922053.py108
1 files changed, 108 insertions, 0 deletions
diff --git a/nova/tests/functional/regressions/test_bug_1922053.py b/nova/tests/functional/regressions/test_bug_1922053.py
new file mode 100644
index 0000000000..89cc16cacc
--- /dev/null
+++ b/nova/tests/functional/regressions/test_bug_1922053.py
@@ -0,0 +1,108 @@
+# 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.
+
+from nova.tests.functional import integrated_helpers
+
+
+class ForceUpWithDoneEvacuations(integrated_helpers._IntegratedTestBase):
+ """Regression test for bug 1922053.
+
+ This regression test aims to assert the behaviour of n-api when forcing a
+ compute service up when it is associated with evacuation migration
+ records still marked as `done`. This suggests that the compute service
+ was not correctly fenced when the evacuation was requested and has not
+ restarted since allowing the evacuation migration records to move to a
+ state of `completed`.
+ """
+
+ ADMIN_API = True
+ microversion = 'latest'
+
+ def _create_test_server(self, compute_host):
+ return self._create_server(host=compute_host, networks='none')
+
+ def _force_down_compute(self, hostname):
+ compute_id = self.api.get_services(
+ host=hostname, binary='nova-compute')[0]['id']
+ self.api.put_service(compute_id, {'forced_down': 'true'})
+
+ def _force_up_compute(self, hostname):
+ compute_id = self.api.get_services(
+ host=hostname, binary='nova-compute')[0]['id']
+ self.api.put_service(compute_id, {'forced_down': 'false'})
+
+ def test_force_up_with_done_evacuation_records(self):
+ # Launch a second compute to host the evacuated instance
+ self._start_compute('compute2')
+
+ # Create a test server to evacuate
+ server = self._create_test_server('compute')
+
+ # Assert we've landed on the first compute
+ self.assertEqual('compute', server['OS-EXT-SRV-ATTR:host'])
+
+ # Force down the first compute to allow the evacuation
+ self._force_down_compute('compute')
+
+ # Evacuate then assert the instance moves to compute2 and that the
+ # migration record is moved to done
+ server = self._evacuate_server(
+ server,
+ expected_host='compute2',
+ expected_migration_status='done'
+ )
+
+ # FIXME(lyarwood): This is bug #1922053, this shouldn't be allowed with
+ # `done` evacuation migration records still associated with the host.
+ # Replace this with the following assertion once fixed:
+ # ex = self.assertRaises(
+ # client.OpenStackApiException,
+ # self._force_up_compute,
+ # 'compute',
+ # )
+ # self.assertEqual(400, ex.response.status_code)
+ self._force_up_compute('compute')
+
+ # Assert that the evacuation migration record remains `done`
+ self._wait_for_migration_status(server, ["done"])
+
+ # Restart the source compute to move the migration record along
+ self.computes['compute'].stop()
+ self.computes['compute'].start()
+
+ # Assert that the evacuation migration record is now `completed`
+ self._wait_for_migration_status(server, ["completed"])
+
+
+class ForceUpWithDoneEvacuationsv252(ForceUpWithDoneEvacuations):
+
+ """Regression test for bug 1922053 using microversion 2.52.
+
+ Required as the PUT /os-services/force-down API used by this test via
+ self.api.force_down_service is superseeded by PUT /os-services/{service_id}
+ API used by our parent ForceUpWithDoneEvacuations class from >=2.53.
+
+ This test also uses the 'availability_zone' parameter to force the server
+ to spawn on the first compute as 'host' is only available from 2.74.
+ """
+
+ microversion = '2.52'
+
+ def _create_test_server(self, compute_host):
+ return self._create_server(az='nova:compute', networks='none')
+
+ def _force_down_compute(self, hostname):
+ self.api.force_down_service(hostname, 'nova-compute', forced_down=True)
+
+ def _force_up_compute(self, hostname):
+ self.api.force_down_service(
+ hostname, 'nova-compute', forced_down=False)