AWS tests: cleanup image deletion checking

This is a follow-on to I3279c3b5cb8cf26d390835fd0a7049bc43ec40b5

As discussed in the referenced issue, the blank return and
AttributeError here is the correct way to determine a recently deleted
image.  We don't need to catch the ClientError as that won't be raised
any more.  Getting a value for the state would indicate it wasn't
deleted.

This bumps the moto base requirement to ensure we have this behaviour.

Change-Id: I2d5b0ccb9802aa0d4c81555a17f40fe8b8595ebd
This commit is contained in:
Ian Wienand 2022-04-28 14:09:13 +10:00
parent 8ffd70776a
commit e1461659de
2 changed files with 7 additions and 14 deletions

View File

@ -487,20 +487,13 @@ class TestDriverAws(tests.DBTestCase):
for _ in iterate_timeout(30, Exception, 'ami deletion'):
image = self.ec2.Image(image_id)
try:
if image.state == 'deleted':
break
except botocore.exceptions.ClientError:
# Probably not found
break
# If this has a value the image was not deleted
self.assertIsNone(image.state)
except AttributeError:
# NOTE(ianw) 2022-04-27 For reasons that are unclear
# but have been filed as
# https://github.com/spulec/moto/issues/5067
# accessing the image.state property of a deleted image
# with moto 1.3.6 will no longer result in the ClientError
# above, but boto will get blank response and try to
# dereference a None value. Thus catching this is a
# work-around until we have a better solution.
# Per AWS API, a recently deleted image is empty and
# looking at the state raises an AttributeFailure; see
# https://github.com/boto/boto3/issues/2531. The image
# was deleted, so we continue on here
break
for _ in iterate_timeout(30, Exception, 'snapshot deletion'):

View File

@ -6,5 +6,5 @@ python-subunit
stestr>=1.0.0 # Apache-2.0
testscenarios
testtools>=0.9.27
moto
moto>=3.1.6
responses>=0.12.1