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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3e495c441 IMPALA-14776 (part 1): Auto-close manually created impala 
clients
3e495c441 is described below

commit 3e495c44112bd0c01acd0bdf744c4cbdcd394e4e
Author: Joe McDonnell <[email protected]>
AuthorDate: Wed Feb 25 21:29:06 2026 -0800

    IMPALA-14776 (part 1): Auto-close manually created impala clients
    
    There are several APIs in ImpalaTestSuite that tests can use to
    create a new client:
     - create_impala_client()
     - create_impala_client_from_vector()
     - create_client_for_nth_impalad()
    If the tests don't close the client properly, pytest will report
    a leak of a socket. It seems possible that this type of leak can
    also result in leaving an unclosed session on the impalad. This can
    trigger TestValidateMetrics.test_metrics_are_zero(), which has
    been an issue since switching to pytest 6.2.5.
    
    This modifies those APIs to register the clients in a list and
    close them during test method teardown. That should prevent
    resource leaks (sockets, sessions) associated with these clients.
    The clients may have been cleaned up by other means (with-as or
    try-finally or a manual close), so it is heavily relying on
    close() being idempotent.
    
    The list is maintained at the instance level, and it is set in
    setup_method() and freed in teardown_method(). This means that
    test classes need to call ImpalaTestSuite::setup_method() and
    teardown_method(). This modifies several test classes to call
    these methods appropriately.
    
    This also means that the APIs are no longer class methods, so callers
    need to call them on their instance rather than on the class
    itself. This required changing a handful of locations.
    
    ImpalaTestSuite's built-in clients use an internal API so that
    they can be reused across test methods. They instead are scoped
    at the class level.
    
    Testing:
     - Ran an exhaustive job
    
    Change-Id: Ib550527838a81cd2aaf69bb715080f6ac6da3786
    Reviewed-on: http://gerrit.cloudera.org:8080/24026
    Reviewed-by: Joe McDonnell <[email protected]>
    Tested-by: Joe McDonnell <[email protected]>
    Reviewed-by: Csaba Ringhofer <[email protected]>
---
 tests/common/custom_cluster_test_suite.py          |   2 +
 tests/common/impala_test_suite.py                  | 132 +++++++++++++++------
 tests/conftest.py                                  |   4 +-
 tests/custom_cluster/test_blacklist.py             |  13 +-
 tests/custom_cluster/test_breakpad.py              |   9 +-
 .../custom_cluster/test_parquet_max_page_header.py |   1 +
 tests/custom_cluster/test_permanent_udfs.py        |   1 +
 tests/custom_cluster/test_query_retries.py         |  14 ++-
 tests/custom_cluster/test_redaction.py             |   8 +-
 tests/custom_cluster/test_scratch_disk.py          |  15 ++-
 tests/metadata/test_hdfs_encryption.py             |   2 +
 tests/metadata/test_hdfs_permissions.py            |   2 +
 tests/metadata/test_load.py                        |   4 +
 tests/query_test/test_compressed_formats.py        |   1 +
 tests/query_test/test_insert_permutation.py        |   1 +
 tests/stress/test_acid_stress.py                   |   8 +-
 tests/stress/test_update_stress.py                 |   4 +-
 17 files changed, 164 insertions(+), 57 deletions(-)

diff --git a/tests/common/custom_cluster_test_suite.py 
b/tests/common/custom_cluster_test_suite.py
index 155a9f169..d3a96ef46 100644
--- a/tests/common/custom_cluster_test_suite.py
+++ b/tests/common/custom_cluster_test_suite.py
@@ -409,6 +409,7 @@ class CustomClusterTestSuite(ImpalaTestSuite):
           raise e
 
   def setup_method(self, method):
+    super().setup_method(method)
     if not self.SHARED_CLUSTER_ARGS:
       # Store the test method name so that we can put logs in different 
directories for
       # different tests. This only applies if the cluster is being restarted 
per test
@@ -445,6 +446,7 @@ class CustomClusterTestSuite(ImpalaTestSuite):
       super(CustomClusterTestSuite, cls).teardown_class()
 
   def teardown_method(self, method):
+    super().teardown_method(method)
     if not self.SHARED_CLUSTER_ARGS:
       self.cluster_teardown(method.__name__, method.__dict__)
     self.set_current_test_method_name(None)
diff --git a/tests/common/impala_test_suite.py 
b/tests/common/impala_test_suite.py
index c7b1d4808..5232e8e29 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -41,6 +41,7 @@ from getpass import getuser
 from impala.hiveserver2 import HiveServer2Cursor
 from random import choice
 from subprocess import check_call
+from threading import Lock
 import tests.common
 from tests.common.base_test_suite import BaseTestSuite
 from tests.common.environ import (
@@ -359,14 +360,34 @@ class ImpalaTestSuite(BaseTestSuite):
     cls.close_impala_clients()
 
   def setup_method(self, test_method):  # noqa: U100
-    """Setup for all test method."""
+    """
+    Setup for all test method. All classes inheriting from this class with a 
custom
+    setup_method() must call this ImpalaTestSuite::setup_method() either via 
their
+    super() or directly (same for teardown_method()).
+    """
+    # List of clients to be closed at the end of the test method. This avoids 
resource
+    # leaks of clients and sessions. This is protected by a lock to avoid 
concurrent
+    # modification
+    self.test_method_scoped_clients_lock = Lock()
+    self.test_method_scoped_clients = []
     self._reset_impala_clients()
 
   def teardown_method(self, test_method):  # noqa: U100
-    """Teardown for all test method.
-    Currently, it is only here as a placeholder for future use and complement
-    setup_method() declaration."""
-    pass
+    """
+    Teardown for all test methods. This closes all test scoped clients to avoid
+    socket/session leaks. All classes inheriting from this class with a custom
+    teardown_method() must call this ImpalaTestSuite::teardown_method() either 
via
+    their super() or directly (same for setup_method()).
+    """
+    # This is taking advantage of the fact that close() is idempotent. Many 
clients
+    # in this list have been closed by other means. Teardown is expected to be 
single
+    # threaded, as all threads used by tests should be cleaned up prior to 
this. So,
+    # it should not be necessary to take the lock and no thread is racing with 
this
+    # thread to close the client. Even so, taking the lock is harmless, so do 
it anyway.
+    with self.test_method_scoped_clients_lock:
+      for client in self.test_method_scoped_clients:
+        client.close()
+      self.test_method_scoped_clients = None
 
   @classmethod
   def need_default_clients(cls):
@@ -379,11 +400,17 @@ class ImpalaTestSuite(BaseTestSuite):
     return True
 
   @classmethod
-  def create_impala_client(cls, host_port=None, protocol=None, is_hive=False, 
user=None):
+  def create_impala_client_internal(cls, host_port=None, protocol=None, 
is_hive=False,
+      user=None):
     """
     Create a new ImpalaConnection client.
-    Make sure to always call this method using a with-as statement or manually 
close
-    the returned connection before discarding it."""
+    This method mostly should not be used directly outside of test 
infrastructure code.
+    Unlike other signatures, this is a classmethod and can be used from other
+    classmethod code.
+
+    It comes with no protection against leaking the client, so it must be used 
with
+    a with-as statement, a try-finally block, or manual logic to close the 
connection.
+    """
     if protocol is None:
       protocol = cls.default_test_protocol()
     if host_port is None:
@@ -397,14 +424,33 @@ class ImpalaTestSuite(BaseTestSuite):
     client.connect()
     return client
 
-  @classmethod
-  def create_impala_client_from_vector(cls, vector):
+  def create_impala_client(self, host_port=None, protocol=None, is_hive=False, 
user=None):
+    """
+    Create a new ImpalaConnection client. This client is registered at the 
class level
+    and will be cleaned up during test method teardown. This still works 
properly using
+    a with-as statement or with manual close statements."""
+    client = self.create_impala_client_internal(host_port=host_port, 
protocol=protocol,
+        is_hive=is_hive, user=user)
+    # If the appropriate fields haven't been set, then the caller hasn't called
+    # setup_method(). Give a clearer error.
+    if not hasattr(self, 'test_method_scoped_clients') or \
+       self.test_method_scoped_clients is None:
+      assert False, "ImpalaTestSuite::setup_method() has not been called. " \
+        "All test classes must call 
ImpalaTestSuite::setup_method()/teardown_method()."
+    # Register this client to be closed at test method teardown. Some tests 
use a
+    # threadpool that could be opening clients concurrently, so this takes a 
lock.
+    with self.test_method_scoped_clients_lock:
+      self.test_method_scoped_clients.append(client)
+    return client
+
+  def create_impala_client_from_vector(self, vector):
     """A shorthand for create_impala_client with test vector as input.
     Vector must have 'protocol' and 'exec_option' dimension.
     Return a client of specified 'protocol' and with cofiguration 
'exec_option' set.
-    Make sure to always call this method using a with-as statement or manually 
close
-    the returned connection before discarding it."""
-    client = cls.create_impala_client(protocol=vector.get_protocol())
+    This client is registered at the class level and will be cleaned up during 
test
+    method teardown. This still works properly using a with-as statement or 
with
+    manual close statements."""
+    client = self.create_impala_client(protocol=vector.get_protocol())
     client.set_configuration(vector.get_exec_option_dict())
     return client
 
@@ -412,11 +458,15 @@ class ImpalaTestSuite(BaseTestSuite):
   def get_impalad_cluster_size(cls):
     return len(cls.__get_cluster_host_ports(cls.default_test_protocol()))
 
-  @classmethod
-  def create_client_for_nth_impalad(cls, nth=0, protocol=None):
+  def create_client_for_nth_impalad(self, nth=0, protocol=None):
+    """
+    Create a new ImpalaConnection client for the specified impalad.
+    This client is registered at the class level and will be cleaned up during 
test
+    method teardown. This still works properly using a with-as statement or 
with
+    manual close statements."""
     if protocol is None:
-      protocol = cls.default_test_protocol()
-    host_ports = cls.__get_cluster_host_ports(protocol)
+      protocol = self.default_test_protocol()
+    host_ports = self.__get_cluster_host_ports(protocol)
     if nth < len(IMPALAD_HOST_PORT_LIST):
       host_port = host_ports[nth]
     else:
@@ -426,23 +476,38 @@ class ImpalaTestSuite(BaseTestSuite):
       host, port = host_port.split(':')
       port = str(int(port) + nth)
       host_port = host + ':' + port
-    return cls.create_impala_client(host_port, protocol=protocol)
+    return self.create_impala_client(host_port, protocol=protocol)
 
   @classmethod
   def create_impala_clients(cls):
     """Creates Impala clients for all supported protocols."""
-    # The default connection (self.client) is Beeswax so that existing tests, 
which assume
-    # Beeswax do not need modification (yet).
-    cls.beeswax_client = cls.create_impala_client(protocol=BEESWAX)
-    cls.hs2_client = None
+    # These built-in clients are scoped at the class level. They specifically
+    # use the create_impala_client_internal() API to allow the clients to
+    # be reused across multiple test methods. They are cleaned up in the class
+    # teardown method.
+
+    # If the beeswax client already exists, close it to avoid leaks
+    if cls.beeswax_client:
+      cls.beeswax_client.close()
+      cls.beeswax_client = None
+    cls.beeswax_client = cls.create_impala_client_internal(protocol=BEESWAX)
+
+    # If the HS2 client already exists, close it to avoid leaks
+    if cls.hs2_client:
+      cls.hs2_client.close()
+      cls.hs2_client = None
     try:
-      cls.hs2_client = cls.create_impala_client(protocol=HS2)
+      cls.hs2_client = cls.create_impala_client_internal(protocol=HS2)
     except Exception as e:
       # HS2 connection can fail for benign reasons, e.g. running with 
unsupported auth.
       LOG.info("HS2 connection setup failed, continuing...: {0}".format(e))
-    cls.hs2_http_client = None
+
+    # If the HS2-HTTP client already exists, close it to avoid leaks
+    if cls.hs2_http_client:
+      cls.hs2_http_client.close()
+      cls.hs2_http_client = None
     try:
-      cls.hs2_http_client = cls.create_impala_client(protocol=HS2_HTTP)
+      cls.hs2_http_client = 
cls.create_impala_client_internal(protocol=HS2_HTTP)
     except Exception as e:
       # HS2 HTTP connection can fail for benign reasons, e.g. running with 
unsupported
       # auth.
@@ -451,11 +516,13 @@ class ImpalaTestSuite(BaseTestSuite):
 
   @classmethod
   def _reset_impala_clients(cls):
-    if cls.beeswax_client:
+    # Reset the configuration for built-in clients. This tolerates when the 
fields are
+    # not set, as CustomClusterTestSuite can call this before the cluster 
starts up.
+    if hasattr(cls, 'beeswax_client') and cls.beeswax_client:
       cls.beeswax_client.clear_configuration()
-    if cls.hs2_client:
+    if hasattr(cls, 'hs2_client') and cls.hs2_client:
       cls.hs2_client.clear_configuration()
-    if cls.hs2_http_client:
+    if hasattr(cls, 'hs2_http_client') and cls.hs2_http_client:
       cls.hs2_http_client.clear_configuration()
 
   @classmethod
@@ -541,12 +608,11 @@ class ImpalaTestSuite(BaseTestSuite):
   @classmethod
   def cleanup_db(cls, db_name, sync_ddl=1):
     # Create a new client to avoid polluting query options of existing clients.
-    client = cls.create_impala_client()
-    client.set_configuration({'sync_ddl': sync_ddl})
-    try:
+    # This uses the internal API because this method is used in cleanup 
functions,
+    # and it should work even if teardown_method() has already run.
+    with cls.create_impala_client_internal() as client:
+      client.set_configuration({'sync_ddl': sync_ddl})
       client.execute("drop database if exists `" + db_name + "` cascade")
-    finally:
-      client.close()
 
   def __restore_query_options(self, query_options_changed, impalad_client):
     """
diff --git a/tests/conftest.py b/tests/conftest.py
index 383aeae4b..fa52e6bda 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -394,7 +394,7 @@ def unique_database(request, testid_checksum):
     request.instance.filesystem_client.delete_file_dir(db_location, 
recursive=True)
 
   def cleanup():
-    with request.cls.create_impala_client(protocol=HS2) as client:
+    with request.instance.create_impala_client(protocol=HS2) as client:
       client.set_configuration({'sync_ddl': sync_ddl})
       for db_name in db_names:
         cleanup_database(client, db_name, True)
@@ -403,7 +403,7 @@ def unique_database(request, testid_checksum):
 
   request.addfinalizer(cleanup)
 
-  with request.cls.create_impala_client(protocol=HS2) as client:
+  with request.instance.create_impala_client(protocol=HS2) as client:
     client.set_configuration({'sync_ddl': sync_ddl})
     for db_name in db_names:
       cleanup_database(client, db_name, False)
diff --git a/tests/custom_cluster/test_blacklist.py 
b/tests/custom_cluster/test_blacklist.py
index 945e47ea5..bdc007f01 100644
--- a/tests/custom_cluster/test_blacklist.py
+++ b/tests/custom_cluster/test_blacklist.py
@@ -18,6 +18,7 @@
 from __future__ import absolute_import, division, print_function
 from builtins import range
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.impala_test_suite import ImpalaTestSuite
 
 import pytest
 import re
@@ -226,13 +227,17 @@ class TestBlacklistFaultyDisk(CustomClusterTestSuite):
     return result
 
   def setup_method(self, method):  # noqa: U100
-    # Don't call the superclass method to prevent starting Impala before each 
test. In
-    # this class, each test is responsible for doing that because we want to 
generate
-    # the parameter string to start-impala-cluster in each test method.
-    pass
+    # Skip the call to CustomClusterTestSuite setup_method() to prevent 
starting Impala
+    # before each test. In this class, each test is responsible for doing that 
because
+    # we want to generate the parameter string to start-impala-cluster in each 
test
+    # method. However, we are required to call ImpalaTestSuite's 
setup_method() (and
+    # ImpalaTestSuite's teardown_method()).
+    ImpalaTestSuite.setup_method(self, method)
 
   def teardown_method(self, method):  # noqa: U100
     self.clear_tmp_dirs()
+    # See comment in setup_method()
+    ImpalaTestSuite.teardown_method(self, method)
 
   @SkipIfBuildType.not_dev_build
   @pytest.mark.execute_serially
diff --git a/tests/custom_cluster/test_breakpad.py 
b/tests/custom_cluster/test_breakpad.py
index 666f384bb..dbd8273a2 100644
--- a/tests/custom_cluster/test_breakpad.py
+++ b/tests/custom_cluster/test_breakpad.py
@@ -28,6 +28,7 @@ from signal import SIGSEGV, SIGKILL, SIGUSR1, SIGTERM
 from subprocess import CalledProcessError
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.impala_test_suite import ImpalaTestSuite
 
 DAEMONS = ['impalad', 'statestored', 'catalogd']
 DAEMON_ARGS = ['impalad_args', 'state_store_args', 'catalogd_args']
@@ -36,12 +37,18 @@ DAEMON_ARGS = ['impalad_args', 'state_store_args', 
'catalogd_args']
 class TestBreakpadBase(CustomClusterTestSuite):
   """Base class with utility methods for all breakpad tests."""
   def setup_method(self, method):
+    # Skip CustomClusterTestSuite's setup_method() as we start the cluster
+    # manually. This is still required to call ImpalaTestSuite's setup_method()
+    # (and teardown_method()).
+    ImpalaTestSuite.setup_method(self, method)
     # Override parent
     # The temporary directory gets removed in teardown_method() after each 
test.
     self.tmp_dir = self.make_tmp_dir('breakpad')
 
   def teardown_method(self, method):
-    # Override parent
+    # Skip CustomClusterTestSuite's teardown_method(), but this is required to
+    # call ImpalaTestSuite's teardown_method().
+    ImpalaTestSuite.teardown_method(self, method)
     # Stop the cluster to prevent future accesses to self.tmp_dir.
     self.kill_cluster(SIGKILL)
     assert len(self.TMP_DIRS) > 0
diff --git a/tests/custom_cluster/test_parquet_max_page_header.py 
b/tests/custom_cluster/test_parquet_max_page_header.py
index 026a44b45..4b97cdfae 100644
--- a/tests/custom_cluster/test_parquet_max_page_header.py
+++ b/tests/custom_cluster/test_parquet_max_page_header.py
@@ -60,6 +60,7 @@ class TestParquetMaxPageHeader(CustomClusterTestSuite):
     self.__create_test_tbls()
 
   def teardown_method(self, method):
+    super(TestParquetMaxPageHeader, self).teardown_method(method)
     self.__drop_test_tbls()
     self.close_impala_clients()
 
diff --git a/tests/custom_cluster/test_permanent_udfs.py 
b/tests/custom_cluster/test_permanent_udfs.py
index deebed844..9b117246a 100644
--- a/tests/custom_cluster/test_permanent_udfs.py
+++ b/tests/custom_cluster/test_permanent_udfs.py
@@ -79,6 +79,7 @@ class TestUdfPersistence(CustomClusterTestSuite):
     self.__cleanup()
     self.close_impala_clients()
     self.clear_tmp_dirs()
+    super(TestUdfPersistence, self).teardown_method(method)
 
   def __cleanup(self):
     self.client.execute("DROP DATABASE IF EXISTS %s CASCADE" % self.DATABASE)
diff --git a/tests/custom_cluster/test_query_retries.py 
b/tests/custom_cluster/test_query_retries.py
index 9880affd1..2755e43a4 100644
--- a/tests/custom_cluster/test_query_retries.py
+++ b/tests/custom_cluster/test_query_retries.py
@@ -1250,13 +1250,17 @@ class 
TestQueryRetriesFaultyDisk(CustomClusterTestSuite):
       order by o_orderdate
       """
 
-  def setup_method(self, method):  # noqa: U100
+  def setup_method(self, method):
     # Don't call the superclass method to prevent starting Impala before each 
test. In
     # this class, each test is responsible for doing that because we want to 
generate
-    # the parameter string to start-impala-cluster in each test method.
-    pass
-
-  def teardown_method(self, method):  # noqa: U100
+    # the parameter string to start-impala-cluster in each test method. This 
is still
+    # required to call the ImpalaTestSuite::setup_method() (and corresponding
+    # teardown_method()).
+    ImpalaTestSuite.setup_method(self, method)
+
+  def teardown_method(self, method):
+    # See comment in setup_method()
+    ImpalaTestSuite.teardown_method(self, method)
     self.clear_tmp_dirs()
 
   def __generate_scratch_dir(self, num):
diff --git a/tests/custom_cluster/test_redaction.py 
b/tests/custom_cluster/test_redaction.py
index 0ca333206..43773049e 100644
--- a/tests/custom_cluster/test_redaction.py
+++ b/tests/custom_cluster/test_redaction.py
@@ -27,6 +27,7 @@ from time import sleep
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.file_utils import grep_file, assert_file_in_dir_contains,\
     assert_no_files_in_dir_contain
+from tests.common.impala_test_suite import ImpalaTestSuite
 
 LOG = logging.getLogger(__name__)
 
@@ -60,12 +61,17 @@ class TestRedaction(CustomClusterTestSuite):
     return os.path.join(self.tmp_dir, "redaction_rules.json")
 
   def setup_method(self, method):
+    # Since this test starts the cluster itself, it doesn't want to use
+    # CustomClusterTestSuite's setup_method(). However, it is still required to
+    # call ImpalaTestSuite::setup_method() (and the corresponding 
teardown_method()).
+    ImpalaTestSuite.setup_method(self, method)
     # Override parent
     # The temporary directory gets removed in teardown_method() after each 
test.
     self.tmp_dir = self.make_tmp_dir('redaction')
 
   def teardown_method(self, method):
-    # Parent method would fail, nothing needs to be done.
+    # See comment in setup_method()
+    ImpalaTestSuite.teardown_method(self, method)
     # Cleanup any temporary dirs.
     self.clear_tmp_dirs()
 
diff --git a/tests/custom_cluster/test_scratch_disk.py 
b/tests/custom_cluster/test_scratch_disk.py
index 38d454227..5847de305 100644
--- a/tests/custom_cluster/test_scratch_disk.py
+++ b/tests/custom_cluster/test_scratch_disk.py
@@ -28,6 +28,7 @@ import subprocess
 import time
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIf
 from tests.util.hdfs_util import NAMENODE
 from tests.util.parse_util import bytes_to_str
@@ -87,13 +88,17 @@ class TestScratchDir(CustomClusterTestSuite):
         os.chmod(dir_path, stat.S_IREAD)
     return result
 
-  def setup_method(self, method):  # noqa: U100
+  def setup_method(self, method):
     # Don't call the superclass method to prevent starting Impala before each 
test. In
     # this file, each test is responsible for doing that because we want to 
generate
-    # the parameter string to start-impala-cluster in each test method.
-    pass
-
-  def teardown_method(self, method):  # noqa: U100
+    # the parameter string to start-impala-cluster in each test method. This 
is still
+    # required to call ImpalaTestSuite::setup_method() (and the corresponding
+    # teardown_method()).
+    ImpalaTestSuite.setup_method(self, method)
+
+  def teardown_method(self, method):
+    # See comment in setup_method()
+    ImpalaTestSuite.teardown_method(self, method)
     self.clear_tmp_dirs()
     self.check_deleted_file_fd()
 
diff --git a/tests/metadata/test_hdfs_encryption.py 
b/tests/metadata/test_hdfs_encryption.py
index 5ff1dd68b..1060c3340 100644
--- a/tests/metadata/test_hdfs_encryption.py
+++ b/tests/metadata/test_hdfs_encryption.py
@@ -71,6 +71,7 @@ class TestHdfsEncryption(ImpalaTestSuite):
         v.get_value('key_tbl_dir') is not None)
 
   def setup_method(self, method):
+    super().setup_method(method)
     self.__cleanup()
     self.client.execute('create database if not exists %s' % TEST_DB)
     self.client.execute('use %s' % TEST_DB)
@@ -89,6 +90,7 @@ class TestHdfsEncryption(ImpalaTestSuite):
     rc, stdout, stderr = exec_process(
             "hadoop fs -rmr /user/{0}/.Trash/".format(getpass.getuser()))
     assert rc == 0, 'Error deleting Trash: %s %s' % (stdout, stderr)
+    super().teardown_method(method)
 
   def create_encryption_zone(self, key, path):
     """Creates an encryption zone using key 'key' on path 'path'"""
diff --git a/tests/metadata/test_hdfs_permissions.py 
b/tests/metadata/test_hdfs_permissions.py
index 985cd55c9..59bf6c86e 100644
--- a/tests/metadata/test_hdfs_permissions.py
+++ b/tests/metadata/test_hdfs_permissions.py
@@ -39,9 +39,11 @@ class TestHdfsPermissions(ImpalaTestSuite):
         create_uncompressed_text_dimension(cls.get_workload()))
 
   def setup_method(self, method):
+    super().setup_method(method)
     self._cleanup()
 
   def teardown_method(self, method):
+    super().teardown_method(method)
     self._cleanup()
 
   def _cleanup(self):
diff --git a/tests/metadata/test_load.py b/tests/metadata/test_load.py
index 688e2d5ae..64d037f57 100644
--- a/tests/metadata/test_load.py
+++ b/tests/metadata/test_load.py
@@ -61,8 +61,10 @@ class TestLoadData(ImpalaTestSuite):
 
   def teardown_method(self, method):
     self._clean_test_tables()
+    super().teardown_method(method)
 
   def setup_method(self, method):
+    super().setup_method(method)
     # Defensively clean the data dirs if they exist.
     self._clean_test_tables()
 
@@ -125,8 +127,10 @@ class TestLoadDataExternal(ImpalaTestSuite):
 
   def teardown_method(self, method):
     self._clean_test_tables()
+    super().teardown_method(method)
 
   def setup_method(self, method):
+    super().setup_method(method)
     # Defensively clean the data dirs if they exist.
     self._clean_test_tables()
 
diff --git a/tests/query_test/test_compressed_formats.py 
b/tests/query_test/test_compressed_formats.py
index 3ef0cef15..6264dceb8 100644
--- a/tests/query_test/test_compressed_formats.py
+++ b/tests/query_test/test_compressed_formats.py
@@ -224,6 +224,7 @@ class TestLargeCompressedFile(ImpalaTestSuite):
 
   def teardown_method(self, method):
     self.__drop_test_table()
+    super(TestLargeCompressedFile, self).teardown_method(method)
 
   def __generate_file(self, file_name, file_size):
     """Generate file with random data and a specified size."""
diff --git a/tests/query_test/test_insert_permutation.py 
b/tests/query_test/test_insert_permutation.py
index b61c84856..6970bad35 100644
--- a/tests/query_test/test_insert_permutation.py
+++ b/tests/query_test/test_insert_permutation.py
@@ -49,3 +49,4 @@ class TestInsertQueriesWithPermutation(ImpalaTestSuite):
 
   def teardown_method(self, method):
     list(map(self.cleanup_db, ["insert_permutation_test"]))
+    super(TestInsertQueriesWithPermutation, self).teardown_method(method)
diff --git a/tests/stress/test_acid_stress.py b/tests/stress/test_acid_stress.py
index 1210ae512..892c8cc62 100644
--- a/tests/stress/test_acid_stress.py
+++ b/tests/stress/test_acid_stress.py
@@ -241,7 +241,7 @@ class TestConcurrentAcidInserts(TestAcidStress):
     """Writes ascending numbers into column 'i'. To column 'wid' it writes its 
identifier
     passed in parameter 'wid'. Occasionally it truncates the table."""
     target_impalad = wid % ImpalaTestSuite.get_impalad_cluster_size()
-    impalad_client = 
ImpalaTestSuite.create_client_for_nth_impalad(target_impalad)
+    impalad_client = self.create_client_for_nth_impalad(target_impalad)
     try:
       num_inserts = 0
       while num_inserts < 50:
@@ -269,7 +269,7 @@ class TestConcurrentAcidInserts(TestAcidStress):
           "wid: %d" % wid
 
     target_impalad = cid % ImpalaTestSuite.get_impalad_cluster_size()
-    impalad_client = 
ImpalaTestSuite.create_client_for_nth_impalad(target_impalad)
+    impalad_client = self.create_client_for_nth_impalad(target_impalad)
     try:
       while counter.value != writers:
         result = impalad_client.execute("select * from %s" % tbl_name)
@@ -322,7 +322,7 @@ class TestFailingAcidInserts(TestAcidStress):
     INSERTs with the value -1 must fail with a debug action.
     Occasionally it truncates the table."""
     FAIL_ACTION = "CLIENT_REQUEST_UPDATE_CATALOG:[email protected]"
-    impalad_client = 
ImpalaTestSuite.create_client_for_nth_impalad(target_impalad)
+    impalad_client = self.create_client_for_nth_impalad(target_impalad)
     try:
       num_inserts = 0
       while num_inserts < 50:
@@ -347,7 +347,7 @@ class TestFailingAcidInserts(TestAcidStress):
 
   def _impala_role_checker(self, tbl_name, target_impalad, counter, writers):
     """Checks that the table doesn't contain other values than 1."""
-    impalad_client = 
ImpalaTestSuite.create_client_for_nth_impalad(target_impalad)
+    impalad_client = self.create_client_for_nth_impalad(target_impalad)
     try:
       while counter.value != writers:
         result = impalad_client.execute("select * from %s where i != 1" % 
tbl_name)
diff --git a/tests/stress/test_update_stress.py 
b/tests/stress/test_update_stress.py
index 013cefc02..fd2568398 100644
--- a/tests/stress/test_update_stress.py
+++ b/tests/stress/test_update_stress.py
@@ -211,7 +211,7 @@ class TestIcebergConcurrentOperations(ImpalaTestSuite):
 
   def _hive_role_concurrent_writer(self, tbl_name, all_rows_deleted):
     """Increments j's value with each iteration until all rows are deleted"""
-    hive_client = ImpalaTestSuite.create_impala_client(
+    hive_client = self.create_impala_client(
       host_port=DEFAULT_HIVE_SERVER2, protocol='hs2', is_hive=True)
     while all_rows_deleted.value != 1:
       try:
@@ -224,7 +224,7 @@ class TestIcebergConcurrentOperations(ImpalaTestSuite):
     hive_client.close()
 
   def _hive_role_concurrent_deleter(self, tbl_name, all_rows_deleted, 
num_rows):
-    hive_client = ImpalaTestSuite.create_impala_client(
+    hive_client = self.create_impala_client(
       host_port=DEFAULT_HIVE_SERVER2, protocol='hs2', is_hive=True)
     i = 0
     while i < num_rows:

Reply via email to