From 025318b82568ba93bd3c1f92727bf9d8624e42ab Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 30 Jun 2022 15:23:15 -0700 Subject: [PATCH] Fix race in test_aws_resource_cleanup If the test was slow enough that the image was not immediately deleted, we would fail the assertIsNone because image.state=='available'. Correct this by continuing to iterate in the wait loop while that's true. Change-Id: I6ee14c5737abe37d90d6b57442644085b08f30ab --- nodepool/tests/unit/test_driver_aws.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodepool/tests/unit/test_driver_aws.py b/nodepool/tests/unit/test_driver_aws.py index 209eb674f..71f08b16e 100644 --- a/nodepool/tests/unit/test_driver_aws.py +++ b/nodepool/tests/unit/test_driver_aws.py @@ -498,7 +498,9 @@ class TestDriverAws(tests.DBTestCase): image = self.ec2.Image(image_id) try: # If this has a value the image was not deleted - self.assertIsNone(image.state) + if image.state == 'available': + # Definitely not deleted yet + continue except AttributeError: # Per AWS API, a recently deleted image is empty and # looking at the state raises an AttributeFailure; see