Add functional test for deleting BFV server with old attach flow
When creating a new instance and deleting it before it gets scheduled
with the old attachment flow (reserve_volume), the block device mappings
are not persisted to database which means that the clean up fails
because it tries to lookup attachment_id which cannot be lazy loaded.
This patch adds a (failing) functional test to check for this issue
which will be addressed in a follow-up patch.
Related-Bug: #1750666
Change-Id: I294c54e5a22dd6e5b226a4b00e7cd116813f0704
(cherry picked from commit 3120627d98
)
This commit is contained in:
parent
c1b3d8c214
commit
9b59abc044
|
@ -10,6 +10,9 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from nova.compute import api as compute_api
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests import fixtures as nova_fixtures
|
from nova.tests import fixtures as nova_fixtures
|
||||||
from nova.tests.functional import integrated_helpers
|
from nova.tests.functional import integrated_helpers
|
||||||
|
@ -240,7 +243,45 @@ class ServersPreSchedulingTestCase(test.TestCase,
|
||||||
list_resp = list_resp.body['servers']
|
list_resp = list_resp.body['servers']
|
||||||
self.assertEqual(0, len(list_resp))
|
self.assertEqual(0, len(list_resp))
|
||||||
|
|
||||||
def test_boot_from_volume_delete_build_request_pre_scheduling(self):
|
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
|
||||||
|
return_value=compute_api.BFV_RESERVE_MIN_COMPUTE_VERSION)
|
||||||
|
def test_bfv_delete_build_request_pre_scheduling_ocata(self, mock_get):
|
||||||
|
cinder = self.useFixture(nova_fixtures.CinderFixture(self))
|
||||||
|
|
||||||
|
volume_id = nova_fixtures.CinderFixture.IMAGE_BACKED_VOL
|
||||||
|
server = self.api.post_server({
|
||||||
|
'server': {
|
||||||
|
'flavorRef': '1',
|
||||||
|
'name': 'test_bfv_delete_build_request_pre_scheduling',
|
||||||
|
'networks': 'none',
|
||||||
|
'block_device_mapping_v2': [
|
||||||
|
{
|
||||||
|
'boot_index': 0,
|
||||||
|
'uuid': volume_id,
|
||||||
|
'source_type': 'volume',
|
||||||
|
'destination_type': 'volume'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
# Since _IntegratedTestBase uses the CastAsCall fixture, when we
|
||||||
|
# get the server back we know all of the volume stuff should be done.
|
||||||
|
self.assertIn(volume_id, cinder.reserved_volumes)
|
||||||
|
|
||||||
|
# Now delete the server, which should go through the "local delete"
|
||||||
|
# code in the API, find the build request and delete it along with
|
||||||
|
# detaching the volume from the instance.
|
||||||
|
self.api.delete_server(server['id'])
|
||||||
|
|
||||||
|
# The volume should no longer have any attachments as instance delete
|
||||||
|
# should have removed them.
|
||||||
|
# self.assertNotIn(volume_id, cinder.reserved_volumes)
|
||||||
|
# FIXME(mnaser): This is part of bug 1750666 where the BDMs aren't
|
||||||
|
# properly deleted because they don't exist in the database.
|
||||||
|
self.assertIn(volume_id, cinder.reserved_volumes)
|
||||||
|
|
||||||
|
def test_bfv_delete_build_request_pre_scheduling(self):
|
||||||
cinder = self.useFixture(
|
cinder = self.useFixture(
|
||||||
nova_fixtures.CinderFixtureNewAttachFlow(self))
|
nova_fixtures.CinderFixtureNewAttachFlow(self))
|
||||||
# This makes the get_minimum_version_all_cells check say we're running
|
# This makes the get_minimum_version_all_cells check say we're running
|
||||||
|
|
Loading…
Reference in New Issue