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'): for _ in iterate_timeout(30, Exception, 'ami deletion'):
image = self.ec2.Image(image_id) image = self.ec2.Image(image_id)
try: try:
if image.state == 'deleted': # If this has a value the image was not deleted
break self.assertIsNone(image.state)
except botocore.exceptions.ClientError:
# Probably not found
break
except AttributeError: except AttributeError:
# NOTE(ianw) 2022-04-27 For reasons that are unclear # Per AWS API, a recently deleted image is empty and
# but have been filed as # looking at the state raises an AttributeFailure; see
# https://github.com/spulec/moto/issues/5067 # https://github.com/boto/boto3/issues/2531. The image
# accessing the image.state property of a deleted image # was deleted, so we continue on here
# 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.
break break
for _ in iterate_timeout(30, Exception, 'snapshot deletion'): for _ in iterate_timeout(30, Exception, 'snapshot deletion'):

View File

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