You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ar...@apache.org on 2018/12/21 17:59:49 UTC
[drill] branch master updated: DRILL-6919: Fix compilation error in
TestGracefulShutdown class for mapr profile
This is an automated email from the ASF dual-hosted git repository.
arina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new af3977a DRILL-6919: Fix compilation error in TestGracefulShutdown class for mapr profile
af3977a is described below
commit af3977a8e6ea2c66a585312bf64463a3d3bd9a6c
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Thu Dec 20 23:39:39 2018 +0200
DRILL-6919: Fix compilation error in TestGracefulShutdown class for mapr profile
---
.../drill/store/openTSDB/TestOpenTSDBPlugin.java | 33 ++--------------------
.../java/org/apache/drill/test/QueryTestUtil.java | 29 +++++++++++++++++++
.../apache/drill/test/TestGracefulShutdown.java | 5 ++--
3 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
index 0c1fb5e..bcff4d6 100644
--- a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
+++ b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
@@ -22,17 +22,12 @@ import org.apache.drill.PlanTestBase;
import org.apache.drill.common.exceptions.UserRemoteException;
import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePluginConfig;
+import org.apache.drill.test.QueryTestUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.BindException;
-import java.net.ServerSocket;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
@@ -55,7 +50,6 @@ import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POS
import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_REQUEST_WITH_TAGS;
public class TestOpenTSDBPlugin extends PlanTestBase {
- private static final Logger logger = LoggerFactory.getLogger(TestOpenTSDBPlugin.class);
private static int portNumber;
@@ -64,7 +58,7 @@ public class TestOpenTSDBPlugin extends PlanTestBase {
@BeforeClass
public static void setup() throws Exception {
- portNumber = getFreePortNumber(10_000, 200);
+ portNumber = QueryTestUtil.getFreePortNumber(10_000, 200);
final StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage();
OpenTSDBStoragePluginConfig storagePluginConfig =
new OpenTSDBStoragePluginConfig(String.format("http://localhost:%s", portNumber));
@@ -191,27 +185,4 @@ public class TestOpenTSDBPlugin extends PlanTestBase {
test("describe `warp.speed.test`");
Assert.assertEquals(1, testSql("show tables"));
}
-
- /**
- * Checks that port with specified number is free and returns it.
- * Otherwise, increases port number and checks until free port is found
- * or the number of attempts is reached specified numberOfAttempts
- *
- * @param portNumber initial port number
- * @param numberOfAttempts max number of attempts to find port with greater number
- * @return free port number
- * @throws BindException if free port was not found and all attempts were used.
- */
- private static int getFreePortNumber(int portNumber, int numberOfAttempts) throws IOException {
- for (int i = portNumber; i <= portNumber + numberOfAttempts; i++) {
- try (ServerSocket socket = new ServerSocket(i)) {
- return socket.getLocalPort();
- } catch (BindException e) {
- logger.warn("Port {} is already in use.", i);
- }
- }
-
- throw new BindException(String.format("Free port could not be found in the range [%s-%s].\n" +
- "Please release any of used ports in this range.", portNumber, portNumber + numberOfAttempts));
- }
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/test/QueryTestUtil.java b/exec/java-exec/src/test/java/org/apache/drill/test/QueryTestUtil.java
index 2c89694..79ac606 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/test/QueryTestUtil.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/test/QueryTestUtil.java
@@ -17,6 +17,9 @@
*/
package org.apache.drill.test;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.ServerSocket;
import java.util.List;
import java.util.Properties;
import java.util.regex.Matcher;
@@ -41,11 +44,15 @@ import org.apache.drill.exec.server.options.OptionManager;
import org.apache.drill.exec.server.options.OptionValue;
import org.apache.drill.exec.server.options.SystemOptionManager;
import org.apache.drill.exec.util.VectorUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utilities useful for tests that issue SQL queries.
*/
public class QueryTestUtil {
+ private static final Logger logger = LoggerFactory.getLogger(QueryTestUtil.class);
+
/**
* Constructor. All methods are static.
*/
@@ -286,4 +293,26 @@ public class QueryTestUtil {
drillbitContext.getCompiler().flushCache();
}
+ /**
+ * Checks that port with specified number is free and returns it.
+ * Otherwise, increases port number and checks until free port is found
+ * or the number of attempts is reached specified numberOfAttempts
+ *
+ * @param portNumber initial port number
+ * @param numberOfAttempts max number of attempts to find port with greater number
+ * @return free port number
+ * @throws BindException if free port was not found and all attempts were used.
+ */
+ public static int getFreePortNumber(int portNumber, int numberOfAttempts) throws IOException {
+ for (int i = portNumber; i <= portNumber + numberOfAttempts; i++) {
+ try (ServerSocket socket = new ServerSocket(i)) {
+ return socket.getLocalPort();
+ } catch (BindException e) {
+ logger.warn("Port {} is already in use.", i);
+ }
+ }
+
+ throw new BindException(String.format("Free port could not be found in the range [%s-%s].\n" +
+ "Please release any of used ports in this range.", portNumber, portNumber + numberOfAttempts));
+ }
}
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 9d649ba..94180e2 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
@@ -21,7 +21,6 @@ import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.server.Drillbit;
-import org.apache.hadoop.net.ServerSocketUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -184,8 +183,8 @@ public class TestGracefulShutdown extends BaseTestQuery {
Drillbit drillbit = null;
Drillbit drillbitWithSamePort = null;
- int userPort = ServerSocketUtil.getPort(31170, 300);
- int bitPort = ServerSocketUtil.getPort(31180, 300);
+ int userPort = QueryTestUtil.getFreePortNumber(31170, 300);
+ int bitPort = QueryTestUtil.getFreePortNumber(31180, 300);
ClusterFixtureBuilder fixtureBuilder = ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk()
.configProperty(ExecConstants.INITIAL_USER_PORT, userPort)
.configProperty(ExecConstants.INITIAL_BIT_PORT, bitPort);