[
https://issues.apache.org/jira/browse/DRILL-6415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16495505#comment-16495505
]
ASF GitHub Bot commented on DRILL-6415:
---------------------------------------
parthchandra closed pull request #1281: DRILL-6415: Fixed
TestGracefulShutdown.TestRestApi test from timing out
URL: https://github.com/apache/drill/pull/1281
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
b/exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
index ccd65e41fe..bec1691078 100644
---
a/exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
+++
b/exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
@@ -20,7 +20,6 @@
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.server.Drillbit;
-import org.apache.drill.exec.work.WorkManager;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -28,15 +27,14 @@
import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
+import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.Collection;
-import java.util.Properties;
import java.nio.file.Path;
-import java.io.BufferedWriter;
+import java.util.Collection;
import static org.junit.Assert.fail;
@@ -44,9 +42,7 @@
public class TestGracefulShutdown extends BaseTestQuery {
@Rule
- public final TestRule TIMEOUT = TestTools.getTimeoutRule(180_000);
-
- public static final int WAIT_TIMEOUT_MS = WorkManager.EXIT_TIMEOUT_MS +
30_000;
+ public final TestRule TIMEOUT = TestTools.getTimeoutRule(120_000);
@BeforeClass
public static void setUpTestData() throws Exception {
@@ -55,37 +51,17 @@ public static void setUpTestData() throws Exception {
}
}
- public static final Properties WEBSERVER_CONFIGURATION = new Properties() {
- {
- put(ExecConstants.HTTP_ENABLE, true);
- put(ExecConstants.HTTP_PORT_HUNT, true);
- put(ExecConstants.DRILL_PORT_HUNT, true);
- put(ExecConstants.GRACE_PERIOD, 10000);
- put(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING, true);
- }
- };
-
- public static final Properties DRILL_PORT_CONFIGURATION = new Properties() {
- {
- put(ExecConstants.DRILL_PORT_HUNT, true);
- put(ExecConstants.GRACE_PERIOD, 10000);
- put(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING, true);
- }
- };
-
- public ClusterFixtureBuilder enableWebServer(ClusterFixtureBuilder builder) {
- Properties props = new Properties();
- props.putAll(WEBSERVER_CONFIGURATION);
- builder.configBuilder.configProps(props);
+ private static void enableWebServer(ClusterFixtureBuilder builder) {
+ enableDrillPortHunting(builder);
+ builder.configBuilder.put(ExecConstants.HTTP_ENABLE, true);
+ builder.configBuilder.put(ExecConstants.HTTP_PORT_HUNT, true);
builder.sessionOption(ExecConstants.SLICE_TARGET, 10);
- return builder;
}
- public ClusterFixtureBuilder enableDrillPortHunting(ClusterFixtureBuilder
builder) {
- Properties props = new Properties();
- props.putAll(DRILL_PORT_CONFIGURATION);
- builder.configBuilder.configProps(props);
- return builder;
+ private static void enableDrillPortHunting(ClusterFixtureBuilder builder) {
+ builder.configBuilder.put(ExecConstants.DRILL_PORT_HUNT, true);
+ builder.configBuilder.put(ExecConstants.GRACE_PERIOD, 500);
+ builder.configBuilder.put(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING,
true);
}
/*
@@ -95,98 +71,30 @@ public ClusterFixtureBuilder
enableDrillPortHunting(ClusterFixtureBuilder builde
@Test
public void testOnlineEndPoints() throws Exception {
- String[] drillbits = {"db1" ,"db2","db3", "db4", "db5", "db6"};
+ String[] drillbits = {"db1" ,"db2","db3"};
ClusterFixtureBuilder builder =
ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
enableDrillPortHunting(builder);
try ( ClusterFixture cluster = builder.build()) {
Drillbit drillbit = cluster.drillbit("db2");
+ int zkRefresh =
drillbit.getContext().getConfig().getInt(ExecConstants.ZK_REFRESH);
DrillbitEndpoint drillbitEndpoint =
drillbit.getRegistrationHandle().getEndPoint();
- int grace_period =
drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
-
- new Thread(new Runnable() {
- public void run() {
- try {
- cluster.closeDrillbit("db2");
- } catch (Exception e) {
- fail();
- }
- }
- }).start();
-
- Thread.sleep(grace_period);
+ cluster.closeDrillbit("db2");
- long currentTime = System.currentTimeMillis();
- long stopTime = currentTime + WAIT_TIMEOUT_MS;
-
- while (currentTime < stopTime) {
+ while (true) {
Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit()
- .getContext()
- .getClusterCoordinator()
- .getOnlineEndPoints();
+ .getContext()
+ .getClusterCoordinator()
+ .getOnlineEndPoints();
if (!drillbitEndpoints.contains(drillbitEndpoint)) {
// Success
return;
}
- Thread.sleep(100L);
- currentTime = System.currentTimeMillis();
- }
-
- Assert.fail("Timed out");
- }
- }
- /*
- Test if the drillbit transitions from ONLINE state when a shutdown
- request is initiated
- */
- @Test
- public void testStateChange() throws Exception {
-
- String[] drillbits = {"db1" ,"db2", "db3", "db4", "db5", "db6"};
- ClusterFixtureBuilder builder =
ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
- enableDrillPortHunting(builder);
-
- try (ClusterFixture cluster = builder.build()) {
- Drillbit drillbit = cluster.drillbit("db2");
- int grace_period =
drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
- DrillbitEndpoint drillbitEndpoint =
drillbit.getRegistrationHandle().getEndPoint();
- new Thread(new Runnable() {
- public void run() {
- try {
- cluster.closeDrillbit("db2");
- } catch (Exception e) {
- fail();
- }
- }
- }).start();
-
- Thread.sleep(grace_period);
-
- long currentTime = System.currentTimeMillis();
- long stopTime = currentTime + WAIT_TIMEOUT_MS;
-
- while (currentTime < stopTime) {
- Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit()
- .getContext()
- .getClusterCoordinator()
- .getAvailableEndpoints();
- for (DrillbitEndpoint dbEndpoint : drillbitEndpoints) {
- if (drillbitEndpoint.getAddress().equals(dbEndpoint.getAddress()) &&
drillbitEndpoint.getUserPort() == dbEndpoint.getUserPort()) {
- if (!dbEndpoint.getState().equals(DrillbitEndpoint.State.ONLINE)) {
- // Success
- return;
- }
- }
- }
-
- Thread.sleep(100L);
- currentTime = System.currentTimeMillis();
+ Thread.sleep(zkRefresh);
}
-
- Assert.fail("Timed out");
}
}
@@ -196,48 +104,35 @@ public void run() {
@Test
public void testRestApi() throws Exception {
- String[] drillbits = { "db1" ,"db2", "db3" };
+ String[] drillbits = {"db1", "db2", "db3"};
ClusterFixtureBuilder builder =
ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
- builder = enableWebServer(builder);
+ enableWebServer(builder);
QueryBuilder.QuerySummaryFuture listener;
final String sql = "select * from dfs.root.`.`";
- try ( ClusterFixture cluster = builder.build();
- final ClientFixture client = cluster.clientFixture()) {
+ try (ClusterFixture cluster = builder.build();
+ final ClientFixture client = cluster.clientFixture()) {
Drillbit drillbit = cluster.drillbit("db1");
- int port =
drillbit.getContext().getConfig().getInt("drill.exec.http.port");
- int grace_period =
drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
- listener = client.queryBuilder().sql(sql).futureSummary();
- Thread.sleep(60000);
- while( port < 8049) {
- URL url = new URL("http://localhost:"+port+"/gracefulShutdown");
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- if (conn.getResponseCode() != 200) {
- throw new RuntimeException("Failed : HTTP error code : "
- + conn.getResponseCode());
- }
- port++;
+ int port = drillbit.getWebServerPort();
+ int zkRefresh =
drillbit.getContext().getConfig().getInt(ExecConstants.ZK_REFRESH);
+ listener = client.queryBuilder().sql(sql).futureSummary();
+ URL url = new URL("http://localhost:" + port + "/gracefulShutdown");
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("POST");
+ if (conn.getResponseCode() != 200) {
+ throw new RuntimeException("Failed : HTTP error code : "
+ + conn.getResponseCode());
}
- Thread.sleep(grace_period);
- Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit()
- .getContext()
- .getClusterCoordinator()
- .getOnlineEndPoints();
-
- long currentTime = System.currentTimeMillis();
- long stopTime = currentTime + WAIT_TIMEOUT_MS;
-
- while (currentTime < stopTime) {
+ while (true) {
if (listener.isDone()) {
break;
}
-
Thread.sleep(100L);
- currentTime = System.currentTimeMillis();
}
- Assert.assertTrue(listener.isDone());
- Assert.assertEquals(1,drillbitEndpoints.size());
+ if (waitAndAssertDrillbitCount(cluster, zkRefresh)) {
+ return;
+ }
+ Assert.fail("Timed out");
}
}
@@ -249,48 +144,48 @@ public void testRestApiShutdown() throws Exception {
String[] drillbits = {"db1" ,"db2", "db3"};
ClusterFixtureBuilder builder =
ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
- builder = enableWebServer(builder);
+ enableWebServer(builder);
QueryBuilder.QuerySummaryFuture listener;
final String sql = "select * from dfs.root.`.`";
- try ( ClusterFixture cluster = builder.build();
- final ClientFixture client = cluster.clientFixture()) {
+ try (ClusterFixture cluster = builder.build();
+ final ClientFixture client = cluster.clientFixture()) {
Drillbit drillbit = cluster.drillbit("db1");
- int port =
drillbit.getContext().getConfig().getInt("drill.exec.http.port");
- int grace_period =
drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
+ int port = drillbit.getWebServerPort();
+ int zkRefresh =
drillbit.getContext().getConfig().getInt(ExecConstants.ZK_REFRESH);
listener = client.queryBuilder().sql(sql).futureSummary();
- Thread.sleep(10000);
-
- while( port < 8048) {
- URL url = new URL("http://localhost:"+port+"/shutdown");
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- if (conn.getResponseCode() != 200) {
- throw new RuntimeException("Failed : HTTP error code : "
- + conn.getResponseCode());
+ while (true) {
+ if (listener.isDone()) {
+ break;
}
- port++;
+
+ Thread.sleep(100L);
}
+ URL url = new URL("http://localhost:" + port + "/shutdown");
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("POST");
+ if (conn.getResponseCode() != 200) {
+ throw new RuntimeException("Failed : HTTP error code : "
+ + conn.getResponseCode());
+ }
+ if (waitAndAssertDrillbitCount(cluster, zkRefresh)) {
+ return;
+ }
+ Assert.fail("Timed out");
+ }
+ }
- Thread.sleep(grace_period);
+ private static boolean waitAndAssertDrillbitCount(ClusterFixture cluster,
int zkRefresh) throws InterruptedException {
+ while (true) {
Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit()
.getContext()
.getClusterCoordinator()
.getAvailableEndpoints();
-
- long currentTime = System.currentTimeMillis();
- long stopTime = currentTime + WAIT_TIMEOUT_MS;
-
- while (currentTime < stopTime) {
- if (listener.isDone() && drillbitEndpoints.size() == 2) {
- return;
- }
-
- Thread.sleep(100L);
- currentTime = System.currentTimeMillis();
+ if (drillbitEndpoints.size() == 2) {
+ return true;
}
- Assert.fail("Timed out");
+ Thread.sleep(zkRefresh);
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Unit test TestGracefulShutdown.testRestApiShutdown times out
> ------------------------------------------------------------
>
> Key: DRILL-6415
> URL: https://issues.apache.org/jira/browse/DRILL-6415
> Project: Apache Drill
> Issue Type: Bug
> Components: Tools, Build & Test
> Reporter: Abhishek Girish
> Assignee: Venkata Jyothsna Donapati
> Priority: Major
> Labels: ready-to-commit
> Fix For: 1.14.0
>
>
> {code}
> 16:03:40.415 [main] ERROR org.apache.drill.TestReporter - Test Failed (d:
> -18.3 KiB(72.9 KiB), h: -335.3 MiB(1.3 GiB), nh: 1.1 MiB(335.9 MiB)):
> testRestApiShutdown(org.apache.drill.test.TestGracefulShutdown)
> org.junit.runners.model.TestTimedOutException: test timed out after 180000
> milliseconds
> at sun.misc.Unsafe.park(Native Method) ~[na:1.8.0_161]
> at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
> ~[na:1.8.0_161]
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitUninterruptibly(AbstractQueuedSynchronizer.java:1976)
> ~[na:1.8.0_161]
> at
> org.apache.drill.exec.work.WorkManager.waitToExit(WorkManager.java:203)
> ~[classes/:na]
> at org.apache.drill.exec.server.Drillbit.close(Drillbit.java:242)
> ~[classes/:na]
> at
> org.apache.drill.test.ClusterFixture.safeClose(ClusterFixture.java:454)
> ~[test-classes/:1.14.0-SNAPSHOT]
> at org.apache.drill.test.ClusterFixture.close(ClusterFixture.java:405)
> ~[test-classes/:1.14.0-SNAPSHOT]
> at
> org.apache.drill.test.TestGracefulShutdown.testRestApiShutdown(TestGracefulShutdown.java:294)
> ~[test-classes/:1.14.0-SNAPSHOT]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> ~[na:1.8.0_161]
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> ~[na:1.8.0_161]
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> ~[na:1.8.0_161]
> at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> ~[junit-4.12.jar:4.12]
> at
> mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.executeTestMethod(JUnit4TestRunnerDecorator.java:154)
> ~[jmockit-1.39.jar:1.39]
> at
> mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.invokeExplosively(JUnit4TestRunnerDecorator.java:70)
> ~[jmockit-1.39.jar:1.39]
> at
> mockit.integration.junit4.internal.FakeFrameworkMethod.invokeExplosively(FakeFrameworkMethod.java:34)
> ~[jmockit-1.39.jar:1.39]
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
> ~[junit-4.12.jar:4.12]
> at
> org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
> ~[junit-4.12.jar:4.12]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> ~[na:1.8.0_161]
> at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_161]
> {code}
> {code}
> testRestApiShutdown(org.apache.drill.test.TestGracefulShutdown) Time
> elapsed: 180.028 sec <<< ERROR!
> org.junit.runners.model.TestTimedOutException: test timed out after 180000
> milliseconds
> at sun.misc.Unsafe.park(Native Method)
> at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitUninterruptibly(AbstractQueuedSynchronizer.java:1976)
> at
> org.apache.drill.exec.work.WorkManager.waitToExit(WorkManager.java:203)
> at org.apache.drill.exec.server.Drillbit.close(Drillbit.java:242)
> at
> org.apache.drill.test.ClusterFixture.safeClose(ClusterFixture.java:454)
> at org.apache.drill.test.ClusterFixture.close(ClusterFixture.java:405)
> at
> org.apache.drill.test.TestGracefulShutdown.testRestApiShutdown(TestGracefulShutdown.java:294)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)