Fix cleanup process in AWS tests

This moves the moto stop from a teardown to a cleanup.  This is
necessary so that we don't stop moto before we shut down the test
nodepool.  The current code mostly works, but exhibits problems in
tests with unusual shutdown timings.

Change-Id: Ia457389ae297317dfe2c120f83f9d93a024f4abc
This commit is contained in:
James E. Blair
2024-07-20 09:10:23 -07:00
parent 11eec917f7
commit 0c3063a89a

View File

@@ -160,6 +160,7 @@ class TestDriverAws(tests.DBTestCase):
self.fake_aws = FakeAws()
self.mock_aws.start()
self.addCleanup(self.mock_aws.stop)
self.ec2 = boto3.resource('ec2', region_name='us-west-2')
self.ec2_client = boto3.client('ec2', region_name='us-west-2')
@@ -212,10 +213,6 @@ class TestDriverAws(tests.DBTestCase):
self.patchAdapter(ec2_quotas=getattr(test, '__aws_ec2_quotas__', None),
ebs_quotas=getattr(test, '__aws_ebs_quotas__', None))
def tearDown(self):
self.mock_aws.stop()
super().tearDown()
def setup_config(self, *args, **kw):
kw['subnet_id'] = self.subnet_id
kw['security_group_id'] = self.security_group_id