Copilot commented on code in PR #12005:
URL: https://github.com/apache/gravitino/pull/12005#discussion_r3584074392
##########
clients/client-python/tests/integration/integration_test_env.py:
##########
@@ -239,3 +272,22 @@ def _reset_conf(cls, config, conf_path):
with open(conf_path, mode="w", encoding="utf-8") as file:
for line in filtered_lines:
file.write(line)
+
+
+class MetalakeTestMixin:
+ """Provide common metalake setup and cleanup for integration tests."""
+
+ def setUp(self): # pylint: disable=invalid-name
+ self.init_test_env()
+
+ def tearDown(self): # pylint: disable=invalid-name
+ self.clean_test_data()
+
Review Comment:
`MetalakeTestMixin` is intended to be used via multiple inheritance, but its
`setUp`/`tearDown` do not call `super()`. This can break cooperative
initialization/cleanup if `IntegrationTestEnv` (or another mixin) later adds
`setUp`/`tearDown`, and `tearDown` should ensure `super().tearDown()` runs even
if cleanup fails.
##########
clients/client-python/tests/integration/integration_test_env.py:
##########
@@ -149,6 +149,39 @@ def tearDownClass(cls):
if gravitino_server_running:
logger.error("Can't stop Gravitino server!")
+ @staticmethod
+ def create_gravitino_client(metalake_name: str) -> GravitinoClient:
+ return GravitinoClient(uri="http://localhost:8090",
metalake_name=metalake_name)
+
+ @staticmethod
+ def create_metalake_client(
+ admin_client: GravitinoAdminClient,
+ metalake_name: str,
+ comment: str = "",
+ ) -> GravitinoClient:
+ admin_client.create_metalake(metalake_name, comment=comment,
properties={})
+ return IntegrationTestEnv.create_gravitino_client(metalake_name)
+
Review Comment:
`create_metalake_client` is a `@staticmethod` but hard-codes
`IntegrationTestEnv.create_gravitino_client(...)`, which makes it harder to
override client creation behavior in subclasses (e.g., different URI) and
unnecessarily couples the helper to the base class name. Making it a
`@classmethod` and calling `cls.create_gravitino_client(...)` keeps the helper
extensible without changing call sites.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]