|
| 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 | +from nova.tests import fixtures as nova_fixtures |
| 14 | +from nova.tests.functional.api import client |
| 15 | +from nova.tests.functional import integrated_helpers |
| 16 | + |
| 17 | + |
| 18 | +class ComputeVersion6xPinnedRpcTests(integrated_helpers._IntegratedTestBase): |
| 19 | + |
| 20 | + compute_driver = 'fake.MediumFakeDriver' |
| 21 | + ADMIN_API = True |
| 22 | + api_major_version = 'v2.1' |
| 23 | + microversion = 'latest' |
| 24 | + |
| 25 | + def setUp(self): |
| 26 | + super(ComputeVersion6xPinnedRpcTests, self).setUp() |
| 27 | + self.useFixture(nova_fixtures.CastAsCallFixture(self)) |
| 28 | + |
| 29 | + self.compute1 = self._start_compute(host='host1') |
| 30 | + |
| 31 | + def _test_rebuild_instance_with_compute_rpc_pin(self, version_cap): |
| 32 | + # Since passing the latest microversion (>= 2.93) passes |
| 33 | + # the 'reimage_boot_volume' parameter as True and it is |
| 34 | + # not acceptable with compute RPC version (required 6.1) |
| 35 | + # These tests fail, so assigning microversion to 2.92 |
| 36 | + self.api.microversion = '2.92' |
| 37 | + self.flags(compute=version_cap, group='upgrade_levels') |
| 38 | + |
| 39 | + server_req = self._build_server(networks='none') |
| 40 | + server = self.api.post_server({'server': server_req}) |
| 41 | + server = self._wait_for_state_change(server, 'ACTIVE') |
| 42 | + |
| 43 | + self.api.post_server_action(server['id'], {'rebuild': { |
| 44 | + 'imageRef': '155d900f-4e14-4e4c-a73d-069cbf4541e6' |
| 45 | + }}) |
| 46 | + |
| 47 | + # We automatically pin to 6.0 if old computes are Yoga or older. |
| 48 | + def test_rebuild_instance_6_0(self): |
| 49 | + e = self.assertRaises(client.OpenStackApiException, |
| 50 | + self._test_rebuild_instance_with_compute_rpc_pin, '6.0') |
| 51 | + self.assertEqual(500, e.response.status_code) |
| 52 | + # NOTE(sbauza): This returns a TypeError because of |
| 53 | + # 'reimage_boot_volume' and 'target_state' parameters missing from the |
| 54 | + # rcpapi caller. |
| 55 | + self.assertIn('TypeError', e.response.text) |
| 56 | + |
| 57 | + # We automatically pin to 6.1 if old computes are Zed. |
| 58 | + def test_rebuild_instance_6_1(self): |
| 59 | + self._test_rebuild_instance_with_compute_rpc_pin('6.1') |
| 60 | + |
| 61 | + # We automatically pin to 6.2 if old computes are 2023.1. |
| 62 | + def test_rebuild_instance_6_2(self): |
| 63 | + self._test_rebuild_instance_with_compute_rpc_pin('6.2') |
0 commit comments