polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [4/6] polygene-java git commit: :tools:generator fix Memcache setup in docker based tests
Date Mon, 05 Jun 2017 12:05:20 GMT
:tools:generator fix Memcache setup in docker based tests

If using Docker with a remote host (e.g. boot2docker), the default
configuration pointing to localhost won’t work. This commit always
set memcache configuration defaults according to junit docker rule.


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

Branch: refs/heads/develop
Commit: 182434bd24f1cef8a6ad61c55a472d3d537b2add
Parents: e7d52c5
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Jun 5 14:01:23 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon Jun 5 14:01:56 2017 +0200

----------------------------------------------------------------------
 .../RestAPIApplication/bootstrap-test.tmpl      | 28 ++++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/182434bd/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl
b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl
index ff42660..14f93e5 100644
--- a/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl
@@ -50,8 +50,10 @@ if( polygene.entitystore !== 'Memory' && polygene.entitystore !==
'Preferences'
 <%
     }
 }
-%>
+if( polygene.caching === 'Memcache' ) {
+%>import org.apache.polygene.cache.memcache.MemcacheConfiguration;
 <%
+}
 if( polygene.needsDocker ) {
 %>
 import com.spotify.docker.client.DefaultDockerClient;
@@ -111,6 +113,13 @@ public class BootstrapTest
     private void setupTest( ApplicationAssembly assembly )
     {
         entityStoreSetup( assembly );
+<%
+if( polygene.caching === 'Memcache' ) {
+%>
+        cacheSetup( assembly );
+<%
+}
+%>
     }
 <%
 if(  polygene.entitystore === 'Cassandra' ) {
@@ -272,14 +281,23 @@ if(  polygene.entitystore === 'SQLite' ) {
     {
     }
 <% }
-if(  polygene.caching === 'Memcache' ) {
+if( polygene.caching === 'Memcache' ) {
 %>
+
+    private void cacheSetup( ApplicationAssembly assembly )
+    {
+        ModuleAssembly config = assembly.layer( ConfigurationLayer.NAME ).module( ConfigModule.NAME
);
+
+        MemcacheConfiguration memcacheConfig = config.forMixin( MemcacheConfiguration.class
).declareDefaults();
+        memcacheConfig.addresses().set( CACHE_DOCKER.getDockerHost() + ":" + CACHE_DOCKER.getExposedContainerPort(
"11211/tcp" ) );
+    }
+
     @ClassRule
     public static final OptionalDockerRule CACHE_DOCKER = new OptionalDockerRule( DockerRule.builder()
-                                                              .imageName( "memcached:latest"
 )
-                                                              .expose( "11211", "11211" )
+                                                              .imageName( "memcached:1.4.36-alpine"
 )
+                                                              .expose( "11211" )
                                                               .waitForTimeout( 120 )
-                                                              .waitFor( WaitFor.tcpPort(11211)
) );
+                                                              .waitFor( WaitFor.tcpPort(
11211 ) ) );
 
 <%
 }


Mime
View raw message