use docker image to test infinispan remote access
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
5cff403a69
commit
a0b9cb3fa4
|
@ -11,7 +11,9 @@
|
|||
<url>http://www.eclipse.org/jetty</url>
|
||||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.sessions.infinispan</bundle-symbolic-name>
|
||||
<hotrod.host>127.0.0.1</hotrod.host>
|
||||
<!-- if changing this version please update default in RemoteInfinispanTestSupport you will get thanks from Eclipse IDE users -->
|
||||
<!-- 10.1.7.Final -->
|
||||
<infinispan.docker.version>9.4.11.Final</infinispan.docker.version>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -129,15 +131,19 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>1.7.25</version>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<!-- to test hotrod, configure a cache called "remote-session-test" -->
|
||||
<profile>
|
||||
<id>remote</id>
|
||||
<id>remote-session-tests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>hotrod.enabled</name>
|
||||
|
@ -154,7 +160,7 @@
|
|||
<include>**/*.java</include>
|
||||
</includes>
|
||||
<systemPropertyVariables>
|
||||
<hotrod.host>${hotrod.host}</hotrod.host>
|
||||
<infinispan.docker.version>${infinispan.docker.version}</infinispan.docker.version>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -35,6 +35,10 @@ import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
|
|||
import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller;
|
||||
import org.infinispan.protostream.FileDescriptorSource;
|
||||
import org.infinispan.protostream.SerializationContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.output.Slf4jLogConsumer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
@ -45,17 +49,33 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||
*/
|
||||
public class RemoteInfinispanTestSupport
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RemoteInfinispanTestSupport.class);
|
||||
public static final String DEFAULT_CACHE_NAME = "session_test_cache";
|
||||
public RemoteCache<String, SessionData> _cache;
|
||||
private String _name;
|
||||
public static RemoteCacheManager _manager;
|
||||
private static final Logger INFINISPAN_LOG =
|
||||
LoggerFactory.getLogger("org.eclipse.jetty.server.session.remote.infinispanLogs");
|
||||
|
||||
static GenericContainer infinispan =
|
||||
new GenericContainer("jboss/infinispan-server:" +
|
||||
System.getProperty("infinispan.docker.version", "9.4.11.Final"))
|
||||
.withEnv("APP_USER","theuser")
|
||||
.withEnv("APP_PASS","foobar")
|
||||
.withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG));
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
String host = System.getProperty("hotrod.host", "127.0.0.1");
|
||||
long start = System.currentTimeMillis();
|
||||
infinispan.start();
|
||||
String host = infinispan.getContainerIpAddress();
|
||||
System.setProperty("hotrod.host", host);
|
||||
int port = infinispan.getMappedPort(11222);
|
||||
|
||||
LOG.info("Infinispan container started for {}:{} - {}ms", host, port,
|
||||
System.currentTimeMillis() - start);
|
||||
SearchMapping mapping = new SearchMapping();
|
||||
mapping.entity(SessionData.class).indexed().providedId()
|
||||
.property("expiry", ElementType.METHOD).field();
|
||||
|
@ -64,7 +84,12 @@ public class RemoteInfinispanTestSupport
|
|||
properties.put(Environment.MODEL_MAPPING, mapping);
|
||||
|
||||
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
|
||||
clientBuilder.withProperties(properties).addServer().host(host).marshaller(new ProtoStreamMarshaller());
|
||||
clientBuilder.withProperties(properties).addServer().host(host).port(port)
|
||||
.security().authentication().enable().realm("default")
|
||||
.serverName("infinispan")
|
||||
.saslMechanism("DIGEST-MD5")
|
||||
.username("theuser").password("foobar")
|
||||
.marshaller(new ProtoStreamMarshaller());
|
||||
|
||||
_manager = new RemoteCacheManager(clientBuilder.build());
|
||||
|
||||
|
@ -90,7 +115,8 @@ public class RemoteInfinispanTestSupport
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail(e);
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
org.slf4j.simpleLogger.defaultLogLevel=info
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.remote.infinispanLogs=info
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.remote.RemoteInfinispanTestSupport=info
|
Loading…
Reference in New Issue