Create seperate test examples for different Infinispan versions

Programmatic cache configuration only works for Infinispan 9.1.x. Previous versions can use a linked configuration file to create caches. The InfinispanContainer needed to be updated in order to make the use of GenericContainer methods work.
This commit is contained in:
Reinhard Prechtl 2017-12-22 15:05:16 +01:00
parent ebb1320506
commit d08688124e
6 changed files with 301 additions and 10 deletions

View file

@ -20,7 +20,7 @@ import static java.time.temporal.ChronoUnit.SECONDS;
* @param <SELF> * @param <SELF>
*/ */
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
public class InfinispanContainer<SELF extends InfinispanContainer<SELF>> extends GenericContainer<SELF> { public class InfinispanContainer extends GenericContainer<InfinispanContainer> {
private static final String IMAGE_NAME = "jboss/infinispan-server"; private static final String IMAGE_NAME = "jboss/infinispan-server";
public static final String STANDALONE_MODE_CMD = "standalone"; public static final String STANDALONE_MODE_CMD = "standalone";
@ -48,7 +48,7 @@ public class InfinispanContainer<SELF extends InfinispanContainer<SELF>> extends
} }
private ProtocolVersion protocolVersion; private ProtocolVersion protocolVersion;
private Collection<String> cacheNames; private Collection<String> cacheNames = new ArrayList<>();
private RemoteCacheManager cacheManager; private RemoteCacheManager cacheManager;
@ -72,7 +72,7 @@ public class InfinispanContainer<SELF extends InfinispanContainer<SELF>> extends
this.waitStrategy = new LogMessageWaitStrategy() this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx(".*Infinispan Server.*started in.*\\s") .withRegEx(".*Infinispan Server.*started in.*\\s")
.withStartupTimeout(Duration.of(20, SECONDS)); .withStartupTimeout(Duration.of(60, SECONDS));
} }
/** /**
@ -87,7 +87,7 @@ public class InfinispanContainer<SELF extends InfinispanContainer<SELF>> extends
* @return The container instance * @return The container instance
*/ */
@Override @Override
public SELF withCommand(String cmd) { public InfinispanContainer withCommand(String cmd) {
super.setCommand(cmd); super.setCommand(cmd);
this.withCommand(ensureStandaloneCommand(getCommandParts())); this.withCommand(ensureStandaloneCommand(getCommandParts()));
return self(); return self();
@ -100,7 +100,7 @@ public class InfinispanContainer<SELF extends InfinispanContainer<SELF>> extends
* @return * @return
*/ */
@Override @Override
public SELF withCommand(String... commandParts) { public InfinispanContainer withCommand(String... commandParts) {
this.setCommand(ensureStandaloneCommand(commandParts)); this.setCommand(ensureStandaloneCommand(commandParts));
return self(); return self();
} }

View file

@ -25,7 +25,7 @@ public class GenericInfinispanContainerIntegrationTest {
.waitingFor(new LogMessageWaitStrategy().withRegEx(".*Infinispan Server.*started in.*\\s")) .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Infinispan Server.*started in.*\\s"))
.withStartupTimeout(Duration.ofMillis(20000)) .withStartupTimeout(Duration.ofMillis(20000))
.withClasspathResourceMapping( .withClasspathResourceMapping(
"infinispan-standalone.xml", "infinispan-91x-standalone.xml",
"/opt/jboss/infinispan-server/standalone/configuration/standalone.xml", "/opt/jboss/infinispan-server/standalone/configuration/standalone.xml",
BindMode.READ_ONLY) BindMode.READ_ONLY)
.withCommand("standalone"); .withCommand("standalone");

View file

@ -2,15 +2,20 @@ import de.rpr.testcontainers.infinispan.InfinispanContainer;
import org.infinispan.client.hotrod.ProtocolVersion; import org.infinispan.client.hotrod.ProtocolVersion;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
public class Infinispan91xContainerIntegrationTest { public class Infinispan90xContainerIntegrationTest {
@ClassRule @ClassRule
public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final") public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.0.3.Final")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26) .withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
.withCaches("testCache"); .withClasspathResourceMapping(
"infinispan-90x-standalone.xml",
"/opt/jboss/infinispan-server/standalone/configuration/standalone.xml",
BindMode.READ_ONLY) ;
@Test @Test
public void rule_should_have_mapped_hotrod_port() { public void rule_should_have_mapped_hotrod_port() {

View file

@ -5,7 +5,7 @@ import org.junit.Test;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
public class InfinispanContainerIntegrationTest { public class Infinispan91xContainerIntegrationTest {
@ClassRule @ClassRule
public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final") public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final")

View file

@ -0,0 +1,286 @@
<?xml version="1.0" ?>
<server xmlns="urn:jboss:domain:4.2">
<extensions>
<extension module="org.infinispan.extension"/>
<extension module="org.infinispan.server.endpoint"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.logging"/>
<extension module="org.jboss.as.naming"/>
<extension module="org.jboss.as.remoting"/>
<extension module="org.jboss.as.security"/>
<extension module="org.jboss.as.transactions"/>
<extension module="org.wildfly.extension.io"/>
<extension module="org.wildfly.extension.security.manager"/>
</extensions>
<management>
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
</security-realms>
<audit-log>
<formatters>
<json-formatter name="json-formatter"/>
</formatters>
<handlers>
<file-handler name="file" formatter="json-formatter" relative-to="jboss.server.data.dir" path="audit-log.log"/>
</handlers>
<logger log-boot="true" log-read-only="false" enabled="false">
<handlers>
<handler name="file"/>
</handlers>
</logger>
</audit-log>
<management-interfaces>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
<access-control provider="simple">
<role-mapping>
<role name="SuperUser">
<include>
<user name="$local"/>
</include>
</role>
</role-mapping>
</access-control>
</management>
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<size-rotating-file-handler name="HR-ACCESS-FILE" autoflush="true">
<formatter>
<pattern-formatter pattern="(%t) %s%e%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="hotrod-access.log"/>
<append value="true"/>
<rotate-size value="10M"/>
<max-backup-index value="10"/>
</size-rotating-file-handler>
<size-rotating-file-handler name="REST-ACCESS-FILE" autoflush="true">
<formatter>
<pattern-formatter pattern="(%t) %s%e%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="rest-access.log"/>
<append value="true"/>
<rotate-size value="10M"/>
<max-backup-index value="10"/>
</size-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="org.infinispan.server.hotrod.logging.HotRodAccessLoggingHandler">
<!-- Set to TRACE to enable access logging for hot rod or use DMR -->
<level name="INFO"/>
<handlers>
<handler name="HR-ACCESS-FILE"/>
</handlers>
</logger>
<logger category="RestAccessLoggingHandler">
<!-- Set to TRACE to enable access logging for rest or use DMR -->
<level name="INFO"/>
<handlers>
<handler name="REST-ACCESS-FILE"/>
</handlers>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:io:1.1">
<worker name="default"/>
<buffer-pool name="default"/>
</subsystem>
<subsystem xmlns="urn:infinispan:server:core:9.0" default-cache-container="local">
<cache-container name="local" default-cache="default" statistics="true">
<global-state/>
<local-cache name="default"/>
<local-cache name="testCache"/>
</cache-container>
</subsystem>
<subsystem xmlns="urn:infinispan:server:endpoint:9.0">
<hotrod-connector socket-binding="hotrod" cache-container="local">
<topology-state-transfer lazy-retrieval="false" lock-timeout="1000" replication-timeout="5000"/>
</hotrod-connector>
<rest-connector socket-binding="rest" cache-container="local">
<authentication security-realm="ApplicationRealm" auth-method="BASIC"/>
</rest-connector>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jca:4.0">
<archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/>
<bean-validation enabled="true"/>
<default-workmanager>
<short-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</short-running-threads>
<long-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</long-running-threads>
</default-workmanager>
<cached-connection-manager/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<remote-naming/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
<endpoint/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="jboss-web-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jboss-ejb-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jaspitest" cache-type="default">
<authentication-jaspi>
<login-module-stack name="dummy">
<login-module code="Dummy" flag="optional"/>
</login-module-stack>
<auth-module code="Dummy"/>
</authentication-jaspi>
</security-domain>
</security-domains>
</subsystem>
<subsystem xmlns="urn:jboss:domain:security-manager:1.0">
<deployment-permissions>
<maximum-set>
<permission class="java.security.AllPermission"/>
</maximum-set>
</deployment-permissions>
</subsystem>
<subsystem xmlns="urn:jboss:domain:transactions:3.0">
<core-environment>
<process-id>
<uuid/>
</process-id>
</core-environment>
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
</subsystem>
</profile>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="hotrod" port="11222"/>
<socket-binding name="hotrod-internal" port="11223"/>
<socket-binding name="hotrod-multi-tenancy" port="11224"/>
<socket-binding name="memcached" port="11211"/>
<socket-binding name="rest" port="8080"/>
<socket-binding name="rest-multi-tenancy" port="8081"/>
<socket-binding name="rest-ssl" port="8443"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<socket-binding name="websocket" port="8181"/>
<outbound-socket-binding name="remote-store-hotrod-server">
<remote-destination host="remote-host" port="11222"/>
</outbound-socket-binding>
<outbound-socket-binding name="remote-store-rest-server">
<remote-destination host="remote-host" port="8080"/>
</outbound-socket-binding>
</socket-binding-group>
</server>