Enable running Infinispan in clustered mode
This commit is contained in:
parent
a696af771b
commit
097862b30a
10 changed files with 680 additions and 148 deletions
|
@ -0,0 +1,57 @@
|
|||
package de.rpr.testcontainers.infinispan;
|
||||
|
||||
import de.rpr.testcontainers.infinispan.transport.NoTopologyStateTransferTransportFactory;
|
||||
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(NoTopologyStateTransferTransportFactory.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);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,41 +3,19 @@ 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.Configuration;
|
||||
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.testcontainers.containers.BindMode;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.wait.Wait;
|
||||
|
||||
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 InfinispanContainer extends GenericContainer<InfinispanContainer> {
|
||||
|
||||
private static final String IMAGE_NAME = "jboss/infinispan-server";
|
||||
public static final String STANDALONE_MODE_CMD = "standalone";
|
||||
private final String infinispanServerVersion;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
public abstract class InfinispanContainer<T extends InfinispanContainer<T>> extends GenericContainer<T> {
|
||||
|
||||
private static final Set<ProtocolVersion> incompatibleProtocolVersions = new HashSet<>();
|
||||
|
||||
|
@ -48,79 +26,98 @@ public class InfinispanContainer extends GenericContainer<InfinispanContainer> {
|
|||
incompatibleProtocolVersions.add(ProtocolVersion.PROTOCOL_VERSION_13);
|
||||
}
|
||||
|
||||
private ProtocolVersion protocolVersion;
|
||||
private Collection<String> cacheNames = new ArrayList<>();
|
||||
|
||||
private RemoteCacheManager cacheManager;
|
||||
|
||||
/**
|
||||
* Construct an instance using the latest Infinispan image version.
|
||||
/*
|
||||
* An enumeration of the endpoints provided by Infinispan, that this container provides access to.
|
||||
*/
|
||||
public InfinispanContainer() {
|
||||
this(IMAGE_NAME + ":latest");
|
||||
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 boolean isProtocolConflict() {
|
||||
return incompatibleProtocolVersions.contains(getProtocolVersion());
|
||||
}
|
||||
|
||||
private boolean isMajorVersionConflict() {
|
||||
return IntStream.range(1, 8)
|
||||
.anyMatch(majorVersion -> getInfinispanServerVersion().startsWith(Integer.toString(majorVersion)));
|
||||
}
|
||||
|
||||
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) {
|
||||
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())
|
||||
.map(endpoint -> endpoint.getProtocolPort()).toArray(Integer[]::new));
|
||||
|
||||
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) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
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.
|
||||
*
|
||||
|
@ -147,88 +144,45 @@ public class InfinispanContainer extends GenericContainer<InfinispanContainer> {
|
|||
throw new IllegalStateException("Programmatic cache creation only works with InfinispanServer version >= 9.1.0!");
|
||||
}
|
||||
|
||||
this.cacheNames = cacheNames;
|
||||
this.cacheNames.clear();
|
||||
this.cacheNames.addAll(cacheNames);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 InfinispanContainer withStandaloneConfiguration(final String filenameFromClasspath) {
|
||||
return withClasspathResourceMapping(
|
||||
filenameFromClasspath,
|
||||
"/opt/jboss/infinispan-server/standalone/configuration/standalone.xml",
|
||||
BindMode.READ_ONLY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void containerIsStarted(final InspectContainerResponse containerInfo) {
|
||||
cacheManager = new RemoteCacheManager(new ConfigurationBuilder()
|
||||
.addServers(getHotrodEndpointConnectionString())
|
||||
.version(getProtocolVersion())
|
||||
.build());
|
||||
cacheManager = new RemoteCacheManager(getCacheManagerConfiguration());
|
||||
if (cacheManager == null) {
|
||||
throw new IllegalStateException("Couldn't instantiate cacheManager");
|
||||
}
|
||||
this.cacheNames.forEach(this::createCache);
|
||||
}
|
||||
|
||||
private Configuration getCacheManagerConfiguration() {
|
||||
ConfigurationBuilder configBuilder = new ConfigurationBuilder()
|
||||
.addServers(getHotrodEndpointConnectionString())
|
||||
.version(getProtocolVersion());
|
||||
getTransportFactory().ifPresent(transportFactory -> {
|
||||
configBuilder.transportFactory(transportFactory);
|
||||
});
|
||||
return configBuilder.build();
|
||||
}
|
||||
|
||||
private void createCache(final String cacheName) {
|
||||
try {
|
||||
cacheManager.administration().createCache(cacheName, null);
|
||||
getCacheManager().administration().createCache(cacheName, null);
|
||||
} catch (HotRodClientException e) {
|
||||
logger().error("Couldn't create cache '{}'", cacheName, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finished(final Description description) {
|
||||
if (cacheManager != null) {
|
||||
cacheManager.stop();
|
||||
}
|
||||
super.finished(description);
|
||||
}
|
||||
|
||||
private ProtocolVersion getProtocolVersion() {
|
||||
return protocolVersion != null ? protocolVersion : ProtocolVersion.PROTOCOL_VERSION_26;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Hotrod endpoint address used to connect to the Infinispan instance inside the container.
|
||||
* Overload this method to use a custom {@link TransportFactory}.
|
||||
*
|
||||
* @return A String of the format [ipaddress]:[port]
|
||||
* @return
|
||||
*/
|
||||
public String getHotrodEndpointConnectionString() {
|
||||
return getContainerIpAddress() + ":" + getMappedPort(InfinispanEndpoints.HOTROD.protocolPort);
|
||||
protected Optional<Class<? extends TransportFactory>> getTransportFactory() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a preconfigured {@link org.infinispan.client.hotrod.RemoteCacheManager}.
|
||||
*
|
||||
* @return A cacheManager
|
||||
*/
|
||||
public RemoteCacheManager getCacheManager() {
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
private boolean isProtocolConflict() {
|
||||
return incompatibleProtocolVersions.contains(protocolVersion);
|
||||
}
|
||||
|
||||
private boolean isMajorVersionConflict() {
|
||||
return IntStream.range(1, 8)
|
||||
.anyMatch(majorVersion -> infinispanServerVersion.startsWith(Integer.toString(majorVersion)));
|
||||
}
|
||||
|
||||
private boolean isMinorVersionConflict() {
|
||||
boolean minorVersionConflict = false;
|
||||
if (infinispanServerVersion.startsWith("9.0")) {
|
||||
minorVersionConflict = true;
|
||||
}
|
||||
return minorVersionConflict;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
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;
|
||||
|
||||
public class NoTopologyStateTransferTransportFactory extends TcpTransportFactory {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NoTopologyStateTransferTransportFactory.class);
|
||||
|
||||
@Override
|
||||
public void updateServers(final Collection<SocketAddress> newServers, final byte[] cacheName, final boolean quiet) {
|
||||
LOG.info("Receiving new Servers: {}. Ignoring...", newServers);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,10 @@ import org.testcontainers.containers.GenericContainer;
|
|||
import org.testcontainers.containers.wait.LogMessageWaitStrategy;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import de.rpr.testcontainers.infinispan.InfinispanContainer;
|
||||
import de.rpr.testcontainers.infinispan.StandaloneInfinispanContainer;
|
||||
import org.infinispan.client.hotrod.ProtocolVersion;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
@ -8,9 +9,9 @@ import static org.junit.Assert.assertNotNull;
|
|||
public class Infinispan90xContainerIntegrationTest {
|
||||
|
||||
@ClassRule
|
||||
public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.0.3.Final")
|
||||
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26)
|
||||
.withStandaloneConfiguration("infinispan-90x-standalone.xml");
|
||||
public static InfinispanContainer infinispan = new StandaloneInfinispanContainer("jboss/infinispan-server:9.0.3.Final")
|
||||
.withStandaloneConfiguration("infinispan-90x-standalone.xml")
|
||||
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26);
|
||||
|
||||
@Test
|
||||
public void rule_should_have_mapped_hotrod_port() {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
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"));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import de.rpr.testcontainers.infinispan.InfinispanContainer;
|
||||
import de.rpr.testcontainers.infinispan.StandaloneInfinispanContainer;
|
||||
import org.infinispan.client.hotrod.ProtocolVersion;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
@ -8,9 +9,10 @@ import static org.junit.Assert.assertNotNull;
|
|||
public class Infinispan91xContainerIntegrationTest {
|
||||
|
||||
@ClassRule
|
||||
public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.3.Final")
|
||||
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_20)
|
||||
.withCaches("testCache");
|
||||
public static InfinispanContainer infinispan =
|
||||
new StandaloneInfinispanContainer("jboss/infinispan-server:9.1.4.Final")
|
||||
.withCaches("testCache")
|
||||
.withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_20);
|
||||
|
||||
@Test
|
||||
public void rule_should_have_mapped_hotrod_port() {
|
||||
|
|
349
src/test/resources/infinispan-91x-clustered.xml
Normal file
349
src/test/resources/infinispan-91x-clustered.xml
Normal file
|
@ -0,0 +1,349 @@
|
|||
<?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>
|
Loading…
Reference in a new issue