From 0c3063a89a60ceb446d005dfc220dcf79629e6d4 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Sat, 20 Jul 2024 09:10:23 -0700 Subject: [PATCH] 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 --- nodepool/tests/unit/test_driver_aws.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nodepool/tests/unit/test_driver_aws.py b/nodepool/tests/unit/test_driver_aws.py index b2ed241a1..a48853839 100644 --- a/nodepool/tests/unit/test_driver_aws.py +++ b/nodepool/tests/unit/test_driver_aws.py @@ -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