Compare commits

..

No commits in common. "03783caf74906a6bbd753edf79cbce2a2c9effcc" and "d08688124e4a6b4b870984240864dd5337714f5b" have entirely different histories.

12 changed files with 132 additions and 757 deletions

View file

@ -8,68 +8,19 @@ for the Infinispan cache server. It provides an API that is aimed to help you co
At the moment this is a rudimentary implementation and by no means complete. It only supports the [Hotrod protocol](http://infinispan.org/docs/stable/user_guide/user_guide.html#hot_rod_protocol) At the moment this is a rudimentary implementation and by no means complete. It only supports the [Hotrod protocol](http://infinispan.org/docs/stable/user_guide/user_guide.html#hot_rod_protocol)
to connect to the Infinispan server, for example. to connect to the Infinispan server, for example.
Further information can be found in these blog posts:
- [12-19-2017: Running an Infinispan Server using Testcontainers](https://blog.codecentric.de/en/2017/12/running-infinispan-server-using-testcontainers)
- [01-21-2018: Running a clustered Infinispan Server using Testcontainers](https://reinhard.codes/2018/01/21/running-an-infinispan-node-in-clustered-mode-using-testcontainers/)
Feel free to suggest changes! Feel free to suggest changes!
# Usage # Usage
It's possible to run Infinispan in standalone or in clustered mode. See the integration tests contained in this repository Here's simple example how you can use the `InfinispanContainer`.
for detailed examples.
## Instantiation of the Infinispan containers
Here's a simple example how you can use the `StandaloneInfinispanContainer`.
``` ```
@ClassRule @ClassRule
public static InfinispanContainer infinispan = new StandaloneInfinispanContainer(); public static InfinispanContainer infinispan = new InfinispanContainer()
```
If you want to run Infinispan as a one-node clustered instance, you can do it like this:
```
@ClassRule
public static InfinispanContainer infinispan = new ClusteredInfinispanContainer();
```
## Cache creation
You can create simple local caches that need to be available for your tests. If you run an up-to-date Infinispan container (>9.1.0) then caches can be created
using the API of the `RemoteCacheManager` provided by the Infinispan client library. Simple configure some caches that the `InfinispanContainer` should create for you.
They will automatically be created once the container has started.
```
new StandaloneInfinispanContainer()
.withCaches("testCache")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26);
```
The `ClusteredInfinispanContainer` supports the same method.
If you run an Infinispan server version prior to `9.1.0`, you can link a configuration file that contains the necessary caches into the container:
```
new StandaloneInfinispanContainer("jboss/infinispan-server:9.0.3.Final")
.withStandaloneConfiguration("infinispan-standalone.xml")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26) .withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
.withCaches("testCache");
``` ```
There's an equivalent for the `ClusteredInfinispanContainer`:
```
new ClusteredInfinispanContainer("jboss/infinispan-server:9.0.3.Final")
.withClusteredConfiguration("infinispan-clustered.xml")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
```
## CacheManager retrieval
If you want, you can retrieve a `RemoteCacheManager` from the container: If you want, you can retrieve a `RemoteCacheManager` from the container:
``` ```
infinispan.getCacheManager() infinispan.getCacheManager()
``` ```

View file

@ -15,7 +15,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Dependency versions --> <!-- Dependency versions -->
<testcontainers.version>1.5.1</testcontainers.version> <testcontainers.version>1.5.0</testcontainers.version>
<infinispan.version>9.1.4.Final</infinispan.version> <infinispan.version>9.1.4.Final</infinispan.version>
</properties> </properties>

View file

@ -1,57 +0,0 @@
package de.rpr.testcontainers.infinispan;
import de.rpr.testcontainers.infinispan.transport.DisabledTopologyStateTransferTransportFactory;
import org.infinispan.client.hotrod.impl.transport.TransportFactory;
import org.testcontainers.containers.BindMode;
import java.util.Optional;
/**
* An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be
* used to easily instantiate an Infinispan server for integration tests.
*/
@SuppressWarnings("ALL")
public class ClusteredInfinispanContainer extends InfinispanContainer {
private static final String IMAGE_NAME = "jboss/infinispan-server";
/**
* Construct an instance using the latest Infinispan image version.
*/
public ClusteredInfinispanContainer() {
this(IMAGE_NAME + ":latest");
}
/**
* Construct an instance using the specifice image name.
*
* @param imageName The image name, must contain a version reference
*/
public ClusteredInfinispanContainer(final String imageName) {
super(imageName);
}
/**
* Use a custom {@link TransportFactory} to disable the Hotrod Topology-State-Transfer.
*
* @return
*/
@Override
protected Optional<Class<? extends TransportFactory>> getTransportFactory() {
return Optional.of(DisabledTopologyStateTransferTransportFactory.class);
}
/**
* Links a configuration file for a clustered Infinispan server into the container. The configuration file format needs to match the server version.
*
* @param filenameFromClasspath The filename containing the standalone configuration.
* @return The container itself
*/
public ClusteredInfinispanContainer withClusteredConfiguration(final String filenameFromClasspath) {
return (ClusteredInfinispanContainer) withClasspathResourceMapping(
filenameFromClasspath,
"/opt/jboss/infinispan-server/standalone/configuration/clustered.xml",
BindMode.READ_ONLY);
}
}

View file

@ -3,19 +3,40 @@ package de.rpr.testcontainers.infinispan;
import com.github.dockerjava.api.command.InspectContainerResponse; import com.github.dockerjava.api.command.InspectContainerResponse;
import org.infinispan.client.hotrod.ProtocolVersion; import org.infinispan.client.hotrod.ProtocolVersion;
import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.infinispan.client.hotrod.impl.transport.TransportFactory;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.Wait; import org.testcontainers.containers.wait.LogMessageWaitStrategy;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.stream.IntStream;
import static java.time.temporal.ChronoUnit.SECONDS;
/**
* An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be
* used to easily instantiate an Infinispan server for integration tests.
*
* @param <SELF>
*/
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
public abstract class InfinispanContainer<T extends InfinispanContainer<T>> extends GenericContainer<T> { public class InfinispanContainer extends GenericContainer<InfinispanContainer> {
private static final String IMAGE_NAME = "jboss/infinispan-server";
public static final String STANDALONE_MODE_CMD = "standalone";
/*
* An enumeration of the endpoints provided by Infinispan, that this container provides access to.
*/
private enum InfinispanEndpoints {
HOTROD(11222);
private final int protocolPort;
private InfinispanEndpoints(final int port) {
this.protocolPort = port;
}
}
private static final Set<ProtocolVersion> incompatibleProtocolVersions = new HashSet<>(); private static final Set<ProtocolVersion> incompatibleProtocolVersions = new HashSet<>();
@ -26,98 +47,79 @@ public abstract class InfinispanContainer<T extends InfinispanContainer<T>> exte
incompatibleProtocolVersions.add(ProtocolVersion.PROTOCOL_VERSION_13); incompatibleProtocolVersions.add(ProtocolVersion.PROTOCOL_VERSION_13);
} }
/*
* An enumeration of the endpoints provided by Infinispan, that this container provides access to.
*/
protected enum InfinispanEndpoints {
HOTROD(11222);
private final int protocolPort;
InfinispanEndpoints(final int port) {
this.protocolPort = port;
}
public int getProtocolPort() {
return protocolPort;
}
}
protected RemoteCacheManager cacheManager;
private final String infinispanServerVersion;
private final Collection<String> cacheNames = new ArrayList<>();
private ProtocolVersion protocolVersion; private ProtocolVersion protocolVersion;
private Collection<String> cacheNames = new ArrayList<>();
private boolean isProtocolConflict() { private RemoteCacheManager cacheManager;
return incompatibleProtocolVersions.contains(getProtocolVersion());
} /**
* Construct an instance using the latest Infinispan image version.
private boolean isMajorVersionConflict() { */
return IntStream.range(1, 8) public InfinispanContainer() {
.anyMatch(majorVersion -> getInfinispanServerVersion().startsWith(Integer.toString(majorVersion))); this(IMAGE_NAME + ":latest");
}
private boolean isMinorVersionConflict() {
boolean minorVersionConflict = false;
if (getInfinispanServerVersion().startsWith("9.0")) {
minorVersionConflict = true;
}
return minorVersionConflict;
} }
/**
* Construct n instance using the specifice image name.
*
* @param imageName The image name, must contain a version reference
*/
public InfinispanContainer(final String imageName) { public InfinispanContainer(final String imageName) {
super(imageName); super(imageName);
this.infinispanServerVersion = imageName.split(":")[1]; this.withCommand(STANDALONE_MODE_CMD);
withExposedPorts(Arrays.stream(InfinispanEndpoints.values()).map(endpoint -> endpoint.protocolPort).toArray(Integer[]::new));
withExposedPorts(Arrays.stream(InfinispanEndpoints.values()) this.waitStrategy = new LogMessageWaitStrategy()
.map(endpoint -> endpoint.getProtocolPort()).toArray(Integer[]::new)); .withRegEx(".*Infinispan Server.*started in.*\\s")
.withStartupTimeout(Duration.of(60, SECONDS));
this.waitStrategy = Wait.forListeningPort();
} }
/**
* Overloading, because we want to make sure that the "standalone" command is always present.
* <p>
* The {@link org.testcontainers.containers.GenericContainer#setCommand} method splits on empty string.
* In order to avoid dependency of that behaviour, we set the cmd first, then getting the commandParts
* and ensuring that it contains the "standalone" command.
* </p>
*
* @param cmd The command(s) to set. {@link org.testcontainers.containers.GenericContainer#setCommand}
* @return The container instance
*/
@Override
public InfinispanContainer withCommand(String cmd) {
super.setCommand(cmd);
this.withCommand(ensureStandaloneCommand(getCommandParts()));
return self();
}
/**
* Overloading, because we want to make sure that the "standalone" command is always present.
*
* @param cmd
* @return
*/
@Override
public InfinispanContainer withCommand(String... commandParts) {
this.setCommand(ensureStandaloneCommand(commandParts));
return self();
}
private String[] ensureStandaloneCommand(final String[] commandParts) {
List<String> commands = Arrays.asList(commandParts);
if (commands.contains(STANDALONE_MODE_CMD)) {
return commands.toArray(new String[0]);
} else {
commands.add(STANDALONE_MODE_CMD);
return commands.toArray(new String[0]);
}
}
public InfinispanContainer withProtocolVersion(final ProtocolVersion protocolVersion) { public InfinispanContainer withProtocolVersion(final ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion; this.protocolVersion = protocolVersion;
return this; return this;
} }
@Override
protected void finished(final Description description) {
if (cacheManager != null) {
cacheManager.stop();
}
super.finished(description);
}
/**
* Retrieve the Hotrod endpoint address used to connect to the Infinispan instance inside the container.
*
* @return A String of the format [ipaddress]:[port]
*/
public String getHotrodEndpointConnectionString() {
return getContainerIpAddress() + ":" + getMappedPort(StandaloneInfinispanContainer.InfinispanEndpoints.HOTROD.protocolPort);
}
/**
* Retrieve a preconfigured {@link org.infinispan.client.hotrod.RemoteCacheManager}.
*
* @return A cacheManager
*/
public RemoteCacheManager getCacheManager() {
return cacheManager;
}
protected ProtocolVersion getProtocolVersion() {
return protocolVersion != null ? protocolVersion : ProtocolVersion.PROTOCOL_VERSION_26;
}
protected String getInfinispanServerVersion() {
return infinispanServerVersion;
}
/** /**
* Defines caches that should be created after the container has started. * Defines caches that should be created after the container has started.
* *
@ -135,54 +137,52 @@ public abstract class InfinispanContainer<T extends InfinispanContainer<T>> exte
* @return The container itself * @return The container itself
*/ */
public InfinispanContainer withCaches(final Collection<String> cacheNames) { public InfinispanContainer withCaches(final Collection<String> cacheNames) {
if (incompatibleProtocolVersions.contains(protocolVersion)) {
if (isProtocolConflict()) { throw new IllegalArgumentException(
throw new IllegalArgumentException("Programmatic cache creation only works with Hotrod protocol version >= 2.0!"); "You have to use a Hotrod protocol version of 2.0 at least. 1.x can't create caches through the API. " +
"You can still map a configuration file into the container using '.withClasspathResourceMapping()'");
} }
this.cacheNames = cacheNames;
if (isMajorVersionConflict() || isMinorVersionConflict()) {
throw new IllegalStateException("Programmatic cache creation only works with InfinispanServer version >= 9.1.0!");
}
this.cacheNames.clear();
this.cacheNames.addAll(cacheNames);
return this; return this;
} }
@Override @Override
protected void containerIsStarted(final InspectContainerResponse containerInfo) { protected void containerIsStarted(final InspectContainerResponse containerInfo) {
cacheManager = new RemoteCacheManager(getCacheManagerConfiguration()); cacheManager = new RemoteCacheManager(new ConfigurationBuilder()
if (cacheManager == null) {
throw new IllegalStateException("Couldn't instantiate cacheManager");
}
this.cacheNames.forEach(this::createCache);
}
private Configuration getCacheManagerConfiguration() {
ConfigurationBuilder configBuilder = new ConfigurationBuilder()
.addServers(getHotrodEndpointConnectionString()) .addServers(getHotrodEndpointConnectionString())
.version(getProtocolVersion()); .version(getProtocolVersion())
getTransportFactory().ifPresent(transportFactory -> { .build());
configBuilder.transportFactory(transportFactory);
}); this.cacheNames.forEach(cacheName -> cacheManager.administration().createCache(cacheName, null));
return configBuilder.build();
} }
private void createCache(final String cacheName) { @Override
try { protected void finished(final Description description) {
getCacheManager().administration().createCache(cacheName, null); if (cacheManager != null) {
} catch (HotRodClientException e) { cacheManager.stop();
logger().error("Couldn't create cache '{}'", cacheName, e);
} }
super.finished(description);
}
private ProtocolVersion getProtocolVersion() {
return protocolVersion != null ? protocolVersion : ProtocolVersion.PROTOCOL_VERSION_26;
} }
/** /**
* Overload this method to use a custom {@link TransportFactory}. * Retrieve the Hotrod endpoint address used to connect to the Infinispan instance inside the container.
* *
* @return * @return A String of the format [ipaddress]:[port]
*/ */
protected Optional<Class<? extends TransportFactory>> getTransportFactory() { public String getHotrodEndpointConnectionString() {
return Optional.empty(); return getContainerIpAddress() + ":" + getMappedPort(InfinispanEndpoints.HOTROD.protocolPort);
} }
/**
* Retrieve a preconfigured {@link org.infinispan.client.hotrod.RemoteCacheManager}.
*
* @return A cacheManager
*/
public RemoteCacheManager getCacheManager() {
return cacheManager;
}
} }

View file

@ -1,96 +0,0 @@
package de.rpr.testcontainers.infinispan;
import com.github.dockerjava.api.command.InspectContainerResponse;
import org.infinispan.client.hotrod.ProtocolVersion;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.testcontainers.containers.BindMode;
import java.util.*;
import java.util.stream.IntStream;
/**
* An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be
* used to easily instantiate an Infinispan server for integration tests.
*
* @param <SELF>
*/
@SuppressWarnings("ALL")
public class StandaloneInfinispanContainer extends InfinispanContainer {
private static final String IMAGE_NAME = "jboss/infinispan-server";
private static final String STANDALONE_MODE_CMD = "standalone";
/**
* Construct an instance using the latest Infinispan image version.
*/
public StandaloneInfinispanContainer() {
this(IMAGE_NAME + ":latest");
}
/**
* Construct n instance using the specifice image name.
*
* @param imageName The image name, must contain a version reference
*/
public StandaloneInfinispanContainer(final String imageName) {
super(imageName);
this.withCommand(STANDALONE_MODE_CMD);
}
/**
* Overloading, because we want to make sure that the "standalone" command is always present.
* <p>
* The {@link org.testcontainers.containers.GenericContainer#setCommand} method splits on empty string.
* In order to avoid dependency of that behaviour, we set the cmd first, then getting the commandParts
* and ensuring that it contains the "standalone" command.
* </p>
*
* @param cmd The command(s) to set. {@link org.testcontainers.containers.GenericContainer#setCommand}
* @return The container instance
*/
@Override
public StandaloneInfinispanContainer withCommand(String cmd) {
super.setCommand(cmd);
this.withCommand(ensureStandaloneCommand(getCommandParts()));
return this;
}
/**
* Overloading, because we want to make sure that the "standalone" command is always present.
*
* @param cmd
* @return
*/
@Override
public StandaloneInfinispanContainer withCommand(String... commandParts) {
this.setCommand(ensureStandaloneCommand(commandParts));
return this;
}
private String[] ensureStandaloneCommand(final String[] commandParts) {
List<String> commands = Arrays.asList(commandParts);
if (commands.contains(STANDALONE_MODE_CMD)) {
return commands.toArray(new String[0]);
} else {
commands.add(STANDALONE_MODE_CMD);
return commands.toArray(new String[0]);
}
}
/**
* Links a configuration file for a standalone Infinispan server into the container. The configuration file format needs to match the server version.
*
* @param filenameFromClasspath The filename containing the standalone configuration.
* @return The container itself
*/
public StandaloneInfinispanContainer withStandaloneConfiguration(final String filenameFromClasspath) {
return (StandaloneInfinispanContainer) withClasspathResourceMapping(
filenameFromClasspath,
"/opt/jboss/infinispan-server/standalone/configuration/standalone.xml",
BindMode.READ_ONLY);
}
}

View file

@ -1,23 +0,0 @@
package de.rpr.testcontainers.infinispan.transport;
import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.SocketAddress;
import java.util.Collection;
/**
* This is a subclass of the {@link TcpTransportFactory}. It overwrites the {@link TcpTransportFactory#updateServers(Collection, byte[], boolean)}
* in order to suppress the update of the cluster nodes, communicated back to the client during the Hotrod Topology State Transfer.
*/
public class DisabledTopologyStateTransferTransportFactory extends TcpTransportFactory {
private static final Logger LOG = LoggerFactory.getLogger(DisabledTopologyStateTransferTransportFactory.class);
@Override
public void updateServers(final Collection<SocketAddress> newServers, final byte[] cacheName, final boolean quiet) {
LOG.info("Receiving new Servers: {}. Ignoring...", newServers);
}
}

View file

@ -10,10 +10,7 @@ import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.LogMessageWaitStrategy; import org.testcontainers.containers.wait.LogMessageWaitStrategy;
import java.time.Duration; import java.time.Duration;
import java.util.concurrent.ExecutorService; import java.util.concurrent.*;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;

View file

@ -1,17 +1,21 @@
import de.rpr.testcontainers.infinispan.InfinispanContainer; import de.rpr.testcontainers.infinispan.InfinispanContainer;
import de.rpr.testcontainers.infinispan.StandaloneInfinispanContainer;
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 Infinispan90xContainerIntegrationTest { public class Infinispan90xContainerIntegrationTest {
@ClassRule @ClassRule
public static InfinispanContainer infinispan = new StandaloneInfinispanContainer("jboss/infinispan-server:9.0.3.Final") public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.0.3.Final")
.withStandaloneConfiguration("infinispan-90x-standalone.xml") .withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26); .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

@ -1,26 +0,0 @@
import de.rpr.testcontainers.infinispan.ClusteredInfinispanContainer;
import de.rpr.testcontainers.infinispan.InfinispanContainer;
import org.infinispan.client.hotrod.ProtocolVersion;
import org.junit.ClassRule;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class Infinispan91xClusteredContainerIntegrationTest {
@ClassRule
public static InfinispanContainer infinispan =
new ClusteredInfinispanContainer("jboss/infinispan-server:9.1.4.Final")
.withCaches("testCache")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_20);
@Test
public void rule_should_have_mapped_hotrod_port() {
assertNotNull(infinispan.getMappedPort(11222));
}
@Test
public void should_get_existing_cache() {
assertNotNull(infinispan.getCacheManager().getCache("testCache"));
}
}

View file

@ -1,26 +0,0 @@
import de.rpr.testcontainers.infinispan.ClusteredInfinispanContainer;
import de.rpr.testcontainers.infinispan.InfinispanContainer;
import org.infinispan.client.hotrod.ProtocolVersion;
import org.junit.ClassRule;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class Infinispan91xClusteredContainerXmlConfigIntegrationTest {
@ClassRule
public static InfinispanContainer infinispan =
new ClusteredInfinispanContainer("jboss/infinispan-server:9.1.4.Final")
.withClusteredConfiguration("infinispan-91x-clustered.xml")
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_20);
@Test
public void rule_should_have_mapped_hotrod_port() {
assertNotNull(infinispan.getMappedPort(11222));
}
@Test
public void should_get_existing_cache() {
assertNotNull(infinispan.getCacheManager().getCache("testCache"));
}
}

View file

@ -1,5 +1,4 @@
import de.rpr.testcontainers.infinispan.InfinispanContainer; import de.rpr.testcontainers.infinispan.InfinispanContainer;
import de.rpr.testcontainers.infinispan.StandaloneInfinispanContainer;
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;
@ -9,10 +8,9 @@ import static org.junit.Assert.assertNotNull;
public class Infinispan91xContainerIntegrationTest { public class Infinispan91xContainerIntegrationTest {
@ClassRule @ClassRule
public static InfinispanContainer infinispan = public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final")
new StandaloneInfinispanContainer("jboss/infinispan-server:9.1.4.Final") .withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
.withCaches("testCache") .withCaches("testCache");
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_20);
@Test @Test
public void rule_should_have_mapped_hotrod_port() { public void rule_should_have_mapped_hotrod_port() {

View file

@ -1,347 +0,0 @@
<?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.jgroups.extension"/>
<extension module="org.wildfly.extension.io"/>
</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:infinispan:server:core:9.0" default-cache-container="clustered">
<cache-container name="clustered" default-cache="testCache" statistics="true">
<transport lock-timeout="60000"/>
<global-state/>
<distributed-cache name="testCache"/>
</cache-container>
</subsystem>
<subsystem xmlns="urn:infinispan:server:endpoint:9.0">
<hotrod-connector socket-binding="hotrod" cache-container="clustered">
<topology-state-transfer lazy-retrieval="false" lock-timeout="1000" replication-timeout="5000"/>
</hotrod-connector>
<rest-connector socket-binding="rest" cache-container="clustered">
<authentication security-realm="ApplicationRealm" auth-method="BASIC"/>
</rest-connector>
</subsystem>
<subsystem xmlns="urn:infinispan:server:jgroups:9.0">
<channels default="cluster">
<channel name="cluster"/>
</channels>
<stacks default="${jboss.default.jgroups.stack:udp}">
<stack name="udp">
<transport type="UDP" socket-binding="jgroups-udp"/>
<protocol type="PING"/>
<protocol type="MERGE3"/>
<protocol type="FD_SOCK" socket-binding="jgroups-udp-fd"/>
<protocol type="FD_ALL"/>
<protocol type="VERIFY_SUSPECT"/>
<protocol type="pbcast.NAKACK2"/>
<protocol type="UNICAST3"/>
<protocol type="pbcast.STABLE"/>
<protocol type="pbcast.GMS"/>
<protocol type="UFC"/>
<protocol type="MFC"/>
<protocol type="FRAG3"/>
</stack>
<stack name="tcp">
<transport type="TCP" socket-binding="jgroups-tcp"/>
<protocol type="MPING" socket-binding="jgroups-mping"/>
<protocol type="MERGE3"/>
<protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
<protocol type="FD_ALL"/>
<protocol type="VERIFY_SUSPECT"/>
<protocol type="pbcast.NAKACK2">
<property name="use_mcast_xmit">false</property>
</protocol>
<protocol type="UNICAST3"/>
<protocol type="pbcast.STABLE"/>
<protocol type="pbcast.GMS"/>
<protocol type="MFC"/>
<protocol type="FRAG3"/>
</stack>
<stack name="tcp-gossip">
<transport type="TCP" socket-binding="jgroups-tcp"/>
<protocol type="TCPGOSSIP">
<property name="initial_hosts">${jgroups.gossip.initial_hosts:}</property>
</protocol>
<protocol type="MERGE3"/>
<protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
<protocol type="FD_ALL"/>
<protocol type="VERIFY_SUSPECT"/>
<protocol type="pbcast.NAKACK2">
<property name="use_mcast_xmit">false</property>
</protocol>
<protocol type="UNICAST3"/>
<protocol type="pbcast.STABLE"/>
<protocol type="pbcast.GMS"/>
<protocol type="MFC"/>
<protocol type="FRAG3"/>
</stack>
</stacks>
</subsystem>
<subsystem xmlns="urn:jboss:domain:io:1.1">
<worker name="default"/>
<buffer-pool name="default"/>
</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: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="jgroups-mping" port="0" multicast-address="${jboss.default.multicast.address:234.99.54.14}"
multicast-port="45700"/>
<socket-binding name="jgroups-tcp" port="7600"/>
<socket-binding name="jgroups-tcp-fd" port="57600"/>
<socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:234.99.54.14}"
multicast-port="45688"/>
<socket-binding name="jgroups-udp-fd" port="54200"/>
<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>