Merge branch 'jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
35ace7787b
|
@ -14,7 +14,7 @@ pipeline {
|
|||
steps {
|
||||
container( 'jetty-build' ) {
|
||||
timeout( time: 120, unit: 'MINUTES' ) {
|
||||
mavenBuild( "jdk11", "-T3 clean install -Premote-session-tests", "maven3", true ) // -Pautobahn
|
||||
mavenBuild( "jdk11", "-T3 clean install -Premote-session-tests -Pgcloud", "maven3", true ) // -Pautobahn
|
||||
// Collect up the jacoco execution results (only on main build)
|
||||
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
|
||||
exclusionPattern: '' +
|
||||
|
@ -39,20 +39,31 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage("Build / Test - JDK15") {
|
||||
agent { node { label 'linux' } }
|
||||
steps {
|
||||
container( 'jetty-build' ) {
|
||||
timeout( time: 120, unit: 'MINUTES' ) {
|
||||
mavenBuild( "jdk15", "-T3 clean install -Premote-session-tests", "maven3", true )
|
||||
mavenBuild( "jdk15", "-T3 clean install -Premote-session-tests -Pgcloud -Djacoco.skip=true", "maven3", true )
|
||||
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
||||
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Build Javadoc") {
|
||||
agent { node { label 'linux' } }
|
||||
steps {
|
||||
container( 'jetty-build' ) {
|
||||
timeout( time: 40, unit: 'MINUTES' ) {
|
||||
mavenBuild( "jdk11",
|
||||
"install javadoc:javadoc -DskipTests -Dpmd.skip=true -Dcheckstyle.skip=true",
|
||||
"maven3", [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,22 @@
|
|||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>gcloud</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
@ -83,15 +99,10 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>false</skipTests>
|
||||
<systemPropertyVariables>
|
||||
<DATASTORE_DATASET>jetty9-work</DATASTORE_DATASET>
|
||||
<DATASTORE_HOST>http://localhost:8088</DATASTORE_HOST>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -20,12 +20,17 @@ package org.eclipse.jetty.gcloud.session;
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.cloud.NoCredentials;
|
||||
import com.google.cloud.ServiceOptions;
|
||||
import com.google.cloud.datastore.Batch;
|
||||
import com.google.cloud.datastore.Blob;
|
||||
import com.google.cloud.datastore.BlobValue;
|
||||
import com.google.cloud.datastore.Datastore;
|
||||
|
@ -38,13 +43,17 @@ import com.google.cloud.datastore.Query;
|
|||
import com.google.cloud.datastore.Query.ResultType;
|
||||
import com.google.cloud.datastore.QueryResults;
|
||||
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
|
||||
import com.google.cloud.datastore.testing.LocalDatastoreHelper;
|
||||
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStore.EntityDataModel;
|
||||
import org.eclipse.jetty.server.session.SessionData;
|
||||
import org.eclipse.jetty.server.session.SessionDataStore;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
|
||||
import org.threeten.bp.Duration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testcontainers.containers.DatastoreEmulatorContainer;
|
||||
import org.testcontainers.containers.output.Slf4jLogConsumer;
|
||||
import org.testcontainers.containers.wait.strategy.Wait;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -55,10 +64,35 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
*/
|
||||
public class GCloudSessionTestSupport
|
||||
{
|
||||
LocalDatastoreHelper _helper = LocalDatastoreHelper.create(1.0);
|
||||
Datastore _ds;
|
||||
KeyFactory _keyFactory;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GCloudSessionTestSupport.class);
|
||||
private static final Logger GCLOUD_LOG = LoggerFactory.getLogger("org.eclipse.jetty.gcloud.session.gcloudLogs");
|
||||
|
||||
public DatastoreEmulatorContainer emulator = new CustomDatastoreEmulatorContainer(
|
||||
DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk:316.0.0-emulators")
|
||||
).withLogConsumer(new Slf4jLogConsumer(GCLOUD_LOG));
|
||||
|
||||
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk");
|
||||
|
||||
private static final String CMD = "gcloud beta emulators datastore start --project test-project --host-port 0.0.0.0:8081 --consistency=1.0";
|
||||
private static final int HTTP_PORT = 8081;
|
||||
|
||||
public static class CustomDatastoreEmulatorContainer extends DatastoreEmulatorContainer
|
||||
{
|
||||
public CustomDatastoreEmulatorContainer(DockerImageName dockerImageName)
|
||||
{
|
||||
super(dockerImageName);
|
||||
|
||||
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
|
||||
|
||||
withExposedPorts(HTTP_PORT);
|
||||
setWaitStrategy(Wait.forHttp("/").forStatusCode(200));
|
||||
withCommand("/bin/sh", "-c", CMD);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestGCloudSessionDataStoreFactory extends GCloudSessionDataStoreFactory
|
||||
{
|
||||
Datastore _d;
|
||||
|
@ -85,15 +119,35 @@ public class GCloudSessionTestSupport
|
|||
|
||||
public GCloudSessionTestSupport()
|
||||
{
|
||||
DatastoreOptions options = _helper.getOptions();
|
||||
_ds = options.getService();
|
||||
_keyFactory = _ds.newKeyFactory().setKind(EntityDataModel.KIND);
|
||||
// no op
|
||||
}
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
_helper.start();
|
||||
emulator.start();
|
||||
String host;
|
||||
//work out if we're running locally or not: if not local, then the host passed to
|
||||
//DatastoreOptions must be prefixed with a scheme
|
||||
String endPoint = emulator.getEmulatorEndpoint();
|
||||
InetAddress hostAddr = InetAddress.getByName(new URL("http://" + endPoint).getHost());
|
||||
LOGGER.info("endPoint: {} ,hostAddr.isAnyLocalAddress(): {},hostAddr.isLoopbackAddress(): {}",
|
||||
endPoint,
|
||||
hostAddr.isAnyLocalAddress(),
|
||||
hostAddr.isLoopbackAddress());
|
||||
if (hostAddr.isAnyLocalAddress() || hostAddr.isLoopbackAddress())
|
||||
host = endPoint;
|
||||
else
|
||||
host = "http://" + endPoint;
|
||||
|
||||
DatastoreOptions options = DatastoreOptions.newBuilder()
|
||||
.setHost(host)
|
||||
.setCredentials(NoCredentials.getInstance())
|
||||
.setRetrySettings(ServiceOptions.getNoRetrySettings())
|
||||
.setProjectId("test-project")
|
||||
.build();
|
||||
_ds = options.getService();
|
||||
_keyFactory = _ds.newKeyFactory().setKind(EntityDataModel.KIND);
|
||||
}
|
||||
|
||||
public Datastore getDatastore()
|
||||
|
@ -104,12 +158,13 @@ public class GCloudSessionTestSupport
|
|||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
_helper.stop(Duration.ofMinutes(1)); //wait up to 1min for shutdown
|
||||
emulator.stop();
|
||||
}
|
||||
|
||||
public void reset() throws Exception
|
||||
{
|
||||
_helper.reset();
|
||||
emulator.stop();
|
||||
this.setUp();
|
||||
}
|
||||
|
||||
public void createSession(String id, String contextPath, String vhost,
|
||||
|
@ -257,12 +312,14 @@ public class GCloudSessionTestSupport
|
|||
QueryResults<Key> results = _ds.run(query);
|
||||
assertNotNull(results);
|
||||
int actual = 0;
|
||||
List<Key> keys = new ArrayList<>();
|
||||
while (results.hasNext())
|
||||
{
|
||||
results.next();
|
||||
Key key = results.next();
|
||||
keys.add(key);
|
||||
++actual;
|
||||
}
|
||||
assertEquals(count, actual);
|
||||
assertEquals(count, actual, "keys found: " + keys);
|
||||
}
|
||||
|
||||
public void deleteSessions() throws Exception
|
||||
|
@ -270,18 +327,21 @@ public class GCloudSessionTestSupport
|
|||
Query<Key> query = Query.newKeyQueryBuilder().setKind(GCloudSessionDataStore.EntityDataModel.KIND).build();
|
||||
QueryResults<Key> results = _ds.run(query);
|
||||
|
||||
Batch batch = _ds.newBatch();
|
||||
|
||||
if (results != null)
|
||||
{
|
||||
List<Key> keys = new ArrayList<Key>();
|
||||
List<Key> keys = new ArrayList<>();
|
||||
|
||||
while (results.hasNext())
|
||||
{
|
||||
keys.add(results.next());
|
||||
}
|
||||
|
||||
_ds.delete(keys.toArray(new Key[keys.size()]));
|
||||
batch.delete(keys.toArray(new Key[keys.size()]));
|
||||
}
|
||||
|
||||
batch.submit();
|
||||
assertSessions(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
org.slf4j.simpleLogger.defaultLogLevel=info
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session=info
|
||||
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session.gcloudLogs=info
|
|
@ -25,8 +25,6 @@ import java.nio.file.Path;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.hibernate.search.cfg.Environment;
|
||||
import org.hibernate.search.cfg.SearchMapping;
|
||||
|
@ -37,7 +35,6 @@ import org.infinispan.configuration.cache.Index;
|
|||
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
|
|
@ -42,7 +42,6 @@ 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;
|
||||
|
|
Loading…
Reference in New Issue