Adds regression functional test for 1980720
Related-Bug: #1980720 Change-Id: I223995b5f8cb72cb47d04e969819efe4885dfc88
This commit is contained in:
parent
03d2715ed4
commit
50802572dc
21
nova/tests/fixtures/cinder.py
vendored
21
nova/tests/fixtures/cinder.py
vendored
@ -47,6 +47,13 @@ class CinderFixture(fixtures.Fixture):
|
|||||||
# This represents a bootable image-backed volume to test
|
# This represents a bootable image-backed volume to test
|
||||||
# boot-from-volume scenarios.
|
# boot-from-volume scenarios.
|
||||||
IMAGE_BACKED_VOL = '6ca404f3-d844-4169-bb96-bc792f37de98'
|
IMAGE_BACKED_VOL = '6ca404f3-d844-4169-bb96-bc792f37de98'
|
||||||
|
|
||||||
|
# This represents a bootable image-backed volume to test
|
||||||
|
# boot-from-volume scenarios with
|
||||||
|
# os_require_quiesce
|
||||||
|
# hw_qemu_guest_agent
|
||||||
|
IMAGE_BACKED_VOL_QUIESCE = '6ca404f3-d844-4169-bb96-bc792f37de26'
|
||||||
|
|
||||||
# This represents a bootable image-backed volume with required traits
|
# This represents a bootable image-backed volume with required traits
|
||||||
# as part of volume image metadata
|
# as part of volume image metadata
|
||||||
IMAGE_WITH_TRAITS_BACKED_VOL = '6194fc02-c60e-4a01-a8e5-600798208b5f'
|
IMAGE_WITH_TRAITS_BACKED_VOL = '6194fc02-c60e-4a01-a8e5-600798208b5f'
|
||||||
@ -157,6 +164,13 @@ class CinderFixture(fixtures.Fixture):
|
|||||||
'image_id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'
|
'image_id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if volume_id == self.IMAGE_BACKED_VOL_QUIESCE:
|
||||||
|
volume['bootable'] = True
|
||||||
|
volume['volume_image_metadata'] = {
|
||||||
|
"os_require_quiesce": "True",
|
||||||
|
"hw_qemu_guest_agent": "True"
|
||||||
|
}
|
||||||
|
|
||||||
if volume_id == self.IMAGE_WITH_TRAITS_BACKED_VOL:
|
if volume_id == self.IMAGE_WITH_TRAITS_BACKED_VOL:
|
||||||
volume['bootable'] = True
|
volume['bootable'] = True
|
||||||
volume['volume_image_metadata'] = {
|
volume['volume_image_metadata'] = {
|
||||||
@ -333,6 +347,10 @@ class CinderFixture(fixtures.Fixture):
|
|||||||
if 'reimage_reserved' not in kwargs:
|
if 'reimage_reserved' not in kwargs:
|
||||||
raise exception.InvalidInput('reimage_reserved not specified')
|
raise exception.InvalidInput('reimage_reserved not specified')
|
||||||
|
|
||||||
|
def fake_get_absolute_limits(_self, context):
|
||||||
|
limits = {'totalSnapshotsUsed': 0, 'maxTotalSnapshots': -1}
|
||||||
|
return limits
|
||||||
|
|
||||||
self.test.stub_out(
|
self.test.stub_out(
|
||||||
'nova.volume.cinder.API.attachment_create', fake_attachment_create)
|
'nova.volume.cinder.API.attachment_create', fake_attachment_create)
|
||||||
self.test.stub_out(
|
self.test.stub_out(
|
||||||
@ -375,6 +393,9 @@ class CinderFixture(fixtures.Fixture):
|
|||||||
self.test.stub_out(
|
self.test.stub_out(
|
||||||
'nova.volume.cinder.API.reimage_volume',
|
'nova.volume.cinder.API.reimage_volume',
|
||||||
fake_reimage_volume)
|
fake_reimage_volume)
|
||||||
|
self.test.stub_out(
|
||||||
|
'nova.volume.cinder.API.get_absolute_limits',
|
||||||
|
fake_get_absolute_limits)
|
||||||
|
|
||||||
def volume_ids_for_instance(self, instance_uuid):
|
def volume_ids_for_instance(self, instance_uuid):
|
||||||
for volume_id, attachments in self.volume_to_attachment.items():
|
for volume_id, attachments in self.volume_to_attachment.items():
|
||||||
|
@ -633,6 +633,13 @@ class InstanceHelperMixin:
|
|||||||
return self._wait_for_state_change(server, 'SHUTOFF')
|
return self._wait_for_state_change(server, 'SHUTOFF')
|
||||||
return server
|
return server
|
||||||
|
|
||||||
|
def _snapshot_server(self, server, snapshot_name):
|
||||||
|
"""Create server snapshot."""
|
||||||
|
self.api.post_server_action(
|
||||||
|
server['id'],
|
||||||
|
{'createImage': {'name': snapshot_name}}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PlacementHelperMixin:
|
class PlacementHelperMixin:
|
||||||
"""A helper mixin for interacting with placement."""
|
"""A helper mixin for interacting with placement."""
|
||||||
|
67
nova/tests/functional/regressions/test_bug_1980720.py
Normal file
67
nova/tests/functional/regressions/test_bug_1980720.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Copyright (C) 2022 Red Hat, Inc
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 import fixtures as nova_fixtures
|
||||||
|
from nova.tests.functional.api import client
|
||||||
|
from nova.tests.functional import integrated_helpers
|
||||||
|
from nova.tests.functional.libvirt import base
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
|
||||||
|
class LibvirtDriverTests(
|
||||||
|
base.ServersTestBase,
|
||||||
|
integrated_helpers.InstanceHelperMixin
|
||||||
|
):
|
||||||
|
api_major_version = 'v2.1'
|
||||||
|
microversion = 'latest'
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(LibvirtDriverTests, self).setUp()
|
||||||
|
self.cinder = self.useFixture(nova_fixtures.CinderFixture(self))
|
||||||
|
self.start_compute()
|
||||||
|
|
||||||
|
def _create_server_with_block_device(self):
|
||||||
|
server_request = self._build_server(
|
||||||
|
networks=[],
|
||||||
|
)
|
||||||
|
# removing imageRef is required as we want
|
||||||
|
# to boot from volume
|
||||||
|
server_request.pop('imageRef')
|
||||||
|
server_request['block_device_mapping_v2'] = [{
|
||||||
|
'boot_index': 0,
|
||||||
|
'source_type': 'volume',
|
||||||
|
'uuid': nova_fixtures.CinderFixture.IMAGE_BACKED_VOL_QUIESCE,
|
||||||
|
'destination_type': 'volume'}]
|
||||||
|
|
||||||
|
server = self.api.post_server({
|
||||||
|
'server': server_request,
|
||||||
|
})
|
||||||
|
self._wait_for_state_change(server, 'ACTIVE')
|
||||||
|
return server
|
||||||
|
|
||||||
|
def test_snapshot_quiesce_fail(self):
|
||||||
|
server = self._create_server_with_block_device()
|
||||||
|
with mock.patch.object(
|
||||||
|
nova_fixtures.libvirt.Domain, 'fsFreeze'
|
||||||
|
) as mock_obj:
|
||||||
|
ex = nova_fixtures.libvirt.libvirtError("Error")
|
||||||
|
|
||||||
|
mock_obj.side_effect = ex
|
||||||
|
excep = self.assertRaises(
|
||||||
|
client.OpenStackApiException,
|
||||||
|
self._snapshot_server, server, "snapshot-1"
|
||||||
|
)
|
||||||
|
self.assertEqual(500, excep.response.status_code)
|
Loading…
x
Reference in New Issue
Block a user