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

prozsa pushed a commit to branch branch-4.5.0
in repository https://gitbox.apache.org/repos/asf/impala.git

commit fb4c504d91b2e879a89d703090eeac37398de2e5
Author: jasonmfehr <jf...@cloudera.com>
AuthorDate: Wed Feb 5 08:35:05 2025 -0800

    IMPALA-13201: Remove Unused Parameter from Test retry Function
    
    The custom cluster tests utilize the retry() function defined in
    retry.py. This function takes as input another function to do the
    assertions. This assertion function used to have a single boolean
    parameter indicating if the retry was on its last attempt. In
    actuality, this boolean was not used and thus caused flake8 failures.
    
    This change removes this unused parameter from the assertion function
    passed in to the retry function.
    
    Change-Id: I1bce9417b603faea7233c70bde3816beed45539e
    Reviewed-on: http://gerrit.cloudera.org:8080/22452
    Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
 tests/common/custom_cluster_test_suite.py |  2 +-
 tests/common/impala_test_suite.py         |  4 +---
 tests/custom_cluster/test_query_live.py   |  2 +-
 tests/custom_cluster/test_query_log.py    |  8 ++------
 tests/util/retry.py                       | 12 +++++-------
 5 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/tests/common/custom_cluster_test_suite.py 
b/tests/common/custom_cluster_test_suite.py
index d0d3275b8..c7fd3774e 100644
--- a/tests/common/custom_cluster_test_suite.py
+++ b/tests/common/custom_cluster_test_suite.py
@@ -410,7 +410,7 @@ class CustomClusterTestSuite(ImpalaTestSuite):
     catalog_log = self.assert_catalogd_log_contains("INFO", r'A catalog update 
with \d+ '
         r'entries is assembled. Catalog version: (\d+)', timeout_s=10, 
expected_count=-1)
 
-    def assert_func(last_iteration):
+    def assert_func():
       coord_log = self.assert_impalad_log_contains("INFO", r'Catalog topic 
update '
           r'applied with version: (\d+)', timeout_s=5, expected_count=-1)
       return int(coord_log.group(1)) >= int(catalog_log.group(1))
diff --git a/tests/common/impala_test_suite.py 
b/tests/common/impala_test_suite.py
index 46c2a550c..e865a696e 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -1579,9 +1579,7 @@ class ImpalaTestSuite(BaseTestSuite):
     """
     actual_log_path = self.__build_log_path(daemon, level)
 
-    def exists_func(is_last_try):
-      if is_last_try:
-        LOG.info("Checking existence of {} for the last 
time.".format(actual_log_path))
+    def exists_func():
       return os.path.exists(actual_log_path)
 
     assert retry(exists_func, max_attempts, sleep_time_s, 1, True), "file '{}' 
did not " \
diff --git a/tests/custom_cluster/test_query_live.py 
b/tests/custom_cluster/test_query_live.py
index be16ea512..2427a6bf9 100644
--- a/tests/custom_cluster/test_query_live.py
+++ b/tests/custom_cluster/test_query_live.py
@@ -37,7 +37,7 @@ class TestQueryLive(CustomClusterTestSuite):
     self.wait_for_wm_init_complete()
 
     # Wait until sys.impala_query_live is available in the coordinator's 
catalog cache.
-    def table_exists(last_iteration):
+    def table_exists():
       catalog_objs = self.cluster.get_first_impalad() \
           .service.read_debug_webpage("catalog?json")
       return "impala_query_live" in catalog_objs
diff --git a/tests/custom_cluster/test_query_log.py 
b/tests/custom_cluster/test_query_log.py
index fb05709fc..1da399077 100644
--- a/tests/custom_cluster/test_query_log.py
+++ b/tests/custom_cluster/test_query_log.py
@@ -721,16 +721,12 @@ class TestQueryLogTableHS2(TestQueryLogTableBase):
     client2 = self.create_client_for_nth_impalad(1, 
vector.get_value('protocol'))
 
     try:
-      def assert_func(last_iteration):
+      def assert_func():
         results = client2.execute("select query_id,sql from {0} where query_id 
in "
                                   "('{1}','{2}','{3}')".format(self.QUERY_TBL,
                                   sql1.query_id, sql2.query_id, sql3.query_id))
 
-        success = len(results.data) == 3
-        if last_iteration:
-          assert len(results.data) == 3
-
-        return success
+        return len(results.data) == 3
 
       assert retry(func=assert_func, max_attempts=5, sleep_time_s=3)
     finally:
diff --git a/tests/util/retry.py b/tests/util/retry.py
index fb91c9ad4..33f3391a1 100644
--- a/tests/util/retry.py
+++ b/tests/util/retry.py
@@ -23,14 +23,12 @@ from time import sleep
 def retry(func, max_attempts=3, sleep_time_s=1, backoff=2, 
raise_immediately=False):
   """
   Repeatedly executes a provided function until the function either returns 
True or the
-  maximum number of iterations is it.
+  maximum number of iterations is reached.
 
   Inputs:
-    func             - A function to execute, this function must take a single 
boolean
-                       parameter which indicates if the current attempt is the 
last
-                       attempt, the purpose of this parameter is to enable 
assertions to
-                       run during the lastattempt so that better error 
messages a
-                       provided.
+    func              - A function to execute, this function must not take any 
parameters
+                        and must return a boolean True or False indicating if 
all
+                        assertions passed or failed.
     max_attempts      - The maximum number of times to run the function.
     sleep_time_s      - The number of seconds to sleep before retrying.
     backoff           - Defines the amount the the sleep time will be 
multiplied by after
@@ -67,7 +65,7 @@ def retry(func, max_attempts=3, sleep_time_s=1, backoff=2, 
raise_immediately=Fal
 
   while(iterations < max_attempts):
     try:
-      success = func(iterations == max_attempts - 1)
+      success = func()
 
       if success:
         return True

Reply via email to