You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by st...@apache.org on 2017/10/18 21:17:11 UTC
hive git commit: HIVE-17789: Flaky test:
TestSessionManagerMetrics.testAbandonedSessionMetrics has timing related
problems (Andrew Sherman, reviewed by Sahil Takiar, Aihua Xu)
Repository: hive
Updated Branches:
refs/heads/master c129bb95d -> c6c374eb0
HIVE-17789: Flaky test: TestSessionManagerMetrics.testAbandonedSessionMetrics has timing related problems (Andrew Sherman, reviewed by Sahil Takiar, Aihua Xu)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/c6c374eb
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c6c374eb
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c6c374eb
Branch: refs/heads/master
Commit: c6c374eb09c28baa4d8fd9e5de30aa3554ef804e
Parents: c129bb9
Author: Andrew Sherman <as...@cloudera.com>
Authored: Wed Oct 18 14:16:07 2017 -0700
Committer: Sahil Takiar <st...@cloudera.com>
Committed: Wed Oct 18 14:16:59 2017 -0700
----------------------------------------------------------------------
.../cli/session/TestSessionManagerMetrics.java | 22 +++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/c6c374eb/service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java
----------------------------------------------------------------------
diff --git a/service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java b/service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java
index 5f418c7..646159f 100644
--- a/service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java
+++ b/service/src/test/org/apache/hive/service/cli/session/TestSessionManagerMetrics.java
@@ -25,6 +25,8 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
+import com.fasterxml.jackson.databind.JsonNode;
import org.apache.hadoop.hive.common.metrics.MetricsTestUtils;
import org.apache.hadoop.hive.common.metrics.common.MetricsConstant;
import org.apache.hadoop.hive.common.metrics.common.MetricsFactory;
@@ -32,7 +34,6 @@ import org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics;
import org.apache.hadoop.hive.common.metrics.metrics2.MetricsReporting;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.metadata.Hive;
-import org.apache.hadoop.util.Time;
import org.apache.hive.service.cli.FetchOrientation;
import org.apache.hive.service.cli.HiveSQLException;
import org.apache.hive.service.cli.OperationHandle;
@@ -373,9 +374,20 @@ public class TestSessionManagerMetrics {
sm.openSession(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V9, "user", "passw", "127.0.0.1",
new HashMap<String, String>());
- Thread.sleep(3200);
-
- json = metrics.dumpJson();
- MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.HS2_ABANDONED_SESSIONS, 1);
+ // We're going to wait for the session to be abandoned.
+ String currentValue;
+ int count = 5; // how many times we'll sleep before giving up
+ String expectedValue = "1";
+ do {
+ // HIVE_SERVER2_SESSION_CHECK_INTERVAL is set to 3 seconds, so we have to wait for at least
+ // that long to see an abandoned session
+ Thread.sleep(3200);
+ json = metrics.dumpJson();
+ currentValue = MetricsTestUtils
+ .getJsonNode(json, MetricsTestUtils.COUNTER, MetricsConstant.HS2_ABANDONED_SESSIONS)
+ .asText();
+ // loop until the value is correct or we run out of tries
+ } while (!expectedValue.equals(currentValue) && --count > 0);
+ Assert.assertEquals(expectedValue, currentValue);
}
}