This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 90d32eae92bae1a108aade6980ffd6acd10e262d
Author: Zoltan Borok-Nagy <[email protected]>
AuthorDate: Wed Jul 16 18:46:23 2025 +0200

    IMPALA-14231: Stop HMS when Iceberg REST Catalog tests are running
    
    This patch stops the Hive Metastore until the Iceberg REST Catalog
    tests are running. It is needed to verify that Impala is functioning
    without the presence of HMS.
    
    Testing
     * custom cluster tests and ranger tests updated
    
    Change-Id: I52577501b730e186bd9ee963543796132e42d97b
    Reviewed-on: http://gerrit.cloudera.org:8080/23183
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 tests/authorization/test_ranger.py                | 62 ++++++++++++++++-------
 tests/custom_cluster/test_iceberg_rest_catalog.py | 58 +++++++++++++++------
 2 files changed, 86 insertions(+), 34 deletions(-)

diff --git a/tests/authorization/test_ranger.py 
b/tests/authorization/test_ranger.py
index 6e9f7fc22..17ce48d4c 100644
--- a/tests/authorization/test_ranger.py
+++ b/tests/authorization/test_ranger.py
@@ -31,7 +31,7 @@ from builtins import map, range
 import pytest
 import requests
 
-from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.custom_cluster_test_suite import CustomClusterTestSuite, 
HIVE_CONF_DIR
 from tests.common.file_utils import copy_files_to_hdfs_dir
 from tests.common.iceberg_rest_server import IcebergRestServer
 from tests.common.skip import SkipIf, SkipIfFS, SkipIfHive2
@@ -3266,6 +3266,37 @@ class TestRangerIcebergRestCatalog(TestRanger):
   def default_test_protocol(cls):
       return HS2
 
+  @classmethod
+  def need_default_clients(cls):
+    """There will be no HMS, so we shouldn't create the Hive client."""
+    return False
+
+  @classmethod
+  def setup_class(cls):
+    super(TestRangerIcebergRestCatalog, cls).setup_class()
+    try:
+      cls.iceberg_rest_server = IcebergRestServer()
+      cls.iceberg_rest_server.start_rest_server(300)
+    except Exception as e:
+      cls.iceberg_rest_server.stop_rest_server(10)
+      raise e
+
+    try:
+      cls._stop_hive_service()
+    except Exception as e:
+      cls.cleanup_infra_services()
+      raise e
+
+  @classmethod
+  def teardown_class(cls):
+    cls.cleanup_infra_services()
+    super(TestRangerIcebergRestCatalog, cls).teardown_class()
+
+  @classmethod
+  def cleanup_infra_services(cls):
+    cls.iceberg_rest_server.stop_rest_server(10)
+    cls._start_hive_service(None)
+
   @classmethod
   def add_custom_cluster_constraints(cls):
     # Do not call the super() implementation because this class needs to relax 
the
@@ -3274,25 +3305,20 @@ class TestRangerIcebergRestCatalog(TestRanger):
       lambda v: v.get_value('table_format').file_format == 'parquet')
 
   def setup_method(self, method):
+    args = method.__dict__
+    if HIVE_CONF_DIR in args:
+      raise Exception("Cannot specify HIVE_CONF_DIR because the tests of this 
class are "
+          "running without Hive.")
     # Invoke start-impala-cluster.py with '--no_catalogd'
     start_args = "--no_catalogd"
-    if START_ARGS in method.__dict__:
-      start_args = method.__dict__[START_ARGS] + " " + start_args
-    method.__dict__[START_ARGS] = start_args
-
-    try:
-      self.iceberg_rest_server = IcebergRestServer()
-      self.iceberg_rest_server.start_rest_server(300)
-      super(TestRangerIcebergRestCatalog, self).setup_method(method)
-      self.admin_client = self.create_impala_client(user=ADMIN)
-    except Exception as e:
-      print(e)
-      self.iceberg_rest_server.stop_rest_server(10)
-      raise e
-
-  def teardown_method(self, method):
-    self.iceberg_rest_server.stop_rest_server(10)
-    super(TestRangerIcebergRestCatalog, self).teardown_method(method)
+    if START_ARGS in args:
+      start_args = args[START_ARGS] + " " + start_args
+    args[START_ARGS] = start_args
+
+    super(TestRangerIcebergRestCatalog, self).setup_method(method)
+    # At this point we can create the Impala clients that we will need.
+    self.create_impala_clients()
+    self.admin_client = self.create_impala_client(user=ADMIN)
 
   def _get_all_resource(self):
     return {
diff --git a/tests/custom_cluster/test_iceberg_rest_catalog.py 
b/tests/custom_cluster/test_iceberg_rest_catalog.py
index bf84623c7..26fa484aa 100644
--- a/tests/custom_cluster/test_iceberg_rest_catalog.py
+++ b/tests/custom_cluster/test_iceberg_rest_catalog.py
@@ -19,7 +19,7 @@ from __future__ import absolute_import, division, 
print_function
 import os
 import pytest
 
-from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.custom_cluster_test_suite import CustomClusterTestSuite, 
HIVE_CONF_DIR
 from tests.common.iceberg_rest_server import IcebergRestServer
 
 REST_SERVER_PORT = 9084
@@ -33,27 +33,53 @@ IMPALAD_ARGS = """--use_local_catalog=true 
--catalogd_deployed=false
 class TestIcebergRestCatalog(CustomClusterTestSuite):
   """Test suite for Iceberg REST Catalog."""
 
-  def setup_method(self, method):
-    # Invoke start-impala-cluster.py with '--no_catalogd'
-    start_args = "--no_catalogd"
-    if START_ARGS in method.__dict__:
-      start_args = method.__dict__[START_ARGS] + " " + start_args
-    method.__dict__[START_ARGS] = start_args
+  @classmethod
+  def need_default_clients(cls):
+    """There will be no HMS, so we shouldn't create the Hive client."""
+    return False
+
+  @classmethod
+  def setup_class(cls):
+    super(TestIcebergRestCatalog, cls).setup_class()
+    try:
+      cls.iceberg_rest_server = IcebergRestServer()
+      cls.iceberg_rest_server.start_rest_server(300)
+    except Exception as e:
+      cls.iceberg_rest_server.stop_rest_server(10)
+      raise e
 
     try:
-      self.iceberg_rest_server = IcebergRestServer()
-      self.iceberg_rest_server.start_rest_server(300)
-      super(TestIcebergRestCatalog, self).setup_method(method)
+      cls._stop_hive_service()
     except Exception as e:
-      self.iceberg_rest_server.stop_rest_server(10)
+      cls.cleanup_infra_services()
       raise e
 
-  def teardown_method(self, method):
-    self.iceberg_rest_server.stop_rest_server(10)
-    super(TestIcebergRestCatalog, self).teardown_method(method)
+  @classmethod
+  def teardown_class(cls):
+    cls.cleanup_infra_services()
+    return super(TestIcebergRestCatalog, cls).teardown_class()
+
+  @classmethod
+  def cleanup_infra_services(cls):
+    cls.iceberg_rest_server.stop_rest_server(10)
+    cls._start_hive_service(None)
+
+  def setup_method(self, method):
+    args = method.__dict__
+    if HIVE_CONF_DIR in args:
+      raise Exception("Cannot specify HIVE_CONF_DIR because the tests of this 
class are "
+          "running without Hive.")
+    # Invoke start-impala-cluster.py with '--no_catalogd'
+    start_args = "--no_catalogd"
+    if START_ARGS in args:
+      start_args = args[START_ARGS] + " " + start_args
+    args[START_ARGS] = start_args
+
+    super(TestIcebergRestCatalog, self).setup_method(method)
+    # At this point we can create the Impala clients that we will need.
+    self.create_impala_clients()
 
-  @CustomClusterTestSuite.with_args(
-     impalad_args=IMPALAD_ARGS)
+  @CustomClusterTestSuite.with_args(impalad_args=IMPALAD_ARGS)
   @pytest.mark.execute_serially
   def test_rest_catalog_basic(self, vector):
     self.run_test_case('QueryTest/iceberg-rest-catalog', vector, use_db="ice")

Reply via email to