Fixes disk resize negative test

If the configured flavor has a disk size of 1 GB, the negative
resize test will fail, because the nova API does not allow
resizing disks to 0 GB.

This patch will instead create a bigger flavor, and resize to the
vanilla one.

Change-Id: I733dab539a3b97a16d0dd14a9bc294c1446c5131
This commit is contained in:
Claudiu Belu 2017-08-31 09:50:55 -07:00
parent fb57b6104e
commit 6e1bb25132
2 changed files with 30 additions and 10 deletions

View File

@ -85,24 +85,32 @@ class _ResizeMixin(_ResizeUtils):
_BIGGER_FLAVOR = {}
_BAD_FLAVOR = {}
def _check_resize(self, resize_flavor_id, original_flavor_id=None,
expected_fail=False):
original_flavor_id = original_flavor_id or self._get_flavor_ref()
server_tuple = self._create_server(original_flavor_id)
if expected_fail:
self.assertRaises(exceptions.ResizeException,
self._resize_server,
server_tuple, resize_flavor_id)
else:
self._resize_server(server_tuple, resize_flavor_id)
# assert that the server is still reachable, even if the resize
# failed.
self._check_server_connectivity(server_tuple)
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
def test_resize(self):
new_flavor = self._create_new_flavor(self._get_flavor_ref(),
self._BIGGER_FLAVOR)
server_tuple = self._create_server()
self._resize_server(server_tuple, new_flavor['id'])
self._check_server_connectivity(server_tuple)
self._check_resize(new_flavor['id'])
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
def test_resize_negative(self):
new_flavor = self._create_new_flavor(self._get_flavor_ref(),
self._BAD_FLAVOR)
server_tuple = self._create_server()
self.assertRaises(exceptions.ResizeException, self._resize_server,
server_tuple, new_flavor['id'])
# assert that the server is still reachable, even if the resize
# failed.
self._check_server_connectivity(server_tuple)
self._check_resize(new_flavor['id'], expected_fail=True)

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import testtools
from oswin_tempest_plugin import config
from oswin_tempest_plugin.tests._mixins import migrate
from oswin_tempest_plugin.tests._mixins import resize
@ -48,6 +50,16 @@ class _BaseDiskTestMixin(migrate._MigrateMixin,
server_tuple = self._create_server()
self._check_server_connectivity(server_tuple)
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
def test_resize_negative(self):
# NOTE(claudiub): This test will try to downsize a VM's disk, which is
# unsupported. The configured flavor might have disk set to 1GB.
# The nova-api does not allow disks to be resized on 0 GB.
flavor = self._get_flavor_ref()
new_flavor = self._create_new_flavor(flavor, self._BIGGER_FLAVOR)
self._check_resize(flavor, new_flavor['id'], expected_fail=True)
class VhdDiskTest(test_base.TestBase, _BaseDiskTestMixin):