diff --git a/tests/functional/leyden-quickstart/.gitignore b/tests/functional/leyden-quickstart/.gitignore new file mode 100644 index 00000000000..626464def82 --- /dev/null +++ b/tests/functional/leyden-quickstart/.gitignore @@ -0,0 +1,36 @@ +# Compiled class file +*.class + +# Maven +target/ +.m2/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# IntelliJ Idea +.idea/* +!.idea/runConfigurations +*.iws +*.ipr +*.iml +*.releaseBackup +atlassian-ide-plugin.xml + +# Netbeans +nbactions.xml +nb-configuration.xml + +# Eclipse +.settings +.settings/ +.project +.classpath +.factorypath + diff --git a/tests/functional/leyden-quickstart/Dockerfile.leyden b/tests/functional/leyden-quickstart/Dockerfile.leyden new file mode 100644 index 00000000000..e94df62ad22 --- /dev/null +++ b/tests/functional/leyden-quickstart/Dockerfile.leyden @@ -0,0 +1,50 @@ +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM container-registry.oracle.com/os/oraclelinux:9-slim as olinux-leyden + +WORKDIR /usr/share + +ARG CHECKPOINT_DIR + +ENV JDK_NAME=openjdk-24-leyden+2-8_linux-x64 +ENV JAVA_HOME=/usr/share/$JDK_NAME +ENV CR_DIR=${CONT_IMG_VER:-/leyden-checkpoint/cr} + +# Install wrk +RUN microdnf -h +RUN microdnf -y update && microdnf -y install perl wget tar gzip curl git openssl-devel +RUN git clone https://github.com/wg/wrk.git && cd wrk && make && cp wrk /usr/local/bin/ + +# Install Leyden +RUN wget -O leyden-jdk.tar.gz "https://download.java.net/java/early_access/leyden/2/${JDK_NAME}_bin.tar.gz" +RUN tar -xvf ./leyden-jdk.tar.gz -C /usr/share && mv /usr/share/jdk-24 $JAVA_HOME +RUN ln -s $JAVA_HOME/bin/jcmd /bin/ && ln -s $JAVA_HOME/bin/jps /bin/ && ln -s $JAVA_HOME/bin/java /bin/ + +FROM olinux-leyden +WORKDIR /helidon + +ADD target/leyden-quickstart.jar . +ADD target/libs ./libs +ADD runtimeLeyden.sh . +ADD warmUp.sh . +ADD measure.sh . +RUN chmod +x ./*.sh + +RUN ./runtimeLeyden.sh + +CMD ["sh","/helidon/runtimeLeyden.sh"] + +EXPOSE 7001 \ No newline at end of file diff --git a/tests/functional/leyden-quickstart/README.md b/tests/functional/leyden-quickstart/README.md new file mode 100644 index 00000000000..7a43cdd41d4 --- /dev/null +++ b/tests/functional/leyden-quickstart/README.md @@ -0,0 +1,33 @@ +```bash +mvn clean package +docker build -t leyden-helloworld -f Dockerfile.leyden . +docker run --network host --rm --name leyden-helloworld leyden-helloworld +``` + + +``` +---- Vanilla +1667 milliseconds (since JVM startup) + +Measuring ...Running 10s test @ http://localhost:7001 + 16 threads and 16 connections + Thread Stats Avg Stdev Max +/- Stdev + Latency 622.78us 1.37ms 27.81ms 92.19% + Req/Sec 4.09k 2.06k 8.96k 61.38% + 651144 requests in 10.02s, 85.07MB read +Requests/sec: 64978.74 +Transfer/sec: 8.49MB + + +---- Leyden + 578 milliseconds (since JVM startup) + + Measuring ...Running 10s test @ http://localhost:7001 + 16 threads and 16 connections + Thread Stats Avg Stdev Max +/- Stdev + Latency 446.13us 0.86ms 22.79ms 92.21% + Req/Sec 4.57k 1.30k 8.82k 70.10% + 729398 requests in 10.10s, 95.30MB read +Requests/sec: 72211.76 +Transfer/sec: 9.43MB +``` \ No newline at end of file diff --git a/tests/functional/leyden-quickstart/buildtimeLeyden.sh b/tests/functional/leyden-quickstart/buildtimeLeyden.sh new file mode 100644 index 00000000000..2fd23cb4b50 --- /dev/null +++ b/tests/functional/leyden-quickstart/buildtimeLeyden.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e + +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +echo "==== Creating Leyden checkpoint ====" +echo "=== Pre-starting Helidon MP app ===" +set +e +mkdir -p "/leyden-checkpoint/cr" +./warmUp.sh & +$JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -Xlog:cds=debug:file=$CR_DIR/cds.log -jar ./*.jar +set -e + +echo "=== Leyden checkpoint created ===" + + + diff --git a/tests/functional/leyden-quickstart/measure.sh b/tests/functional/leyden-quickstart/measure.sh new file mode 100644 index 00000000000..88dd891a76c --- /dev/null +++ b/tests/functional/leyden-quickstart/measure.sh @@ -0,0 +1,21 @@ +#!/bin/bash -e + +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001 +printf "\nMeasuring ..." +wrk -c 16 -t 16 -d 10s http://localhost:7001 \ No newline at end of file diff --git a/tests/functional/leyden-quickstart/pom.xml b/tests/functional/leyden-quickstart/pom.xml new file mode 100644 index 00000000000..3df0731c0c7 --- /dev/null +++ b/tests/functional/leyden-quickstart/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + io.helidon.applications + helidon-mp + 4.1.1 + + + io.helidon.quickstart + leyden-quickstart + 1.0-SNAPSHOT + + + + + io.helidon.microprofile.bundles + helidon-microprofile-core + + + io.helidon.microprofile.openapi + helidon-microprofile-openapi + + + io.helidon.microprofile.health + helidon-microprofile-health + + + jakarta.json.bind + jakarta.json.bind-api + + + org.glassfish.jersey.media + jersey-media-json-binding + runtime + + + io.helidon.logging + helidon-logging-jul + runtime + + + io.smallrye + jandex + runtime + + + org.eclipse.microprofile.metrics + microprofile-metrics-api + + + io.helidon.microprofile.metrics + helidon-microprofile-metrics + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-libs + + + + + io.smallrye + jandex-maven-plugin + + + make-index + + + + + + diff --git a/tests/functional/leyden-quickstart/runtimeLeyden.sh b/tests/functional/leyden-quickstart/runtimeLeyden.sh new file mode 100644 index 00000000000..4ddcab3de6c --- /dev/null +++ b/tests/functional/leyden-quickstart/runtimeLeyden.sh @@ -0,0 +1,38 @@ +#!/bin/bash -e + +# +# Copyright (c) 2022-2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if [ ! -d "$CR_DIR" ]; +then + echo "==== Creating Leyden checkpoint ====" + echo "=== Pre-starting Helidon MP app ===" + set +e + mkdir -p "$CR_DIR" + ./warmUp.sh & + $JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -Xlog:cds=debug:file=$CR_DIR/cds.log -jar ./*.jar + set -e + + echo "=== Leyden checkpoint created ===" +else +echo "==== Starting directly from Leyden checkpoint ====" +#exec ls -l /helidon +./measure.sh & +exec $JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -jar ./*.jar +#exec $JAVA_HOME/bin/java -jar ./*.jar +fi + + diff --git a/tests/functional/leyden-quickstart/src/main/java/io/helidon/quickstart/HelloResource.java b/tests/functional/leyden-quickstart/src/main/java/io/helidon/quickstart/HelloResource.java new file mode 100644 index 00000000000..7ef6d3c7943 --- /dev/null +++ b/tests/functional/leyden-quickstart/src/main/java/io/helidon/quickstart/HelloResource.java @@ -0,0 +1,19 @@ +package io.helidon.quickstart; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/") +@RequestScoped +public class HelloResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String message() { + return "Hello World"; + } + +} diff --git a/tests/functional/leyden-quickstart/src/main/resources/META-INF/beans.xml b/tests/functional/leyden-quickstart/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..b0993408cd8 --- /dev/null +++ b/tests/functional/leyden-quickstart/src/main/resources/META-INF/beans.xml @@ -0,0 +1,8 @@ + + + diff --git a/tests/functional/leyden-quickstart/src/main/resources/META-INF/microprofile-config.properties b/tests/functional/leyden-quickstart/src/main/resources/META-INF/microprofile-config.properties new file mode 100644 index 00000000000..6aa9c264547 --- /dev/null +++ b/tests/functional/leyden-quickstart/src/main/resources/META-INF/microprofile-config.properties @@ -0,0 +1,4 @@ +server.port=7001 +server.host=0.0.0.0 + + diff --git a/tests/functional/leyden-quickstart/src/main/resources/logging.properties b/tests/functional/leyden-quickstart/src/main/resources/logging.properties new file mode 100644 index 00000000000..ffad43dbff5 --- /dev/null +++ b/tests/functional/leyden-quickstart/src/main/resources/logging.properties @@ -0,0 +1,20 @@ + +# Example Logging Configuration File +# For more information see $JAVA_HOME/jre/lib/logging.properties + +# Send messages to the console +handlers=io.helidon.logging.jul.HelidonConsoleHandler + +# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread +java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n + +# Global logging level. Can be overridden by specific loggers +.level=INFO + +# Quiet Weld +org.jboss.level=WARNING + +# Component specific log levels +#io.helidon.config.level=INFO +#io.helidon.security.level=INFO +#io.helidon.common.level=INFO diff --git a/tests/functional/leyden-quickstart/warmUp.sh b/tests/functional/leyden-quickstart/warmUp.sh new file mode 100644 index 00000000000..64e152368a8 --- /dev/null +++ b/tests/functional/leyden-quickstart/warmUp.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001 +printf "\n==== Warming up ...\n" +wrk -c 16 -t 16 -d 10s http://localhost:7001 +printf "\n==== Warmup complete\n" +kill $(jps | grep jar | awk '{print $1}') \ No newline at end of file diff --git a/tests/functional/pom.xml b/tests/functional/pom.xml index 5ff5cf64bb0..01812d7bd26 100644 --- a/tests/functional/pom.xml +++ b/tests/functional/pom.xml @@ -46,5 +46,6 @@ jax-rs-multiple-apps param-converter-provider config-profiles + leyden-quickstart