IMPALA-9209: Fix flakiness in test_end_data_stream_error

TestRPCException.execute_test_query is a helper function that is used
by tests that set an RPC debug action to repeatedly run a query until
the debug action is hit.

Previously, it required that either the query is expected to always
succeed, or it must always fail if the debug action is hit and an
expected error is provided. However, the two tests that have an
expected error, test_end_data_stream_error and
test_transmit_data_error, both set two debug actions - one that will
cause a query failure and one that won't (because we always retry
'reject too busy' errors).

If only the debug action that doesn't cause query failure is hit, the
query won't fail and 'execute_test_query' will fail on the assert that
expects that the query must fail if the action was hit. This is rare,
as both debug actions have a high probability of being hit on a given
run of the query.

The solution is to remove the requirement from the tests that the
query must fail if an expected error is provided and the debug action
is hit.

Change-Id: I499955b2d61c6b806f78e124c7ab919b242921bc
Reviewed-by: Impala Public Jenkins <>
Tested-by: Impala Public Jenkins <>
diff --git a/tests/custom_cluster/ b/tests/custom_cluster/
index 07310b4..495305b 100644
--- a/tests/custom_cluster/
+++ b/tests/custom_cluster/
@@ -58,8 +58,8 @@
   # Execute TEST_QUERY repeatedly until the FAIL debug action has been hit. If
   # 'exception_string' is None, it's expected to always complete sucessfully with result
-  # matching EXPECTED_RESULT. Otherwise, it's expected to fail with 'exception_string' if
-  # the debug action has been hit.
+  # matching EXPECTED_RESULT. Otherwise, it's expected to either succeed or fail with
+  # the error 'exception_string'.
   def execute_test_query(self, exception_string):
     impalad = self.cluster.impalads[2]
     assert impalad.service.krpc_port == self.KRPC_PORT
@@ -71,13 +71,12 @@
       i += 1
         result = self.client.execute(self.TEST_QUERY)
-        assert == self.EXPECTED_RESULT
-        assert not exception_string or self._get_num_fails(impalad) == 0
+        assert == self.EXPECTED_RESULT, "Query returned unexpected results."
       except ImpalaBeeswaxException as e:
         if exception_string is None:
           raise e
-        assert exception_string in str(e)
-    assert self._get_num_fails(impalad) > 0
+        assert exception_string in str(e), "Query failed with unexpected exception."
+    assert self._get_num_fails(impalad) > 0, "Debug action wasn't hit after 10 iters."
   def _get_fail_action(rpc, error=None, port=KRPC_PORT, p=0.1):
     """Returns a debug action that causes rpcs with the name 'rpc' that are sent to the