Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "gcloud" profile for gcloud session testing. #5568

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
steps {
container('jetty-build') {
timeout( time: 120, unit: 'MINUTES' ) {
mavenBuild( "jdk8", "clean install -T3 -Premote-session-tests", "maven3",
mavenBuild( "jdk8", "clean install -Premote-session-tests -Pgcloud", "maven3",
[[parserName: 'Maven'], [parserName: 'Java']])
// Collect up the jacoco execution results (only on main build)
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
Expand Down Expand Up @@ -42,7 +42,7 @@ pipeline {
steps {
container( 'jetty-build' ) {
timeout( time: 120, unit: 'MINUTES' ) {
mavenBuild( "jdk11", "clean install -T3 -Djacoco.skip=true -Premote-session-tests", "maven3",
mavenBuild( "jdk11", "clean install -T3 -Djacoco.skip=true -Premote-session-tests -Pgcloud", "maven3",
[[parserName: 'Maven'], [parserName: 'Java']])
}
}
Expand All @@ -54,7 +54,7 @@ pipeline {
steps {
container( 'jetty-build' ) {
timeout( time: 120, unit: 'MINUTES' ) {
mavenBuild( "jdk15", "clean install -T3 -Djacoco.skip=true -Premote-session-tests", "maven3",
mavenBuild( "jdk15", "clean install -T3 -Djacoco.skip=true -Premote-session-tests -Pgcloud", "maven3",
[[parserName: 'Maven'], [parserName: 'Java']])
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ def mavenBuild(jdk, cmdline, mvnName, consoleParsers) {
"MAVEN_OPTS=-Xms2g -Xmx4g -Djava.awt.headless=true"]) {
configFileProvider(
[configFile(fileId: 'oss-settings.xml', variable: 'GLOBAL_MVN_SETTINGS')]) {
sh "mvn -s $GLOBAL_MVN_SETTINGS -Dmaven.repo.local=.repository -Pci -fae -V -B -e -Djetty.testtracker.log=true $cmdline -Dunix.socket.tmp=" +
sh "mvn -s $GLOBAL_MVN_SETTINGS -Dmaven.repo.local=.repository -Pci -V -B -e -Djetty.testtracker.log=true $cmdline -Dunix.socket.tmp=" +
env.JENKINS_HOME
}
}
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@
<failIfNoTests>false</failIfNoTests>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks> <!-- to work around crash at https://github.com/junit-team/junit5/issues/801 -->
<trimStackTrace>false</trimStackTrace>
<systemPropertyVariables>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
<unix.socket.tmp>${unix.socket.tmp}</unix.socket.tmp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
package org.eclipse.jetty.gcloud.session;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
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.Blob;
import com.google.cloud.datastore.BlobValue;
import com.google.cloud.datastore.Datastore;
Expand Down Expand Up @@ -55,7 +61,7 @@
*/
public class GCloudSessionTestSupport
{
LocalDatastoreHelper _helper = LocalDatastoreHelper.create(1.0);
final LocalDatastoreHelper _helper;
Datastore _ds;
KeyFactory _keyFactory;

Expand Down Expand Up @@ -86,9 +92,41 @@ public static GCloudSessionDataStoreFactory newSessionDataStoreFactory(Datastore
return new TestGCloudSessionDataStoreFactory(d);
}

public GCloudSessionTestSupport()
public GCloudSessionTestSupport() throws IOException
{
DatastoreOptions options = _helper.getOptions();
int localPort;
String localHost = InetAddress.getLocalHost().getHostAddress();
//The google code finds a port based on the wildcard interface,
//so we need to do the same here
InetSocketAddress address = new InetSocketAddress(0);
try (ServerSocket server = new ServerSocket())
{
//ensure that a socket in TIME_WAIT can be reused
server.setReuseAddress(true);
server.bind(address);
localPort = server.getLocalPort();
_helper = LocalDatastoreHelper.newBuilder()
.setConsistency(1.0)
.setPort(localPort)
//.setStoreOnDisk(false)
.build();
}
System.out.println("Using datastore emulator port:" + localPort);
System.out.println("Using datastore client port:" + localHost + ":" + localPort);

//DatastoreOptions options = _helper.getOptions();

//Try forcing the local end of connections to the port opened by
//the forked processes run by the LocalDatastoreHelper to use
//an ip address instead of "localhost" (even though the forked
//processes themselves are hardcoded to use "localhost")
//String localHost = InetAddress.getLocalHost().getHostAddress();
DatastoreOptions options = DatastoreOptions.newBuilder()
.setProjectId(_helper.getProjectId())
.setHost("http://" + localHost + ":" + Integer.toString(localPort))
.setCredentials(NoCredentials.getInstance())
.setRetrySettings(ServiceOptions.getNoRetrySettings()).build();

_ds = options.getService();
_keyFactory = _ds.newKeyFactory().setKind(EntityDataModel.KIND);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.gcloud.LEVEL=DEBUG
org.eclipse.jetty.server.session.LEVEL=DEBUG