You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/10/11 21:38:16 UTC

incubator-geode git commit: Make hostname, member name and container name consistent

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/e2e-testing e4313d2e9 -> 9c4ced8ab


Make hostname, member name and container name consistent


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9c4ced8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9c4ced8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9c4ced8a

Branch: refs/heads/feature/e2e-testing
Commit: 9c4ced8ab4f81344ef62962a009029b50b046a97
Parents: e4313d2
Author: Jens Deppe <jd...@pivotal.io>
Authored: Tue Oct 11 14:37:05 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Tue Oct 11 14:38:08 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/geode/e2e/DockerTest.java   |  2 +-
 .../java/org/apache/geode/e2e/GetPutSteps.java  | 40 ++++++++++----------
 .../geode/e2e/container/DockerCluster.java      | 25 +++++++-----
 .../org/apache/geode/e2e/get_put.story          |  2 +-
 4 files changed, 36 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9c4ced8a/geode-core/src/test/java/org/apache/geode/e2e/DockerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/e2e/DockerTest.java b/geode-core/src/test/java/org/apache/geode/e2e/DockerTest.java
index 13d1807..3587456 100644
--- a/geode-core/src/test/java/org/apache/geode/e2e/DockerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/e2e/DockerTest.java
@@ -32,7 +32,7 @@ public class DockerTest {
 
   @Test
   public void testInvalidGfshCommandReturnsNonZero() throws Exception {
-    String id = cluster.startContainer();
+    String id = cluster.startContainer("test-host-1");
     int r = cluster.execCommand(id, false, null, new String[] { "/tmp/work/bin/gfsh", "startx" });
     assertEquals(1, r);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9c4ced8a/geode-core/src/test/java/org/apache/geode/e2e/GetPutSteps.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/e2e/GetPutSteps.java b/geode-core/src/test/java/org/apache/geode/e2e/GetPutSteps.java
index e07ee34..a457dcf 100644
--- a/geode-core/src/test/java/org/apache/geode/e2e/GetPutSteps.java
+++ b/geode-core/src/test/java/org/apache/geode/e2e/GetPutSteps.java
@@ -1,12 +1,8 @@
 package org.apache.geode.e2e;
 
-import static junit.framework.TestCase.assertNotNull;
 import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.List;
 
 import com.spotify.docker.client.exceptions.DockerException;
@@ -88,6 +84,25 @@ public class GetPutSteps {
     }
   }
 
+  @Given("class{es|} $fnName {is|are} deployed")
+  public void deployClasses(String fnClasses) throws Exception {
+    for (String fnClass : fnClasses.split(",")) {
+      String jar = cluster.injectScratchFile(Utils.getJarForClassName(fnClass));
+      cluster.gfshCommand("deploy --jar=" + jar);
+    }
+  }
+
+  @When("I call function with id $fnId on region $regionName with argument $arg it returns $returns")
+  public void testRegionBucketSizeWithFunction(String fnId, String regionName, String arg, int returns) {
+    ClientCache cache = getClientCache();
+    Region region = cache.getRegion(regionName);
+    Execution exe = FunctionService.onServers(region.getRegionService());
+    ResultCollector rs = exe.withArgs(regionName).execute(fnId);
+    List<Integer> results = (List<Integer>) rs.getResult();
+
+    assertEquals(returns, results.stream().mapToInt(i -> i.intValue()).sum());
+  }
+
   private ClientCache getClientCache() {
     ClientCache cache;
     try {
@@ -105,22 +120,5 @@ public class GetPutSteps {
     return cache;
   }
 
-  @Given("function $fnName is deployed")
-  public void deployFunction(String fnClass) throws Exception {
-    String jar = cluster.injectScratchFile(Utils.getJarForClassName(fnClass));
-    cluster.gfshCommand("deploy --jar=" + jar);
-  }
-
-  @When("I call function with id $fnId on region $regionName with argument $arg it returns $returns")
-  public void foo(String fnId, String regionName, String arg, int returns) {
-    ClientCache cache = getClientCache();
-    Region region = cache.getRegion(regionName);
-    Execution exe = FunctionService.onServers(region.getRegionService());
-    ResultCollector rs = exe.withArgs(regionName).execute(fnId);
-    List<Integer> results = (List<Integer>) rs.getResult();
-
-    assertEquals(returns, results.stream().mapToInt(i -> i.intValue()).sum());
-  }
-
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9c4ced8a/geode-core/src/test/java/org/apache/geode/e2e/container/DockerCluster.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/e2e/container/DockerCluster.java b/geode-core/src/test/java/org/apache/geode/e2e/container/DockerCluster.java
index 3ccc343..2582a4e 100644
--- a/geode-core/src/test/java/org/apache/geode/e2e/container/DockerCluster.java
+++ b/geode-core/src/test/java/org/apache/geode/e2e/container/DockerCluster.java
@@ -1,6 +1,7 @@
 package org.apache.geode.e2e.container;
 
 import static com.google.common.base.Charsets.*;
+import static org.apache.geode.internal.cache.CacheServerLauncher.serverPort;
 
 import java.io.File;
 import java.io.IOException;
@@ -88,13 +89,12 @@ public class DockerCluster {
     startServers();
   }
 
-  public String startContainer() throws DockerException, InterruptedException {
-    return startContainer(new HashMap<>());
+  public String startContainer(String name) throws DockerException, InterruptedException {
+    return startContainer(name, new HashMap<>());
   }
 
-  public String startContainer(Map<String, List<PortBinding>> portBindings) throws DockerException, InterruptedException {
+  public String startContainer(String name, Map<String, List<PortBinding>> portBindings) throws DockerException, InterruptedException {
     String vol = String.format("%s:/tmp/work", geodeHome);
-    String hostname = String.format("%s-%d", name, containerCount++);
 
     HostConfig hostConfig = HostConfig.
       builder().
@@ -106,14 +106,14 @@ public class DockerCluster {
       image("gemfire/ubuntu-gradle").
       openStdin(true).
       exposedPorts(portBindings.keySet()).
-      hostname(hostname).
+      hostname(name).
       hostConfig(hostConfig).
       workingDir("/tmp").
       build();
 
     ContainerCreation creation = docker.createContainer(config);
     String id = creation.id();
-    docker.renameContainer(id, hostname);
+    docker.renameContainer(id, name);
     docker.startContainer(id);
     docker.inspectContainer(id);
 
@@ -124,10 +124,12 @@ public class DockerCluster {
 
   public void startLocators() throws DockerException, InterruptedException {
     for (int i = 0; i < locatorCount; i++) {
+      String memberName = String.format("%s-locator-%d", name, i);
       String[] command = {
         "/tmp/work/bin/gfsh",
         "start locator",
-        String.format("--name=%s-locator-%d", name, i),
+        "--name=" + memberName,
+        "--J=-Dgemfire.enable-cluster-configuration=false",
         "--J=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
       };
 
@@ -140,9 +142,10 @@ public class DockerCluster {
       debugBinding.add(PortBinding.of("HostPort", (5005 + i) + ""));
       ports.put("5005/tcp", debugBinding);
 
-      String id = startContainer(ports);
+      String id = startContainer(memberName, ports);
       execCommand(id, true, null, command);
 
+      // Simply loop, trying to connect to the locator
       while (gfshCommand(null, null) != 0) {
         Thread.sleep(250);
       }
@@ -156,14 +159,16 @@ public class DockerCluster {
   public void startServers() throws DockerException, InterruptedException {
     String locatorAddress = String.format("%s[10334]", docker.inspectContainer(nodeIds.get(0)).networkSettings().ipAddress());
     for (int i = 0; i < serverCount; i++) {
+      String memberName = String.format("%s-server-%d", name, i);
       String serverPort = Integer.toString(40404 + i);
       String[] command = {
         "/tmp/work/bin/gfsh",
         "start server",
-        String.format("--name=%s-server-%d", name, i),
+        "--name=" + memberName,
         "--locators=" + locatorAddress,
         "--server-port=" + serverPort,
         "--hostname-for-clients=localhost",
+//        "--J=-Dgemfire.locator-wait-time=30",
         "--J=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
       };
 
@@ -176,7 +181,7 @@ public class DockerCluster {
       debugBinding.add(PortBinding.of("HostPort", (5005 + i + locatorCount) + ""));
       ports.put("5005/tcp", debugBinding);
 
-      String id = startContainer(ports);
+      String id = startContainer(memberName, ports);
       execCommand(id, true, null, command);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9c4ced8a/geode-core/src/test/resources/org/apache/geode/e2e/get_put.story
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/e2e/get_put.story b/geode-core/src/test/resources/org/apache/geode/e2e/get_put.story
index b6651de..0905390 100644
--- a/geode-core/src/test/resources/org/apache/geode/e2e/get_put.story
+++ b/geode-core/src/test/resources/org/apache/geode/e2e/get_put.story
@@ -9,7 +9,7 @@ Given region BAR is created as PARTITION_REDUNDANT with redundancy 1
 When I put 100 entries into region BAR
 Then I can get 100 entries from region BAR
 
-Given function org.apache.geode.e2e.FnGetPrimaryBucketSize is deployed
+Given class org.apache.geode.e2e.FnGetPrimaryBucketSize is deployed
 When I call function with id org.apache.geode.e2e.FnGetPrimaryBucketSize on region BAR with argument BAZ it returns 100
 
 Given server 0 is killed