From c090a43c5f17655855f3dd08c2498dc1cb31a269 Mon Sep 17 00:00:00 2001 From: Bowen Ding Date: Fri, 14 Aug 2020 21:14:25 +0800 Subject: [PATCH] Set ports to default when testing. --- .../drill/exec/store/ipfs/IPFSGroupScan.java | 8 ++++---- .../drill/exec/store/ipfs/IPFSTestBase.java | 8 +++++++- .../drill/exec/store/ipfs/TestIPFSQueries.java | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSGroupScan.java b/contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSGroupScan.java index eeed78455ee..1c165c05df7 100644 --- a/contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSGroupScan.java +++ b/contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSGroupScan.java @@ -75,10 +75,10 @@ public class IPFSGroupScan extends AbstractGroupScan { private List columns; private static final long DEFAULT_NODE_SIZE = 1000L; - private static final int DEFAULT_USER_PORT = 31010; - private static final int DEFAULT_CONTROL_PORT = 31011; - private static final int DEFAULT_DATA_PORT = 31012; - private static final int DEFAULT_HTTP_PORT = 8047; + public static final int DEFAULT_USER_PORT = 31010; + public static final int DEFAULT_CONTROL_PORT = 31011; + public static final int DEFAULT_DATA_PORT = 31012; + public static final int DEFAULT_HTTP_PORT = 8047; private ListMultimap assignments; private List ipfsWorkList = Lists.newArrayList(); diff --git a/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/IPFSTestBase.java b/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/IPFSTestBase.java index a43ec5581d3..c88f298653f 100644 --- a/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/IPFSTestBase.java +++ b/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/IPFSTestBase.java @@ -20,8 +20,10 @@ package org.apache.drill.exec.store.ipfs; +import org.apache.drill.exec.ExecConstants; import org.apache.drill.exec.store.StoragePluginRegistry; import org.apache.drill.test.ClusterFixture; +import org.apache.drill.test.ClusterFixtureBuilder; import org.apache.drill.test.ClusterTest; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -34,7 +36,11 @@ public class IPFSTestBase extends ClusterTest { @BeforeClass public static void setUpBeforeClass() throws Exception { - startCluster(ClusterFixture.builder(dirTestWatcher)); + ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher); + builder.configProperty(ExecConstants.INITIAL_BIT_PORT, IPFSGroupScan.DEFAULT_CONTROL_PORT); + builder.configProperty(ExecConstants.INITIAL_DATA_PORT, IPFSGroupScan.DEFAULT_DATA_PORT); + builder.configProperty(ExecConstants.INITIAL_USER_PORT, IPFSGroupScan.DEFAULT_USER_PORT); + startCluster(builder); pluginRegistry = cluster.drillbit().getContext().getStorage(); IPFSTestSuit.initIPFS(); diff --git a/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/TestIPFSQueries.java b/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/TestIPFSQueries.java index 06f4dbd0693..9c5b30669a8 100644 --- a/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/TestIPFSQueries.java +++ b/contrib/storage-ipfs/src/test/java/org/apache/drill/exec/store/ipfs/TestIPFSQueries.java @@ -22,6 +22,8 @@ import io.ipfs.multihash.Multihash; import org.apache.drill.categories.IPFSStorageTest; import org.apache.drill.categories.SlowTest; +import org.apache.drill.exec.proto.CoordinationProtos; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -32,8 +34,23 @@ @Category({SlowTest.class, IPFSStorageTest.class}) public class TestIPFSQueries extends IPFSTestBase { + @Before + public void checkDrillbitPorts() { + CoordinationProtos.DrillbitEndpoint ep = cluster.drillbit().getRegistrationHandle().getEndPoint(); + int controlPort = ep.getControlPort(); + int userPort = ep.getUserPort(); + int dataPort = ep.getDataPort(); + if (controlPort != IPFSGroupScan.DEFAULT_CONTROL_PORT + || userPort != IPFSGroupScan.DEFAULT_USER_PORT + || dataPort != IPFSGroupScan.DEFAULT_DATA_PORT) { + //DRILL-7754 handle non-default ports + fail(String.format("Drill binded to non-default ports: %d, %d, %d", controlPort, userPort, dataPort)); + } + } + @Test public void testNullQuery() throws Exception { + testBuilder() .sqlQuery(getSelectStar(IPFSHelper.IPFS_NULL_OBJECT)) .unOrdered()