Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-9.4.x-56…
Browse files Browse the repository at this point in the history
…75-update-osgi-test-deps
  • Loading branch information
janbartel committed Nov 17, 2020
2 parents bdb4dd4 + 1d71cab commit c8af99e
Show file tree
Hide file tree
Showing 29 changed files with 232 additions and 48 deletions.
8 changes: 4 additions & 4 deletions Jenkinsfile
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 -T3 -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
18 changes: 14 additions & 4 deletions aggregates/jetty-all-compact3/pom.xml
Expand Up @@ -37,7 +37,7 @@
<configuration>
<excludes>**/MANIFEST.MF,javax/**</excludes>
<excludeArtifactIds>javax,jetty-test-helper</excludeArtifactIds>
<excludeGroupIds>javax,org.eclipse.jetty.orbit,org.slf4j,org.ow2.asm,org.junit</excludeGroupIds>
<excludeGroupIds>javax,org.eclipse.jetty.orbit,org.slf4j,org.ow2.asm,org.junit,org.apiguardian,org.opentest4j,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
Expand All @@ -51,13 +51,23 @@
</goals>
<configuration>
<classifier>sources</classifier>
<includes>**/*</includes>
<includes>org/eclipse/jetty/**</includes>
<excludes>
META-INF/**, **/Servlet3Continuation*, **/Jetty6Continuation*, **/AppContextLeakPreventer*.java, **/AWTLeakPreventer*.java, **/IntrospectorCleaner*.java, **/PostConstructAnnotationHandler*.java, **/PreDestroyAnnotationHandler*.java, **/ResourceAnnotationHandler*.java, **/ResourcesAnnotationHandler*.java
META-INF/**,
**/module-info.class,
**/Servlet3Continuation*,
**/Jetty6Continuation*,
**/AppContextLeakPreventer*.java,
**/AWTLeakPreventer*.java,
**/IntrospectorCleaner*.java,
**/PostConstructAnnotationHandler*.java,
**/PreDestroyAnnotationHandler*.java,
**/ResourceAnnotationHandler*.java,
**/ResourcesAnnotationHandler*.java
</excludes>
<includeGroupIds>org.eclipse.jetty,org.eclipse.jetty.websocket</includeGroupIds>
<excludeArtifactIds>javax,jetty-test-helper</excludeArtifactIds>
<excludeGroupIds>javax,org.eclipse.jetty.orbit,org.slf4j,org.ow2.asm,org.junit</excludeGroupIds>
<excludeGroupIds>javax,org.eclipse.jetty.orbit,org.slf4j,org.ow2.asm,org.junit,org.apiguardian,org.opentest4j,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/sources</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
Expand Down
Expand Up @@ -562,7 +562,13 @@ protected Origin createOrigin(String scheme, String host, int port, Object tag)
return new Origin(scheme, host, port, tag);
}

protected HttpDestination resolveDestination(Origin origin)
/**
* <p>Returns, creating it if absent, the destination with the given origin.</p>
*
* @param origin the origin that identifies the destination
* @return the destination for the given origin
*/
public HttpDestination resolveDestination(Origin origin)
{
return destinations.computeIfAbsent(origin, o ->
{
Expand Down
Expand Up @@ -120,7 +120,13 @@ protected void normalizeRequest(Request request)
if (version.getVersion() <= 11)
{
if (!headers.containsKey(HttpHeader.HOST.asString()))
headers.put(getHttpDestination().getHostField());
{
URI uri = request.getURI();
if (uri != null)
headers.put(HttpHeader.HOST, uri.getAuthority());
else
headers.put(getHttpDestination().getHostField());
}
}

// Add content headers
Expand Down
Expand Up @@ -253,15 +253,13 @@ public void failed(Throwable x)
abort(x);
}

public void send(Request request, Response.CompleteListener listener)
{
((HttpRequest)request).sendAsync(this, listener);
}

protected void send(HttpRequest request, List<Response.ResponseListener> listeners)
{
if (!getScheme().equalsIgnoreCase(request.getScheme()))
throw new IllegalArgumentException("Invalid request scheme " + request.getScheme() + " for destination " + this);
if (!getHost().equalsIgnoreCase(request.getHost()))
throw new IllegalArgumentException("Invalid request host " + request.getHost() + " for destination " + this);
int port = request.getPort();
if (port >= 0 && getPort() != port)
throw new IllegalArgumentException("Invalid request port " + port + " for destination " + this);
send(new HttpExchange(this, request, listeners));
}

Expand Down
Expand Up @@ -40,6 +40,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.LongConsumer;
import java.util.function.Supplier;
Expand Down Expand Up @@ -722,7 +723,7 @@ public Request timeout(long timeout, TimeUnit unit)
public ContentResponse send() throws InterruptedException, TimeoutException, ExecutionException
{
FutureResponseListener listener = new FutureResponseListener(this);
send(this, listener);
send(listener);

try
{
Expand Down Expand Up @@ -761,15 +762,20 @@ public ContentResponse send() throws InterruptedException, TimeoutException, Exe
@Override
public void send(Response.CompleteListener listener)
{
send(this, listener);
sendAsync(client::send, listener);
}

private void send(HttpRequest request, Response.CompleteListener listener)
void sendAsync(HttpDestination destination, Response.CompleteListener listener)
{
sendAsync(destination::send, listener);
}

private void sendAsync(BiConsumer<HttpRequest, List<Response.ResponseListener>> sender, Response.CompleteListener listener)
{
if (listener != null)
responseListeners.add(listener);
sent();
client.send(request, responseListeners);
sender.accept(this, responseListeners);
}

void sent()
Expand Down
Expand Up @@ -164,8 +164,15 @@ public void selected(String s)
encrypted.flip();
}
assertEquals(21, encrypted.get());
// TLS 1.3 may send 2 alerts: "user_canceled" followed by "close_notify".
encrypted.clear();
assertEquals(-1, channel.read(encrypted));
read = channel.read(encrypted);
if (read > 0)
{
encrypted.clear();
read = channel.read(encrypted);
}
assertEquals(-1, read);
}
}

Expand Down
Expand Up @@ -333,10 +333,11 @@ public SslAttributes(Request request, SSLSession sslSession, Attributes attribut

try
{
_certs = getSslSessionData().getCerts();
SslSessionData sslSessionData = getSslSessionData();
_certs = sslSessionData.getCerts();
_cipherSuite = _session.getCipherSuite();
_keySize = getSslSessionData().getKeySize();
_sessionId = getSslSessionData().getIdStr();
_keySize = sslSessionData.getKeySize();
_sessionId = sslSessionData.getIdStr();
_sessionAttribute = getSslSessionAttribute();
}
catch (Exception e)
Expand Down
Expand Up @@ -36,6 +36,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.client.HttpDestination;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Destination;
import org.eclipse.jetty.client.api.Response;
Expand All @@ -44,7 +46,9 @@
import org.eclipse.jetty.client.util.InputStreamResponseListener;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http2.FlowControlStrategy;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
Expand Down Expand Up @@ -733,6 +737,46 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
assertEquals(1, scenario.client.getDestinations().size());
}

@ParameterizedTest
@ArgumentsSource(TransportProvider.class)
public void testRequestWithDifferentDestination(Transport transport) throws Exception
{
init(transport);

String requestScheme = HttpScheme.HTTPS.is(scenario.getScheme()) ? "http" : "https";
String requestHost = "otherHost.com";
int requestPort = 8888;
scenario.start(new EmptyServerHandler()
{
@Override
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
{
HttpURI uri = jettyRequest.getHttpURI();
assertEquals(requestHost, uri.getHost());
assertEquals(requestPort, uri.getPort());
if (scenario.transport == Transport.H2C || scenario.transport == Transport.H2)
assertEquals(requestScheme, request.getScheme());
}
});

Origin origin = new Origin(scenario.getScheme(), "localhost", scenario.getNetworkConnectorLocalPortInt().get());
HttpDestination destination = scenario.client.resolveDestination(origin);

org.eclipse.jetty.client.api.Request request = scenario.client.newRequest(requestHost, requestPort)
.scheme(requestScheme)
.path("/path");

CountDownLatch resultLatch = new CountDownLatch(1);
destination.send(request, result ->
{
assertTrue(result.isSucceeded());
assertEquals(HttpStatus.OK_200, result.getResponse().getStatus());
resultLatch.countDown();
});

assertTrue(resultLatch.await(5, TimeUnit.SECONDS));
}

private void sleep(long time) throws IOException
{
try
Expand Down
26 changes: 21 additions & 5 deletions tests/test-sessions/test-gcloud-sessions/pom.xml
Expand Up @@ -61,6 +61,27 @@
<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>junit-jupiter</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>
Expand All @@ -78,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>
Expand Up @@ -23,10 +23,12 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
* ClusteredOrphanedSessionTest
*/
@Testcontainers(disabledWithoutDocker = true)
public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest
{

Expand Down
Expand Up @@ -22,10 +22,12 @@
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
* ClusteredSessionScavengingTest
*/
@Testcontainers(disabledWithoutDocker = true)
public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest
{

Expand Down
Expand Up @@ -24,10 +24,12 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
* GCloudSessionDataStoreTest
*/
@Testcontainers(disabledWithoutDocker = true)
public class GCloudSessionDataStoreTest extends AbstractSessionDataStoreTest
{

Expand Down

0 comments on commit c8af99e

Please sign in to comment.