Add functional regression recreate test for bug 1825020

Change I06fad233006c7bab14749a51ffa226c3801f951b in Stein
started validating extra specs on the new flavor during a
resize but didn't take into account some validation that
happens with disk size with the new flavor if the validation
code isn't told that the server is volume-backed. That results
in a 500 FlavorDiskSmallerThanMinDisk response from the API
if the new flavor has a smaller disk size than the current
flavor that the server is using, which shouldn't actually
matter for a volume-backed server.

This adds a functional regression test to recreate the bug.

Change-Id: I9e7e44727946705506d740896349ca1833cfddcd
Related-Bug: #1825020
(cherry picked from commit a40c7f3e8d)
This commit is contained in:
Matt Riedemann 2019-04-16 23:00:15 -04:00
parent dd17cfcaad
commit a1db4507ac
1 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,82 @@
# 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 six
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional.api import client as api_client
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit.image import fake as fake_image
class VolumeBackedResizeDiskDown(test.TestCase,
integrated_helpers.InstanceHelperMixin):
"""Regression test for bug 1825020 introduced in Stein.
This tests a resize scenario where a volume-backed server is resized
to a flavor with a smaller disk than the flavor used to create the
server. Since the server is volume-backed, the disk in the new flavor
should not matter since it won't be used for the guest.
"""
def setUp(self):
super(VolumeBackedResizeDiskDown, self).setUp()
self.flags(allow_resize_to_same_host=True)
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
api_version='v2.1'))
self.api = api_fixture.admin_api
self.useFixture(nova_fixtures.NeutronFixture(self))
self.useFixture(nova_fixtures.CinderFixtureNewAttachFlow(self))
self.useFixture(func_fixtures.PlacementFixture())
fake_image.stub_out_image_service(self)
self.addCleanup(fake_image.FakeImageService_reset)
self.start_service('conductor')
self.start_service('scheduler')
self.start_service('compute')
def test_volume_backed_resize_disk_down(self):
# First determine the flavors we're going to use by picking two flavors
# with different size disks and create a volume-backed server using the
# flavor with the bigger disk size.
flavors = self.api.get_flavors()
flavor1 = flavors[0]
flavor2 = flavors[1]
self.assertGreater(flavor2['disk'], flavor1['disk'])
vol_id = nova_fixtures.CinderFixtureNewAttachFlow.IMAGE_BACKED_VOL
server = {
'name': 'test_volume_backed_resize_disk_down',
'imageRef': '',
'flavorRef': flavor2['id'],
'block_device_mapping_v2': [{
'source_type': 'volume',
'destination_type': 'volume',
'boot_index': 0,
'uuid': vol_id
}]
}
server = self.api.post_server({'server': server})
self._wait_for_state_change(self.api, server, 'ACTIVE')
# Now try to resize the server with the flavor that has smaller disk.
data = {'resize': {'flavorRef': flavor1['id']}}
# FIXME(mriedem): This will raise FlavorDiskSmallerThanMinDisk as a 500
# error until bug 1825020 is fixed.
ex = self.assertRaises(api_client.OpenStackApiException,
self.api.post_server_action, server['id'], data)
self.assertEqual(500, ex.response.status_code)
self.assertIn('FlavorDiskSmallerThanMinDisk', six.text_type(ex))