Merge branch 'jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
9c7d36fd51
|
@ -7,12 +7,11 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>infinispan-remote-query</artifactId>
|
||||
<name>Jetty :: Infinispan Session Manager Remote with Querying</name>
|
||||
<url>http://www.eclipse.org/jetty</url>
|
||||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.infinispan.remote.query</bundle-symbolic-name>
|
||||
<infinispan.docker.image.version>9.4.8.Final</infinispan.docker.image.version>
|
||||
</properties>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -127,10 +126,20 @@
|
|||
<artifactId>infinispan-remote-query-client</artifactId>
|
||||
<version>${infinispan.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>remote</id>
|
||||
<id>remote-session-tests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>hotrod.enabled</name>
|
||||
|
@ -144,6 +153,9 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>false</skipTests>
|
||||
<systemPropertyVariables>
|
||||
<infinispan.docker.image.version>${infinispan.docker.image.version}</infinispan.docker.image.version>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.server.session.SessionData;
|
||||
import org.eclipse.jetty.session.infinispan.InfinispanSessionData;
|
||||
import org.eclipse.jetty.session.infinispan.QueryManager;
|
||||
import org.eclipse.jetty.session.infinispan.RemoteQueryManager;
|
||||
import org.eclipse.jetty.session.infinispan.SessionDataMarshaller;
|
||||
|
@ -35,11 +36,23 @@ import org.hibernate.search.cfg.Environment;
|
|||
import org.hibernate.search.cfg.SearchMapping;
|
||||
import org.infinispan.client.hotrod.RemoteCache;
|
||||
import org.infinispan.client.hotrod.RemoteCacheManager;
|
||||
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
|
||||
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.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.output.Slf4jLogConsumer;
|
||||
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
|
||||
import org.testcontainers.utility.MountableFile;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -49,8 +62,45 @@ public class RemoteQueryManagerTest
|
|||
{
|
||||
public static final String DEFAULT_CACHE_NAME = "remote-session-test";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RemoteQueryManagerTest.class);
|
||||
|
||||
private static final Logger INFINISPAN_LOG =
|
||||
LoggerFactory.getLogger("org.eclipse.jetty.server.session.infinispan.infinispanLogs");
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
GenericContainer infinispan =
|
||||
new GenericContainer(System.getProperty("infinispan.docker.image.name", "jboss/infinispan-server") +
|
||||
":" + System.getProperty("infinispan.docker.image.version", "9.4.8.Final"))
|
||||
.withEnv("APP_USER","theuser")
|
||||
.withEnv("APP_PASS","foobar")
|
||||
.withEnv("MGMT_USER", "admin")
|
||||
.withEnv("MGMT_PASS", "admin")
|
||||
.waitingFor(new LogMessageWaitStrategy()
|
||||
.withRegEx(".*Infinispan Server.*started in.*\\s"))
|
||||
.withExposedPorts(4712,4713,8088,8089,8443,9990,9993,11211,11222,11223,11224)
|
||||
.withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG));
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
infinispan.start();
|
||||
host = infinispan.getContainerIpAddress();
|
||||
port = infinispan.getMappedPort(11222);
|
||||
LOG.info("Infinispan container started for {}:{} - {}ms", host, port,
|
||||
System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void stop() throws Exception
|
||||
{
|
||||
infinispan.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception
|
||||
public void testQuery() throws Exception
|
||||
{
|
||||
SearchMapping mapping = new SearchMapping();
|
||||
mapping.entity(SessionData.class).indexed().providedId().property("expiry", ElementType.FIELD).field();
|
||||
|
@ -59,9 +109,13 @@ public class RemoteQueryManagerTest
|
|||
properties.put(Environment.MODEL_MAPPING, mapping);
|
||||
|
||||
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
|
||||
clientBuilder.withProperties(properties).addServer().host("127.0.0.1").marshaller(new ProtoStreamMarshaller());
|
||||
clientBuilder.withProperties(properties).addServer()
|
||||
.host(this.host).port(this.port)
|
||||
.clientIntelligence(ClientIntelligence.BASIC)
|
||||
.marshaller(new ProtoStreamMarshaller());
|
||||
|
||||
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
|
||||
remoteCacheManager.administration().getOrCreateCache("remote-session-test", (String)null);
|
||||
|
||||
FileDescriptorSource fds = new FileDescriptorSource();
|
||||
fds.addProtoFiles("/session.proto");
|
||||
|
@ -70,20 +124,17 @@ public class RemoteQueryManagerTest
|
|||
serCtx.registerProtoFiles(fds);
|
||||
serCtx.registerMarshaller(new SessionDataMarshaller());
|
||||
|
||||
RemoteCache<String, SessionData> cache = remoteCacheManager.getCache(DEFAULT_CACHE_NAME);
|
||||
|
||||
ByteArrayOutputStream baos;
|
||||
try (InputStream is = RemoteQueryManagerTest.class.getClassLoader().getResourceAsStream("session.proto"))
|
||||
try (InputStream is = RemoteQueryManagerTest.class.getClassLoader().getResourceAsStream("session.proto");
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream())
|
||||
{
|
||||
if (is == null)
|
||||
throw new IllegalStateException("inputstream is null");
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
IO.copy(is, baos);
|
||||
String content = baos.toString("UTF-8");
|
||||
remoteCacheManager.getCache("___protobuf_metadata").put("session.proto", content);
|
||||
}
|
||||
|
||||
String content = baos.toString("UTF-8");
|
||||
remoteCacheManager.getCache("___protobuf_metadata").put("session.proto", content);
|
||||
RemoteCache<String, SessionData> cache = remoteCacheManager.getCache(DEFAULT_CACHE_NAME);
|
||||
|
||||
//put some sessions into the remote cache
|
||||
int numSessions = 10;
|
||||
|
@ -97,7 +148,7 @@ public class RemoteQueryManagerTest
|
|||
String id = "sd" + i;
|
||||
//create new sessiondata with random expiry time
|
||||
long expiryTime = r.nextInt(maxExpiryTime);
|
||||
SessionData sd = new SessionData(id, "", "", 0, 0, 0, 0);
|
||||
InfinispanSessionData sd = new InfinispanSessionData(id, "", "", 0, 0, 0, 0);
|
||||
sd.setLastNode("lastNode");
|
||||
sd.setExpiry(expiryTime);
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
org.slf4j.simpleLogger.defaultLogLevel=info
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.infinispan.infinispanLogs=debug
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.infinispan.RemoteQueryManagerTest=debug
|
6
pom.xml
6
pom.xml
|
@ -1103,6 +1103,12 @@
|
|||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging</artifactId>
|
||||
|
|
|
@ -109,7 +109,6 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
<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 -->
|
||||
<infinispan.docker.image.version>${infinispan.version}</infinispan.docker.image.version>
|
||||
<!-- from 10.xx it has changed to jboss/infinispan -->
|
||||
<infinispan.docker.image.name>jboss/infinispan-server</infinispan.docker.image.name>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -141,19 +144,23 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-slf4j-impl</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<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>
|
||||
|
@ -166,34 +173,13 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<infinispan.docker.image.version>${infinispan.docker.image.version}</infinispan.docker.image.version>
|
||||
<infinispan.docker.image.name>${infinispan.docker.image.name}</infinispan.docker.image.name>
|
||||
</systemPropertyVariables>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/ClusteredSessionScavengingTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>alltests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>alltests</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>FOOBAR</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* InfinispanSessionDataStoreTest
|
||||
|
@ -110,15 +110,7 @@ public class InfinispanSessionDataStoreTest extends AbstractSessionDataStoreTest
|
|||
((InfinispanSessionDataStore)store).setCache(null);
|
||||
|
||||
//test that loading it fails
|
||||
try
|
||||
{
|
||||
store.load("222");
|
||||
fail("Session should be unreadable");
|
||||
}
|
||||
catch (UnreadableSessionDataException e)
|
||||
{
|
||||
//expected exception
|
||||
}
|
||||
assertThrows(UnreadableSessionDataException.class, () -> store.load("222"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* SerializedInfinispanSessionDataStoreTest
|
||||
|
@ -107,15 +107,7 @@ public class SerializedInfinispanSessionDataStoreTest extends AbstractSessionDat
|
|||
((InfinispanSessionDataStore)store).setCache(null);
|
||||
|
||||
//test that loading it fails
|
||||
try
|
||||
{
|
||||
store.load("222");
|
||||
fail("Session should be unreadable");
|
||||
}
|
||||
catch (UnreadableSessionDataException e)
|
||||
{
|
||||
//expected exception
|
||||
}
|
||||
assertThrows(UnreadableSessionDataException.class,() -> store.load("222"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* RemoteInfinispanSessionDataStoreTest
|
||||
|
@ -135,15 +135,7 @@ public class RemoteInfinispanSessionDataStoreTest extends AbstractSessionDataSto
|
|||
((InfinispanSessionDataStore)store).setCache(null);
|
||||
|
||||
//test that loading it fails
|
||||
try
|
||||
{
|
||||
store.load("222");
|
||||
fail("Session should be unreadable");
|
||||
}
|
||||
catch (UnreadableSessionDataException e)
|
||||
{
|
||||
//expected exception
|
||||
}
|
||||
assertThrows(UnreadableSessionDataException.class, () -> store.load("222"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,31 +31,62 @@ import org.hibernate.search.cfg.Environment;
|
|||
import org.hibernate.search.cfg.SearchMapping;
|
||||
import org.infinispan.client.hotrod.RemoteCache;
|
||||
import org.infinispan.client.hotrod.RemoteCacheManager;
|
||||
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
|
||||
import org.infinispan.client.hotrod.configuration.Configuration;
|
||||
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 org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
|
||||
import org.testcontainers.utility.MountableFile;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* RemoteInfinispanTestSupport
|
||||
*/
|
||||
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;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
String host = System.getProperty("hotrod.host", "127.0.0.1");
|
||||
//Testcontainers.exposeHostPorts(11222);
|
||||
long start = System.currentTimeMillis();
|
||||
String infinispanVersion = System.getProperty("infinispan.docker.image.version", "9.4.8.Final");
|
||||
infinispan =
|
||||
new GenericContainer(System.getProperty("infinispan.docker.image.name", "jboss/infinispan-server") +
|
||||
":" + infinispanVersion)
|
||||
.withEnv("APP_USER","theuser")
|
||||
.withEnv("APP_PASS","foobar")
|
||||
.withEnv("MGMT_USER", "admin")
|
||||
.withEnv("MGMT_PASS", "admin")
|
||||
.waitingFor(new LogMessageWaitStrategy()
|
||||
.withRegEx(".*Infinispan Server.*started in.*\\s"))
|
||||
.withExposedPorts(4712,4713,8088,8089,8443,9990,9993,11211,11222,11223,11224)
|
||||
.withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG));
|
||||
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();
|
||||
|
@ -63,10 +94,25 @@ public class RemoteInfinispanTestSupport
|
|||
Properties properties = new Properties();
|
||||
properties.put(Environment.MODEL_MAPPING, mapping);
|
||||
|
||||
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
|
||||
clientBuilder.withProperties(properties).addServer().host(host).marshaller(new ProtoStreamMarshaller());
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().withProperties(properties)
|
||||
.addServer().host(host).port(port)
|
||||
// we just want to limit connectivity to list of host:port we knows at start
|
||||
// as infinispan create new host:port dynamically but due to how docker expose host/port we cannot do that
|
||||
.clientIntelligence(ClientIntelligence.BASIC)
|
||||
.marshaller(new ProtoStreamMarshaller());
|
||||
|
||||
_manager = new RemoteCacheManager(clientBuilder.build());
|
||||
if (infinispanVersion.startsWith("1"))
|
||||
{
|
||||
configurationBuilder.security().authentication()
|
||||
.realm("default")
|
||||
.serverName("infinispan")
|
||||
.saslMechanism("DIGEST-MD5")
|
||||
.username("theuser").password("foobar");
|
||||
}
|
||||
|
||||
Configuration configuration = configurationBuilder.build();
|
||||
|
||||
_manager = new RemoteCacheManager(configuration);
|
||||
|
||||
FileDescriptorSource fds = new FileDescriptorSource();
|
||||
fds.addProtoFiles("/session.proto");
|
||||
|
@ -86,11 +132,12 @@ public class RemoteInfinispanTestSupport
|
|||
}
|
||||
|
||||
String content = baos.toString("UTF-8");
|
||||
_manager.getCache("___protobuf_metadata").put("session.proto", content);
|
||||
_manager.administration().getOrCreateCache("___protobuf_metadata", (String)null).put("session.proto", content);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail(e);
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +161,7 @@ public class RemoteInfinispanTestSupport
|
|||
|
||||
public void setup() throws Exception
|
||||
{
|
||||
_cache = _manager.getCache(_name);
|
||||
_cache = _manager.administration().getOrCreateCache(_name,(String)null);
|
||||
}
|
||||
|
||||
public void teardown() throws Exception
|
||||
|
|
|
@ -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