[PSM Interop] Fix the issue with URL Map test suite not cleaning up failed test client (#32877)

`tearDownClass` is not executed when `setUpClass` failed. In URL Map
test suite, this leads to a test client that failed to start not being
cleaned up.
This PR change the URL Map test suite to register a custom
`addClassCleanup` callback, instead of relying on the `tearDownClass`.
Unlike `tearDownClass`, cleanup callbacks are executed when the
`setUpClass` failed.

ref b/276761453
pull/32907/head
Larry Safran 2 years ago committed by GitHub
parent c515eba30b
commit 4cb69f4658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      tools/run_tests/xds_k8s_test_driver/framework/xds_url_map_testcase.py

@ -342,6 +342,10 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase):
GcpResourceManager().setup(cls.test_case_classes)
cls.started_test_cases.add(cls.__name__)
# Configure cleanup to run after all tests regardless of whether or not
# this setUpClass failed
cls.addClassCleanup(cls.cleanupAfterTests)
# Create the test case's own client runner with it's own namespace,
# enables concurrent running with other test cases.
cls.test_client_runner = GcpResourceManager().create_test_client_runner(
@ -357,7 +361,8 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase):
print_response=True)
@classmethod
def tearDownClass(cls):
def cleanupAfterTests(cls):
logging.info('----- Doing cleanup after %s -----', cls.__name__)
cls.test_client_runner.cleanup(force=True, force_namespace=True)
cls.finished_test_cases.add(cls.__name__)
if cls.finished_test_cases == cls.test_case_names:

Loading…
Cancel
Save