Skip to content

Commit a40c7f3

Browse files
committed
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
1 parent e25d590 commit a40c7f3

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 six
14+
15+
from nova import test
16+
from nova.tests import fixtures as nova_fixtures
17+
from nova.tests.functional.api import client as api_client
18+
from nova.tests.functional import fixtures as func_fixtures
19+
from nova.tests.functional import integrated_helpers
20+
from nova.tests.unit.image import fake as fake_image
21+
22+
23+
class VolumeBackedResizeDiskDown(test.TestCase,
24+
integrated_helpers.InstanceHelperMixin):
25+
"""Regression test for bug 1825020 introduced in Stein.
26+
27+
This tests a resize scenario where a volume-backed server is resized
28+
to a flavor with a smaller disk than the flavor used to create the
29+
server. Since the server is volume-backed, the disk in the new flavor
30+
should not matter since it won't be used for the guest.
31+
"""
32+
33+
def setUp(self):
34+
super(VolumeBackedResizeDiskDown, self).setUp()
35+
self.flags(allow_resize_to_same_host=True)
36+
37+
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
38+
api_version='v2.1'))
39+
self.api = api_fixture.admin_api
40+
41+
self.useFixture(nova_fixtures.NeutronFixture(self))
42+
self.useFixture(nova_fixtures.CinderFixtureNewAttachFlow(self))
43+
self.useFixture(func_fixtures.PlacementFixture())
44+
fake_image.stub_out_image_service(self)
45+
self.addCleanup(fake_image.FakeImageService_reset)
46+
47+
self.start_service('conductor')
48+
self.start_service('scheduler')
49+
self.start_service('compute')
50+
51+
def test_volume_backed_resize_disk_down(self):
52+
# First determine the flavors we're going to use by picking two flavors
53+
# with different size disks and create a volume-backed server using the
54+
# flavor with the bigger disk size.
55+
flavors = self.api.get_flavors()
56+
flavor1 = flavors[0]
57+
flavor2 = flavors[1]
58+
self.assertGreater(flavor2['disk'], flavor1['disk'])
59+
60+
vol_id = nova_fixtures.CinderFixtureNewAttachFlow.IMAGE_BACKED_VOL
61+
server = {
62+
'name': 'test_volume_backed_resize_disk_down',
63+
'imageRef': '',
64+
'flavorRef': flavor2['id'],
65+
'block_device_mapping_v2': [{
66+
'source_type': 'volume',
67+
'destination_type': 'volume',
68+
'boot_index': 0,
69+
'uuid': vol_id
70+
}]
71+
}
72+
server = self.api.post_server({'server': server})
73+
self._wait_for_state_change(self.api, server, 'ACTIVE')
74+
75+
# Now try to resize the server with the flavor that has smaller disk.
76+
data = {'resize': {'flavorRef': flavor1['id']}}
77+
# FIXME(mriedem): This will raise FlavorDiskSmallerThanMinDisk as a 500
78+
# error until bug 1825020 is fixed.
79+
ex = self.assertRaises(api_client.OpenStackApiException,
80+
self.api.post_server_action, server['id'], data)
81+
self.assertEqual(500, ex.response.status_code)
82+
self.assertIn('FlavorDiskSmallerThanMinDisk', six.text_type(ex))

0 commit comments

Comments
 (0)