Fix session expiration test.

The session expiration test would occasionally fail because two sessions ended up expiring
at approximately the same time. This patch ensures that no session is active when the
initial metric value is polled.

Change-Id: Ib62e7c23fb0c43e0e8ee0c17770d47df19964117
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4502
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: jenkins
This commit is contained in:
ishaan
2014-09-23 17:29:49 -07:00
committed by Nong Li
parent 3edeef53d8
commit 9103eb2a0a

View File

@@ -29,6 +29,12 @@ class TestSessionExpiration(CustomClusterTestSuite):
@CustomClusterTestSuite.with_args("--idle_session_timeout=6")
def test_session_expiration(self, vector):
impalad = self.cluster.get_any_impalad()
# setup_class creates an Impala client to <hostname>:21000 after the cluster starts.
# The client expires at the same time as the client created below. Since we choose the
# impalad to connect to randomly, the test becomes flaky, as the metric we expect to
# be incremented by 1 gets incremented by 2 if both clients are connected to the same
# Impalad.
self.client.close()
num_expired = impalad.service.get_metric_value("impala-server.num-sessions-expired")
client = impalad.service.create_beeswax_client()
# Sleep for half the expiration time to confirm that the session is not expired early
@@ -39,7 +45,6 @@ class TestSessionExpiration(CustomClusterTestSuite):
# Wait for session expiration. Session timeout was set for 6 seconds, so Impala
# will poll the session expiry queue every 3 seconds. So, as long as the sleep in
# ImpalaSever::ExpireSessions() is not late, the session will expire in at most 9
# seconds. The test has already waited 3 seconds. Wait another 20 seconds so we
# have plenty of slop in case the Impala sleep occasionally wakes late.
# seconds. The test has already waited 3 seconds.
impalad.service.wait_for_metric_value(
"impala-server.num-sessions-expired", num_expired + 1, 20)