polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [2/2] polygene-java git commit: POLYGENE-221 integration test Riak ES using Docker
Date Wed, 11 Jan 2017 00:00:40 GMT
POLYGENE-221 integration test Riak ES using Docker

Riak listen to its network port before being ready to serve clients.
This breaks the test-support integration.
The tests Thread.sleep to give it a chance to be ready
This will be flaky and should be fixed before we run these tests on CI.
See Riak ES tests for details.


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

Branch: refs/heads/develop
Commit: b05b04a1a92acb0f219aa5bd173243c32f96bdae
Parents: f104f0c
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Wed Jan 11 00:55:30 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Wed Jan 11 01:00:21 2017 +0100

----------------------------------------------------------------------
 extensions/entitystore-riak/build.gradle        |  2 +-
 .../riak/RiakMapEntityStoreTest.java            | 24 ++++++++++++++++----
 .../riak/RiakMapEntityStoreWithCacheTest.java   | 21 +++++++++++++----
 .../src/main/docker/riak/Dockerfile             |  1 +
 4 files changed, 39 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b05b04a1/extensions/entitystore-riak/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/build.gradle b/extensions/entitystore-riak/build.gradle
index b0354c7..37672cd 100644
--- a/extensions/entitystore-riak/build.gradle
+++ b/extensions/entitystore-riak/build.gradle
@@ -32,7 +32,7 @@ dependencies {
 
   runtime polygene.core.runtime
 
-  testCompile polygene.core.testsupport
+  testCompile polygene.internals.testsupport
   testCompile polygene.extension( 'valueserialization-orgjson' )
 
   testRuntime libraries.logback

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b05b04a1/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreTest.java
b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreTest.java
index 59f1714..bf4de29 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreTest.java
@@ -22,25 +22,34 @@ import com.basho.riak.client.api.commands.kv.DeleteValue;
 import com.basho.riak.client.api.commands.kv.ListKeys;
 import com.basho.riak.client.core.query.Location;
 import com.basho.riak.client.core.query.Namespace;
+import java.util.Collections;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.riak.assembly.RiakEntityStoreAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
 import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.junit.ClassRule;
 
 public class RiakMapEntityStoreTest
     extends AbstractEntityStoreTest
 {
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "riak", 8087 );
+
     @BeforeClass
-    public static void beforeRiakProtobufMapEntityStoreTests()
+    public static void waitForRiak() throws InterruptedException
     {
-        assumeConnectivity( "localhost", 8087 );
+        // TODO:flakiness Properly wait for Riak to be ready
+        // Riak listen to its network port before being ready to serve clients
+        // This breaks the test-support integration
+        // Wait a bit to give it a chance to be ready
+        Thread.sleep( 10_000 );
     }
+
     @Override
     // START SNIPPET: assembly
     public void assemble( ModuleAssembly module )
@@ -53,6 +62,13 @@ public class RiakMapEntityStoreTest
         new OrgJsonValueSerializationAssembler().assemble( module );
         // START SNIPPET: assembly
         new RiakEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module
);
+        // END SNIPPET: assembly
+        RiakEntityStoreConfiguration riakConfig = config.forMixin( RiakEntityStoreConfiguration.class
)
+                                                        .declareDefaults();
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "8087/tcp" );
+        riakConfig.hosts().set( Collections.singletonList( host + ':' + port ) );
+        // START SNIPPET: assembly
     }
     // END SNIPPET: assembly
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b05b04a1/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
index 25feae1..50759f9 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
@@ -24,24 +24,32 @@ import com.basho.riak.client.api.commands.kv.DeleteValue;
 import com.basho.riak.client.api.commands.kv.ListKeys;
 import com.basho.riak.client.core.query.Location;
 import com.basho.riak.client.core.query.Namespace;
+import java.util.Collections;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.riak.assembly.RiakEntityStoreAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
 import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.junit.ClassRule;
 
 public class RiakMapEntityStoreWithCacheTest
     extends AbstractEntityStoreWithCacheTest
 {
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "riak", 8087 );
+
     @BeforeClass
-    public static void beforeRiakMapEntityStoreTests()
+    public static void waitForRiak() throws InterruptedException
     {
-        assumeConnectivity( "localhost", 8087 );
+        // TODO:flakiness Properly wait for Riak to be ready
+        // Riak listen to its network port before being ready to serve clients
+        // This breaks the test-support integration
+        // Wait a bit to give it a chance to be ready
+        Thread.sleep( 10_000 );
     }
 
     @Override
@@ -53,6 +61,11 @@ public class RiakMapEntityStoreWithCacheTest
         new EntityTestAssembler().assemble( config );
         new OrgJsonValueSerializationAssembler().assemble( module );
         new RiakEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module
);
+        RiakEntityStoreConfiguration riakConfig = config.forMixin( RiakEntityStoreConfiguration.class
)
+                                                        .declareDefaults();
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "8087/tcp" );
+        riakConfig.hosts().set( Collections.singletonList( host + ':' + port ) );
     }
 
     private RiakClient riakClient;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b05b04a1/internals/testsupport-internal/src/main/docker/riak/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/riak/Dockerfile b/internals/testsupport-internal/src/main/docker/riak/Dockerfile
new file mode 100644
index 0000000..7e1ebfa
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/riak/Dockerfile
@@ -0,0 +1 @@
+FROM basho/riak-kv:latest


Mime
View raw message