From 2b39c7e4067a52796bc8b64542785895ecfad79c Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 4 Apr 2019 10:41:50 +1000 Subject: [PATCH] fix some mod files and add a distribution test for unixsocket Signed-off-by: olivier lamy --- .../modules/hazelcast-embedded-sessions.mod | 26 --------- .../modules/hazelcast-remote-sessions.mod | 26 --------- .../session-store-hazelcast-embedded.mod | 4 +- .../session-store-hazelcast-remote.mod | 6 +-- .../jetty-memcached-sessions/pom.xml | 2 +- .../src/main/config/modules/unixsocket.mod | 26 ++++----- tests/test-distribution/pom.xml | 6 +++ .../tests/distribution/DistributionTests.java | 54 +++++++++++++++++++ 8 files changed, 79 insertions(+), 71 deletions(-) delete mode 100644 jetty-hazelcast/src/main/config/modules/hazelcast-embedded-sessions.mod delete mode 100644 jetty-hazelcast/src/main/config/modules/hazelcast-remote-sessions.mod diff --git a/jetty-hazelcast/src/main/config/modules/hazelcast-embedded-sessions.mod b/jetty-hazelcast/src/main/config/modules/hazelcast-embedded-sessions.mod deleted file mode 100644 index 139fe8ff81e..00000000000 --- a/jetty-hazelcast/src/main/config/modules/hazelcast-embedded-sessions.mod +++ /dev/null @@ -1,26 +0,0 @@ -# -# Jetty Hazelcast module -# - -[depend] -annotations -webapp - -[files] -maven://com.hazelcast/hazelcast-all/3.8.2|lib/hazelcast/hazelcast-all-3.8.2.jar -maven://com.hazelcast/hazelcast-jetty9-sessionmanager/1.0.2|lib/hazelcast/hazelcast-jetty9-sessionmanager-1.0.2.jar -maven://org.eclipse.jetty/jetty-nosql/${jetty.version}|lib/hazelcast/jetty-nosql-${jetty.version}.jar - -[xml] -etc/sessions/hazelcast/default.xml - -[lib] -lib/hazelcast/*.jar - -[license] -Hazelcast is an open source project hosted on Github and released under the Apache 2.0 license. -https://hazelcast.org/ -http://www.apache.org/licenses/LICENSE-2.0.html - -[ini-template] -#jetty.session.hazelcast.configurationLocation= diff --git a/jetty-hazelcast/src/main/config/modules/hazelcast-remote-sessions.mod b/jetty-hazelcast/src/main/config/modules/hazelcast-remote-sessions.mod deleted file mode 100644 index 5038684659d..00000000000 --- a/jetty-hazelcast/src/main/config/modules/hazelcast-remote-sessions.mod +++ /dev/null @@ -1,26 +0,0 @@ -# -# Jetty Hazelcast module -# - -[depend] -annotations -webapp - -[files] -maven://com.hazelcast/hazelcast-all/3.8.2|lib/hazelcast/hazelcast-all-3.8.2.jar -maven://com.hazelcast/hazelcast-jetty9-sessionmanager/1.0.2|lib/hazelcast/hazelcast-jetty9-sessionmanager-1.0.2.jar -maven://org.eclipse.jetty/jetty-nosql/${jetty.version}|lib/hazelcast/jetty-nosql-${jetty.version}.jar - -[xml] -etc/sessions/hazelcast/remote.xml - -[lib] -lib/hazelcast/*.jar - -[license] -Hazelcast is an open source project hosted on Github and released under the Apache 2.0 license. -https://hazelcast.org/ -http://www.apache.org/licenses/LICENSE-2.0.html - -[ini-template] -#jetty.session.hazelcast.configurationLocation= diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod index 2263ae0807b..405b5209aaf 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod @@ -13,7 +13,7 @@ session-store sessions [files] -maven://com.hazelcast/hazelcast/3.8.2|lib/hazelcast/hazelcast-3.8.2.jar +maven://com.hazelcast/hazelcast/3.9.3|lib/hazelcast/hazelcast-3.9.3.jar [xml] etc/sessions/hazelcast/default.xml @@ -33,4 +33,4 @@ jetty.session.hazelcast.mapName=jetty-distributed-session-map jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE #jetty.session.hazelcast.configurationLocation= jetty.session.gracePeriod.seconds=3600 -jetty.session.savePeriod.seconds=0 \ No newline at end of file +jetty.session.savePeriod.seconds=0 diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod index c6a26fc7123..29e3a253171 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod @@ -13,8 +13,8 @@ session-store sessions [files] -maven://com.hazelcast/hazelcast/3.8.2|lib/hazelcast/hazelcast-3.8.2.jar -maven://com.hazelcast/hazelcast-client/3.8.2|lib/hazelcast/hazelcast-client-3.8.2.jar +maven://com.hazelcast/hazelcast/3.9.3|lib/hazelcast/hazelcast-3.9.3.jar +maven://com.hazelcast/hazelcast-client/3.9.3|lib/hazelcast/hazelcast-client-3.9.3.jar [xml] etc/sessions/hazelcast/remote.xml @@ -35,4 +35,4 @@ jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE jetty.session.hazelcast.onlyClient=true #jetty.session.hazelcast.configurationLocation= jetty.session.gracePeriod.seconds=3600 -jetty.session.savePeriod.seconds=0 \ No newline at end of file +jetty.session.savePeriod.seconds=0 diff --git a/jetty-memcached/jetty-memcached-sessions/pom.xml b/jetty-memcached/jetty-memcached-sessions/pom.xml index 5172a0ae573..eaee1b0e331 100644 --- a/jetty-memcached/jetty-memcached-sessions/pom.xml +++ b/jetty-memcached/jetty-memcached-sessions/pom.xml @@ -24,7 +24,7 @@ org.slf4j slf4j-simple - 1.7.9 + ${slf4j.version} test diff --git a/jetty-unixsocket/src/main/config/modules/unixsocket.mod b/jetty-unixsocket/src/main/config/modules/unixsocket.mod index 84a45d21831..2045484cb4e 100644 --- a/jetty-unixsocket/src/main/config/modules/unixsocket.mod +++ b/jetty-unixsocket/src/main/config/modules/unixsocket.mod @@ -19,26 +19,26 @@ server etc/jetty-unixsocket.xml [files] -maven://com.github.jnr/jnr-unixsocket/0.8|lib/jnr/jnr-unixsocket-0.8.jar -maven://com.github.jnr/jnr-ffi/2.0.3|lib/jnr/jnr-ffi-2.0.3.jar -maven://com.github.jnr/jffi/1.2.9|lib/jnr/jffi-1.2.9.jar -maven://com.github.jnr/jffi/1.2.9/jar/native|lib/jnr/jffi-1.2.9-native.jar -maven://org.ow2.asm/asm/5.0.1|lib/jnr/asm-5.0.1.jar -maven://org.ow2.asm/asm-commons/5.0.1|lib/jnr/asm-commons-5.0.1.jar -maven://org.ow2.asm/asm-analysis/5.0.3|lib/jnr/asm-analysis-5.0.3.jar -maven://org.ow2.asm/asm-tree/5.0.3|lib/jnr/asm-tree-5.0.3.jar -maven://org.ow2.asm/asm-util/5.0.3|lib/jnr/asm-util-5.0.3.jar +maven://com.github.jnr/jnr-unixsocket/0.20|lib/jnr/jnr-unixsocket-0.20.jar +maven://com.github.jnr/jnr-ffi/2.1.9|lib/jnr/jnr-ffi-2.1.9.jar +maven://com.github.jnr/jffi/1.2.17|lib/jnr/jffi-1.2.17.jar +maven://com.github.jnr/jffi/1.2.16/jar/native|lib/jnr/jffi-1.2.16-native.jar +maven://org.ow2.asm/asm/7.0|lib/jnr/asm-7.0.jar +maven://org.ow2.asm/asm-commons/7.0|lib/jnr/asm-commons-7.0.jar +maven://org.ow2.asm/asm-analysis/7.0|lib/jnr/asm-analysis-7.0.jar +maven://org.ow2.asm/asm-tree/7.0|lib/jnr/asm-tree-7.0.jar +maven://org.ow2.asm/asm-util/7.0|lib/jnr/asm-util-7.0.jar maven://com.github.jnr/jnr-x86asm/1.0.2|lib/jnr/jnr-x86asm-1.0.2.jar -maven://com.github.jnr/jnr-constants/0.8.7|lib/jnr/jnr-constants-0.8.7.jar -maven://com.github.jnr/jnr-enxio/0.9|lib/jnr/jnr-enxio-0.9.jar -maven://com.github.jnr/jnr-posix/3.0.12|lib/jnr/jnr-posix-3.0.12.jar +maven://com.github.jnr/jnr-constants/0.9.11|lib/jnr/jnr-constants-0.9.11.jar +maven://com.github.jnr/jnr-enxio/0.18|lib/jnr/jnr-enxio-0.18.jar +maven://com.github.jnr/jnr-posix/3.0.46|lib/jnr/jnr-posix-3.0.46.jar [lib] lib/jetty-unixsocket-${jetty.version}.jar lib/jnr/*.jar [license] -Jetty UnixSockets is implmented using the Java Native Runtime, which is an +Jetty UnixSockets is implemented using the Java Native Runtime, which is an open source project hosted on Github and released under the Apache 2.0 license. https://github.com/jnr/jnr-unixsocket http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/tests/test-distribution/pom.xml b/tests/test-distribution/pom.xml index b366b52fcaf..da937ba83ad 100644 --- a/tests/test-distribution/pom.xml +++ b/tests/test-distribution/pom.xml @@ -80,6 +80,12 @@ jetty-test-helper test + + org.eclipse.jetty + jetty-unixsocket + ${project.version} + test + diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index 11718fed86f..306d6b4b807 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -19,6 +19,8 @@ package org.eclipse.jetty.tests.distribution; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.TimeUnit; @@ -27,6 +29,9 @@ import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; +import org.eclipse.jetty.toolchain.test.FS; +import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets; +import org.eclipse.jetty.util.StringUtil; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.JRE; @@ -204,4 +209,53 @@ public class DistributionTests extends AbstractDistributionTest assertThat(response.getContentAsString(), not(containsString("<%"))); } } + + @Test + public void unixSocket() throws Exception + { + Path sockFile; + String unixSocketTmp = System.getProperty("unix.socket.tmp"); + if( StringUtil.isNotBlank(unixSocketTmp)) + { + sockFile = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock"); + } else { + sockFile = Files.createTempFile("unix", ".sock"); + } + assertTrue(Files.deleteIfExists(sockFile), "temp sock file cannot be deleted"); + + + String jettyVersion = System.getProperty("jettyVersion"); + DistributionTester distribution = DistributionTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .mavenLocalRepository(System.getProperty("mavenRepoPath")) + .build(); + + String[] args1 = { + "--create-startd", + "--add-to-start=unixsocket-http,deploy,jsp", + "--approve-all-licenses" + }; + try (DistributionTester.Run run1 = distribution.start(args1)) + { + assertTrue(run1.awaitFor(5, TimeUnit.SECONDS)); + assertEquals(0, run1.getExitValue()); + + File war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + jettyVersion); + distribution.installWarFile(war, "test"); + + try (DistributionTester.Run run2 = distribution.start("jetty.unixsocket="+sockFile.toString())) + { + assertTrue(run2.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS)); + + startHttpClient(() -> new HttpClient( new HttpClientTransportOverUnixSockets(sockFile.toString()), null)); + ContentResponse response = client.GET("http://localhost/test/index.jsp"); + assertEquals(HttpStatus.OK_200, response.getStatus()); + assertThat(response.getContentAsString(), containsString("Hello")); + assertThat(response.getContentAsString(), not(containsString("<%"))); + } + } finally { + FS.delete(sockFile); + } + } + }