You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2018/12/31 09:55:23 UTC

[GitHub] vvysotskyi commented on a change in pull request #1589: DRILL-6936: TestGracefulShutdown.gracefulShutdownThreadShouldBeInitia…

vvysotskyi commented on a change in pull request #1589: DRILL-6936: TestGracefulShutdown.gracefulShutdownThreadShouldBeInitia…
URL: https://github.com/apache/drill/pull/1589#discussion_r244568907
 
 

 ##########
 File path: exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
 ##########
 @@ -179,40 +180,28 @@ public void testRestApiShutdown() throws Exception {
   }
 
   @Test // DRILL-6912
-  public void gracefulShutdownThreadShouldBeInitializedBeforeClosingDrillbit() throws Exception {
-    Drillbit drillbit = null;
-    Drillbit drillbitWithSamePort = null;
-
-    int userPort = QueryTestUtil.getFreePortNumber(31170, 300);
-    int bitPort = QueryTestUtil.getFreePortNumber(31180, 300);
+  public void testDrillbitWithSamePortContainsShutdownThread() throws Exception {
     ClusterFixtureBuilder fixtureBuilder = ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk()
-        .configProperty(ExecConstants.INITIAL_USER_PORT, userPort)
-        .configProperty(ExecConstants.INITIAL_BIT_PORT, bitPort);
-    try (ClusterFixture clusterFixture = fixtureBuilder.build()) {
-      drillbit = clusterFixture.drillbit();
-
-      // creating another drillbit instance using same config
-      drillbitWithSamePort = new Drillbit(clusterFixture.config(), fixtureBuilder.configBuilder().getDefinitions(),
-          clusterFixture.serviceSet());
-
+        .configProperty(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING, true)
+        .configProperty(ExecConstants.INITIAL_USER_PORT, QueryTestUtil.getFreePortNumber(31170, 300))
+        .configProperty(ExecConstants.INITIAL_BIT_PORT, QueryTestUtil.getFreePortNumber(31180, 300));
+
+    try (ClusterFixture fixture = fixtureBuilder.build();
+         Drillbit drillbitWithSamePort = new Drillbit(fixture.config(),
+             fixtureBuilder.configBuilder().getDefinitions(), fixture.serviceSet())) {
+      // Assert preconditions :
+      //      1. First drillbit instance should be started normally
+      //      2. Second instance startup should fail, because ports are occupied by the first one
+      assertNotNull("First drillbit instance should be initialized", fixture.drillbit());
 
 Review comment:
   Looks better, drillbit received from `fixture.drillbit()` will be closed during closing `ClusterFixture`.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services