You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2018/10/09 09:28:52 UTC

asterixdb git commit: [NO ISSUE][TEST] Allow Requests To NC Endpoints By Port

Repository: asterixdb
Updated Branches:
  refs/heads/master 6c4325f0d -> e7fa4b3fb


[NO ISSUE][TEST] Allow Requests To NC Endpoints By Port

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Currently, the test framework allows sending requests to
  NC endpoints that are referenced by name if that name was
  added to the list of available NC endpoints. This change
  allows a request to be sent to any endpoint by specifying
  the endpoint port in the test file.
- Modify a test case to utilize port-based NC endpoints.

Change-Id: If0ad80bed625c45da01aa018e4267409c329be9e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2991
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/e7fa4b3f
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/e7fa4b3f
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/e7fa4b3f

Branch: refs/heads/master
Commit: e7fa4b3fb1662f1ae6d1a2336e2be6b51e18f22d
Parents: 6c4325f
Author: Murtadha Hubail <mh...@apache.org>
Authored: Sun Oct 7 18:12:59 2018 +0300
Committer: Murtadha Hubail <mh...@apache.org>
Committed: Tue Oct 9 02:28:14 2018 -0700

----------------------------------------------------------------------
 .../asterix/test/common/TestExecutor.java       | 33 +++++++++++++++-----
 .../release_partition.4.get.http                |  2 +-
 2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/e7fa4b3f/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index b143ea9..98cd668 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -31,6 +31,7 @@ import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.Inet4Address;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.URI;
@@ -135,6 +136,7 @@ public class TestExecutor {
     private static final Pattern MAX_RESULT_READS_PATTERN =
             Pattern.compile("maxresultreads=(\\d+)(\\D|$)", Pattern.MULTILINE);
     private static final Pattern HTTP_REQUEST_TYPE = Pattern.compile("requesttype=(.*)", Pattern.MULTILINE);
+    private static final String NC_ENDPOINT_PREFIX = "nc:";
     public static final int TRUNCATE_THRESHOLD = 16384;
     public static final Set<String> NON_CANCELLABLE =
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList("store", "validate")));
@@ -1723,16 +1725,25 @@ public class TestExecutor {
 
     protected URI createEndpointURI(String path, String query) throws URISyntaxException {
         InetSocketAddress endpoint;
-        if (!path.startsWith("nc:")) {
+        if (isCcEndPointPath(path)) {
             int endpointIdx = Math.abs(endpointSelector++ % endpoints.size());
             endpoint = endpoints.get(endpointIdx);
         } else {
+            // allowed patterns: [nc:endpointName URL] or [nc:nodeId:port URL]
             final String[] tokens = path.split(" ");
             if (tokens.length != 2) {
                 throw new IllegalArgumentException("Unrecognized http pattern");
             }
-            String nodeId = tokens[0].substring(3);
-            endpoint = getNcEndPoint(nodeId);
+            final String endpointName = tokens[0].substring(NC_ENDPOINT_PREFIX.length());
+            if (containsPort(endpointName)) {
+                // currently only loopback address is supported in the test framework
+                final String nodeIP = InetAddress.getLoopbackAddress().getHostAddress();
+                final String endpointParts[] = StringUtils.split(endpointName, ':');
+                int port = Integer.valueOf(endpointParts[1]);
+                endpoint = new InetSocketAddress(nodeIP, port);
+            } else {
+                endpoint = getNcEndPoint(endpointName);
+            }
             path = tokens[1];
         }
         URI uri = new URI("http", null, endpoint.getHostString(), endpoint.getPort(), path, query, null);
@@ -1873,11 +1884,11 @@ public class TestExecutor {
         Assert.assertEquals(HttpStatus.SC_OK, httpResponse.getStatusLine().getStatusCode());
     }
 
-    private InetSocketAddress getNcEndPoint(String nodeId) {
-        if (ncEndPoints == null || !ncEndPoints.containsKey(nodeId)) {
-            throw new IllegalStateException("No end point specified for node: " + nodeId);
+    private InetSocketAddress getNcEndPoint(String name) {
+        if (ncEndPoints == null || !ncEndPoints.containsKey(name)) {
+            throw new IllegalStateException("No end point specified for node: " + name);
         }
-        return ncEndPoints.get(nodeId);
+        return ncEndPoints.get(name);
     }
 
     private InetSocketAddress getNcReplicationAddress(String nodeId) {
@@ -1978,4 +1989,12 @@ public class TestExecutor {
     private static String toQueryServiceHandle(String handle) {
         return handle.replace("/aql/", "/service/");
     }
+
+    private static boolean isCcEndPointPath(String endPoint) {
+        return !endPoint.startsWith(NC_ENDPOINT_PREFIX);
+    }
+
+    private static boolean containsPort(String endPoint) {
+        return StringUtils.contains(endPoint, ':');
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/e7fa4b3f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/replication/release_partition/release_partition.4.get.http
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/replication/release_partition/release_partition.4.get.http b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/replication/release_partition/release_partition.4.get.http
index d5cf952..74ebe94 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/replication/release_partition/release_partition.4.get.http
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/replication/release_partition/release_partition.4.get.http
@@ -16,4 +16,4 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-nc:asterix_nc1 /admin/storage/partition/0
\ No newline at end of file
+nc:asterix_nc1:19004 /admin/storage/partition/0
\ No newline at end of file