diff --git a/.github/workflows/ubi8-openjdk-17-runtime.yml b/.github/workflows/ubi8-openjdk-17-runtime.yml deleted file mode 100644 index f00c8d2..0000000 --- a/.github/workflows/ubi8-openjdk-17-runtime.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: run behave-test-steps on OpenJDK 17 Runtime Image -on: - push: - branches: [ v1 ] - pull_request: - branches: [ v1 ] -env: - LANG: en_US.UTF-8 - OPENJDK_CONTAINER_SOURCE_TAG: openjdk-containers-1.13 - OPENJDK_CONTAINER: ubi8/openjdk-17-runtime - OPENJDK_CONTAINER_VERSION: 1.13 - OPENJDK_CONTAINER_DESCRIPTOR: ubi8-openjdk-17-runtime.yaml - PYTHON: python3.10 # this is what ubuntu-latest provides right now -jobs: - openjdkci: - name: OpenJDK Runtime Build and Test - timeout-minutes: 60 - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - id: cekit_version - uses: pozetroninc/github-action-get-latest-release@master - with: - owner: cekit - repo: cekit - excludes: prerelease, draft - - uses: actions/checkout@v4 - - name: fetch openjdk runtime image - run: | - docker pull registry.access.redhat.com/${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} - docker tag registry.access.redhat.com/${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} \ - ${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} - - name: Setup required system packages - run: | - sudo apt-get update - sudo apt-get install -y libkrb5-dev virtualenv - - name: Setup virtualenv and install cekit and required packages - run: | - mkdir ~/cekit${{ steps.cekit_version.outputs.release }} - virtualenv -p ${{ env.PYTHON }} ~/cekit${{ steps.cekit_version.outputs.release }} - . ~/cekit${{ steps.cekit_version.outputs.release }}/bin/activate - pip3 install cekit==${{ steps.cekit_version.outputs.release }} docker behave lxml - # docker-squash odcs lxml - -# even though we don't run any S2I tests for the runtime images, the test suite -# will fail to start if the s2i binary is not present. - - name: mock s2i binary - run: sudo ln -s /usr/bin/echo /usr/bin/s2i - - - name: clone openjdk container sources - run: | - git clone https://github.com/jboss-container-images/openjdk.git ~/openjdk-container - cd ~/openjdk-container - git checkout ${{ env.OPENJDK_CONTAINER_SOURCE_TAG }} - - - name: Run behave tests - run: | - . ~/cekit${{ steps.cekit_version.outputs.release }}/bin/activate - STEPSDIR=$(pwd) - git tag v1 # cekit hard-codes using ref v1 - cd ~/openjdk-container - cekit -v --descriptor ${{ env.OPENJDK_CONTAINER_DESCRIPTOR }} test behave --steps-url file://$STEPSDIR diff --git a/.github/workflows/ubi9-openjdk-17-runtime.yml b/.github/workflows/ubi9-openjdk-17-runtime.yml new file mode 100644 index 0000000..a8c779e --- /dev/null +++ b/.github/workflows/ubi9-openjdk-17-runtime.yml @@ -0,0 +1,40 @@ +name: run behave-test-steps regression tests +on: + push: + branches: [ v1 ] + pull_request: + branches: [ v1 ] +env: + OPENJDK_CONTAINER_SOURCE_TAG: ubi9-openjdk-containers-1.18 + OPENJDK_CONTAINER: ubi9/openjdk-17-runtime + OPENJDK_CONTAINER_VERSION: 1.18 + OPENJDK_CONTAINER_DESCRIPTOR: ubi9-openjdk-17-runtime.yaml +jobs: + openjdkci: + name: behave-test-steps regression tests + timeout-minutes: 60 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: fetch and tag openjdk runtime image + run: | + docker pull registry.access.redhat.com/${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} + docker tag registry.access.redhat.com/${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} \ + ${{ env.OPENJDK_CONTAINER }}:${{ env.OPENJDK_CONTAINER_VERSION }} + + - name: Install CEKit + uses: cekit/actions-setup-cekit@v1.1.5 + +# even though we don't run any S2I tests for the runtime images, the test suite +# will fail to start if the s2i binary is not present. + - name: mock s2i binary + run: sudo ln -s /usr/bin/echo /usr/bin/s2i + + - name: Run behave tests + run: | + STEPSDIR=$(pwd) + git tag v1 # cekit hard-codes using ref v1 + cd test + cekit -v test behave --steps-url file://$STEPSDIR diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..830fbc4 --- /dev/null +++ b/test/README.md @@ -0,0 +1,5 @@ +# Regression tests for behave-test-steps + +These features are used for regression testing behave-test-steps via GitHub +Actions. Please see the `.github/workflows` directory to understand how they +are applied. diff --git a/test/image.yaml b/test/image.yaml new file mode 100644 index 0000000..b0d21bc --- /dev/null +++ b/test/image.yaml @@ -0,0 +1,3 @@ +# dummy descriptor, enough to start tests +name: ubi9/openjdk-17-runtime +version: 1.18 diff --git a/test/tests/features/file.feature b/test/tests/features/file.feature new file mode 100644 index 0000000..03885c3 --- /dev/null +++ b/test/tests/features/file.feature @@ -0,0 +1,5 @@ +Feature: test has a shell redirection in it + Scenario: try running a container with redirection + Given container is started with command bash + Then run sh -c '/usr/local/s2i/run > /tmp/boot.log 2>&1' in container and detach + And file /tmp/boot.log should contain java diff --git a/test/tests/features/gc.feature b/test/tests/features/gc.feature new file mode 100644 index 0000000..1118081 --- /dev/null +++ b/test/tests/features/gc.feature @@ -0,0 +1,61 @@ +@ubi9 +Feature: Openshift OpenJDK GC tests + + Scenario: Check default GC configuration + Given container is started as uid 1000 + Then container log should contain -XX:+UseParallelGC + And container log should contain -XX:MinHeapFreeRatio=10 + And container log should contain -XX:MaxHeapFreeRatio=20 + And container log should contain -XX:GCTimeRatio=4 + + Scenario: Check GC_MIN_HEAP_FREE_RATIO GC configuration + Given container is started with env + | variable | value | + | GC_MIN_HEAP_FREE_RATIO | 5 | + Then container log should contain -XX:MinHeapFreeRatio=5 + + Scenario: Check GC_MAX_HEAP_FREE_RATIO GC configuration + Given container is started with env + | variable | value | + | GC_MAX_HEAP_FREE_RATIO | 50 | + Then container log should contain -XX:MaxHeapFreeRatio=50 + + Scenario: Check GC_TIME_RATIO GC configuration + Given container is started with env + | variable | value | + | GC_TIME_RATIO | 5 | + Then container log should contain -XX:GCTimeRatio=5 + + Scenario: Check GC_ADAPTIVE_SIZE_POLICY_WEIGHT GC configuration + Given container is started with env + | variable | value | + | GC_ADAPTIVE_SIZE_POLICY_WEIGHT | 80 | + Then container log should contain -XX:AdaptiveSizePolicyWeight=80 + + Scenario: Check GC_MAX_METASPACE_SIZE GC configuration + Given container is started with env + | variable | value | + | GC_MAX_METASPACE_SIZE | 120 | + Then container log should contain -XX:MaxMetaspaceSize=120m + + Scenario: Check GC_CONTAINER_OPTIONS configuration + Given container is started with env + | variable | value | + | GC_CONTAINER_OPTIONS | -XX:+UseG1GC | + Then container log should contain -XX:+UseG1GC + And container log should not contain -XX:+UseParallelGC + + Scenario: Check GC_METASPACE_SIZE GC configuration + Given container is started with env + | variable | value | + | GC_METASPACE_SIZE | 120 | + Then container log should contain -XX:MetaspaceSize=120m + And container log should not contain integer expression expected + + Scenario: Check GC_METASPACE_SIZE constrained by GC_MAX_METASPACE_SIZE GC configuration + Given container is started with env + | variable | value | + | GC_METASPACE_SIZE | 120 | + | GC_MAX_METASPACE_SIZE | 90 | + Then container log should contain -XX:MaxMetaspaceSize=90m + And container log should contain -XX:MetaspaceSize=90m diff --git a/test/tests/features/general.feature b/test/tests/features/general.feature new file mode 100644 index 0000000..d8f8534 --- /dev/null +++ b/test/tests/features/general.feature @@ -0,0 +1,8 @@ +Feature: Miscellaneous general settings unit tests + + @ubi9 + Scenario: Check the attributes of /home/default using stat + When container is started with args + | arg | value | + | command | stat /home/default | + Then available container log should contain Access: (0770/drwxrwx---) diff --git a/test/tests/features/java.runtime.feature b/test/tests/features/java.runtime.feature new file mode 100644 index 0000000..bfb54ea --- /dev/null +++ b/test/tests/features/java.runtime.feature @@ -0,0 +1,14 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK Runtime tests (OPENJDK-474) + + Scenario: Ensure JAVA_ARGS is passed through, diagnostic options work correctly, JVM_ARGS not present in run script, OPENJDK-474 JAVA_ARGS not repeated + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from undertow-servlet + | variable | value | + | JAVA_ARGS | unique | + | JAVA_DIAGNOSTICS | true | + Then container log should contain /deployments/undertow-servlet.jar unique + And container log should contain -XX:NativeMemoryTracking=summary + And file /usr/local/s2i/run should not contain JVM_ARGS + And container log should not contain unique unique diff --git a/test/tests/features/java.security.feature b/test/tests/features/java.security.feature new file mode 100644 index 0000000..05be83d --- /dev/null +++ b/test/tests/features/java.security.feature @@ -0,0 +1,7 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift S2I tests + Scenario: Check networkaddress.cache.negative.ttl has been set correctly + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from binary-cli-security-property + Then s2i build log should contain networkaddress.cache.negative.ttl=0 diff --git a/test/tests/features/java_s2i.feature b/test/tests/features/java_s2i.feature new file mode 100644 index 0000000..616b57b --- /dev/null +++ b/test/tests/features/java_s2i.feature @@ -0,0 +1,189 @@ +# temporarily marking 'ignore' so these tests are skipped on GHA +@ignore +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK S2I tests +# NOTE: these tests should be usable with the other images once we have refactored the JDK scripts. +# These builds do not actually run maven. This is important, because the proxy +# options supplied do not specify a valid HTTP proxy. + + # handles mirror/repository configuration; proxy configuration + Scenario: run the s2i and check the maven mirror and proxy have been initialised in the default settings.xml, uses http_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | MAVEN_MIRROR_URL | http://127.0.0.1:8080/repository/internal/ | + | http_proxy | 127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:mirror[ns:id='mirror.default'][ns:url='http://127.0.0.1:8080/repository/internal/'][ns:mirrorOf='external:*'] + + # proxy auth configuration (success case) + nonProxyHosts + Scenario: run the s2i and check the maven mirror, proxy (including username and password) and non proxy have been initialised in the default settings.xml, uses http_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | http_proxy | myuser:mypass@127.0.0.1:8080 | + | no_proxy | *.example.com | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'][ns:username='myuser'][ns:password='mypass'][ns:nonProxyHosts='*.example.com'] + + # proxy auth configuration (fail case: no password supplied) + Scenario: run the s2i and check the maven mirror, proxy (including username) and non proxy have been initialised in the default settings.xml, uses http_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | http_proxy | myuser@127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'] + + # handles mirror/repository configuration; proxy configuration + Scenario: run the s2i and check the maven mirror and proxy have been initialised in the default settings.xml, uses http_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | MAVEN_MIRROR_URL | http://127.0.0.1:8080/repository/internal/ | + | http_proxy | 127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:mirror[ns:id='mirror.default'][ns:url='http://127.0.0.1:8080/repository/internal/'][ns:mirrorOf='external:*'] + + # HTTP_PROXY (all caps) ignored + Scenario: run the s2i and check the maven mirror and proxy have been initialised in the default settings.xml, uses http_proxy and HTTP_PROXY + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | http_proxy | 127.0.0.2:9090 | + | HTTP_PROXY | 127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.2'][ns:port='9090'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 0 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'] + + # handles mirror/repository configuration; https proxy configuration + Scenario: run the s2i and check the maven mirror and proxy have been initialised in the default settings.xml, uses https_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | MAVEN_MIRROR_URL | http://127.0.0.1:8080/repository/internal/ | + | https_proxy | 127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='https'][ns:host='127.0.0.1'][ns:port='8080'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:mirror[ns:id='mirror.default'][ns:url='http://127.0.0.1:8080/repository/internal/'][ns:mirrorOf='external:*'] + + # https proxy auth configuration (success case) + nonProxyHosts + Scenario: run the s2i and check the maven mirror, proxy (including username and password) and non proxy have been initialised in the default settings.xml, uses https_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | https_proxy | myuser:mypass@127.0.0.1:8080 | + | no_proxy | *.example.com | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='https'][ns:host='127.0.0.1'][ns:port='8080'][ns:username='myuser'][ns:password='mypass'][ns:nonProxyHosts='*.example.com'] + + # https proxy auth configuration (fail case: no password supplied) + Scenario: run the s2i and check the maven mirror, proxy (including username) and non proxy have been initialised in the default settings.xml, uses https_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | https_proxy | myuser@127.0.0.1:8080 | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='https'][ns:host='127.0.0.1'][ns:port='8080'] + + Scenario: run s2i assemble and check no_proxy is honoured with multiple entries + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + | variable | value | + | MAVEN_ARGS | -v | + | MAVEN_MIRROR_URL | http://127.0.0.1:8080/repository/internal/ | + | http_proxy | http://127.0.0.1:8080 | + | no_proxy | foo.example.com,bar.example.com | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:proxy[ns:id='genproxy'][ns:active='true'][ns:protocol='http'][ns:host='127.0.0.1'][ns:port='8080'][ns:nonProxyHosts='foo.example.com|bar.example.com'] + + # deprecated? + Scenario: run an S2I build that depends on com.redhat.xpaas.repo.redhatga being defined + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + + # deprecated? + Scenario: run an S2I that should fail as MAVEN_ARGS does not define com.redhat.xpaas.repo.redhatga + Given failing s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple using openjdk-enforce-profile + | variable | value | + | MAVEN_ARGS | -e package | + + # CLOUD-579 + Scenario: Test that maven is executed in batch mode + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + Then s2i build log should contain --batch-mode + And s2i build log should not contain \r + + # CLOUD-3095 - context dir should be recursively copied into the image + # "/target" suffix is important here; it triggers a different code-path (no source build) + Scenario: Ensure binary-only mode copies binaries into the target image + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple/target + Then s2i build log should not contain skipping directory . + And run find /deployments in container and check its output for spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar + + # OPENJDK-1954 - MAVEN_REPOS + Scenario: run the s2i and check the maven mirror and proxy have been initialised in the default settings.xml, uses http_proxy + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple/target + | variable | value | + | MAVEN_REPOS | TESTREPO,ANOTHER | + | TESTREPO_MAVEN_REPO_URL | http://repo.example.com:8080/maven2/ | + | TESTREPO_MAVEN_REPO_ID | myrepo | + | ANOTHER_MAVEN_REPO_URL | https://repo.example.org:8888/ | + | ANOTHER_MAVEN_REPO_ID | another | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:server[ns:id='myrepo'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:profile[ns:id='myrepo-profile']/ns:repositories/ns:repository[ns:url='http://repo.example.com:8080/maven2/'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:server[ns:id='another'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:profile[ns:id='another-profile']/ns:repositories/ns:repository[ns:url='https://repo.example.org:8888/'] + + # OPENJDK-1961: MAVEN_REPO_URL and MAVEN_REPO_ID + Scenario: Check MAVEN_REPO_URL generates Maven settings and profile configuration + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple/target + | variable | value | + | MAVEN_REPO_URL | http://repo.example.com:8080/maven2/ | + | MAVEN_REPO_ID | myrepo | + And XML namespaces + | prefix | url | + | ns | http://maven.apache.org/SETTINGS/1.0.0 | + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:server[ns:id='myrepo'] + Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:profile[ns:id='myrepo-profile']/ns:repositories/ns:repository[ns:url='http://repo.example.com:8080/maven2/'] + + Scenario: Ensure the environment is cleaned when executing mvn (OPENJDK-1549) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from OPENJDK-1549 with env + | variable | value | + | MAVEN_ARGS | validate | + + Scenario: Ensure that run-env.sh placed in the JAVA_APP_DIR is sourced in the run script before launching java + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from quarkus-quickstarts/getting-started-3.0.1.Final-nos2i + | variable | value | + | S2I_SOURCE_DATA_DIR | ./ | + | S2I_TARGET_DATA_DIR | /deployments | + Then container log should contain INFO exec -a "someUniqueString" java + + Scenario: Ensure mtime is preserved for build artifacts (OPENJDK-2408) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from OPENJDK-2408-bin-custom-s2i-assemble with env + | variable | value | + | S2I_DELETE_SOURCE | false | + Then run find /deployments/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar ! -newer /tmp/src/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar in container and check its output for spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar diff --git a/test/tests/features/java_s2i_inc.feature b/test/tests/features/java_s2i_inc.feature new file mode 100644 index 0000000..57a820f --- /dev/null +++ b/test/tests/features/java_s2i_inc.feature @@ -0,0 +1,17 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK S2I tests + + # test incremental builds + Scenario: Check incremental builds cache .m2 + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from undertow-servlet + | variable | value | + | JAVA_ARGS | Hello from CTF test | + Then container log should contain /deployments/undertow-servlet.jar Hello from CTF test + And s2i build log should contain Downloading from central: + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from undertow-servlet with env and incremental + | variable | value | + | JAVA_ARGS | Hello from CTF test | + Then container log should contain /deployments/undertow-servlet.jar Hello from CTF test + And s2i build log should not contain Downloading from central: diff --git a/test/tests/features/java_s2i_quarkus.feature b/test/tests/features/java_s2i_quarkus.feature new file mode 100644 index 0000000..b0dbf46 --- /dev/null +++ b/test/tests/features/java_s2i_quarkus.feature @@ -0,0 +1,27 @@ +# builder only +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK S2I tests (Quarkus-based) + + Scenario: Ensure Quarkus CDS doesn't fail due to timestamp mismatch (OPENDJK-1673) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from getting-started + Then container log should not contain A jar file is not the one used while building the shared archive file + + Scenario: quarkus fast-jar layout works out-of-the-box (OPENJDK-631) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from quarkus-quickstarts/getting-started-3.0.1.Final-nos2i + Then container log should contain INFO quarkus fast-jar package type detected + And container log should contain -jar /deployments/quarkus-app/quarkus-run.jar + And container log should contain (main) getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus + # these might occur if the wrong JAR is chosen as the main one + And container log should not contain -jar /deployments/getting-started-1.0.0-SNAPSHOT.jar + And container log should not contain no main manifest attribute + + Scenario: quarkus uber-jar layout works out-of-the-box (OPENJDK-631) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from quarkus-quickstarts/getting-started-3.0.1.Final-nos2i with env + | variable | value | + | QUARKUS_PACKAGE_TYPE | uber-jar | + Then container log should not contain INFO quarkus fast-jar package type detected + And container log should not contain -jar /deployments/quarkus-app/quarkus-run.jar + And container log should contain -jar /deployments/getting-started-1.0.0-SNAPSHOT-runner.jar + And container log should contain (main) getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus diff --git a/test/tests/features/memory.feature b/test/tests/features/memory.feature new file mode 100644 index 0000000..64ca385 --- /dev/null +++ b/test/tests/features/memory.feature @@ -0,0 +1,41 @@ +Feature: OPENJDK-559 JVM Memory tests + + @ubi9 + Scenario: Check default JVM max heap configuration + Given container is started as uid 1000 + Then container log should contain -XX:MaxRAMPercentage=80.0 + + @ubi9 + Scenario: Check configured JVM max heap configuration and ensure JAVA_MAX_MEM_RATIO accepts floats but only takes whole number part + Given container is started with env + | variable | value | + | JAVA_MAX_MEM_RATIO | 90.4 | + Then container log should contain -XX:MaxRAMPercentage=90.0 + + @ubi9 + Scenario: Ensure JAVA_MAX_MEM_RATIO accepts Integers + Given container is started with env + | variable | value | + | JAVA_MAX_MEM_RATIO | 90 | + Then container log should contain -XX:MaxRAMPercentage=90.0 + + @ubi9 + Scenario: Ensure JAVA_MAX_MEM_RATIO=0 disables parameter + Given container is started with env + | variable | value | + | JAVA_MAX_MEM_RATIO | 0 | + Then container log should not contain -XX:MaxRAMPercentage + + @ubi9 + Scenario: Check default JVM initial heap configuration is unspecified + Given container is started as uid 1000 + Then container log should not contain -XX:InitialRAMPercentage + And container log should not contain -Xms + + # Not the runtime images + @ubi9/openjdk-11 + @ubi9/openjdk-17 + @ubi9/openjdk-21 + Scenario: Ensure Maven doesn't use MaxRAMPercentage=80 + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + Then s2i build log should match regex INFO Using MAVEN_OPTS.*-XX:MaxRAMPercentage=25.0$ diff --git a/test/tests/features/openjdk.feature b/test/tests/features/openjdk.feature new file mode 100644 index 0000000..1bace56 --- /dev/null +++ b/test/tests/features/openjdk.feature @@ -0,0 +1,98 @@ +Feature: Miscellaneous OpenJDK-related unit tests + + @ubi9/openjdk-11 + @ubi9/openjdk-11-runtime + Scenario: Check that only OpenJDK 11 is installed + When container is started with args + | arg | value | + | command | rpm -qa | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-17 + Then available container log should not contain java-21 + + @ubi9/openjdk-17 + @ubi9/openjdk-17-runtime + Scenario: Check that only OpenJDK 17 is installed + When container is started with args + | arg | value | + | command | rpm -qa | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-11 + Then available container log should not contain java-21 + + @ubi9/openjdk-21 + @ubi9/openjdk-21-runtime + Scenario: Check that only OpenJDK 21 is installed + When container is started with args + | arg | value | + | command | rpm -qa | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-11 + Then available container log should not contain java-17 + + @ubi9 + Scenario: Ensure JAVA_HOME is defined and contains Java + When container is started with args + | arg | value | + | command | bash -c "$JAVA_HOME/bin/java -version" | + Then available container log should contain OpenJDK Runtime Environment + + @ubi9 + Scenario: Check that certain non-UBI packages are not installed + When container is started with args + | arg | value | + | command | rpm -qa | + Then available container log should not contain grub + Then available container log should not contain os-prober + Then available container log should not contain rpm-plugin-systemd-inhibit + + @ubi9/openjdk-11 + @ubi9/openjdk-11-runtime + Scenario: Check that directories from other JDKs are not present (JDK11) + When container is started with args + | arg | value | + | command | ls -1 /usr/lib/jvm | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-17 + Then available container log should not contain java-21 + + @ubi9/openjdk-17 + @ubi9/openjdk-17-runtime + Scenario: Check that directories from other JDKs are not present (JDK17) + When container is started with args + | arg | value | + | command | ls -1 /usr/lib/jvm | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-11 + Then available container log should not contain java-21 + + @ubi9/openjdk-21 + @ubi9/openjdk-21-runtime + Scenario: Check that directories from other JDKs are not present (JDK21) + When container is started with args + | arg | value | + | command | ls -1 /usr/lib/jvm | + Then available container log should not contain java-1.8.0 + Then available container log should not contain java-11 + Then available container log should not contain java-17 + + @ubi9 + Scenario: Ensure LANG is defined and contains UTF-8 + When container is started with args + | arg | value | + | command | bash -c "$JAVA_HOME/bin/java -XshowSettings:properties -version" | + Then available container log should contain file.encoding = UTF-8 + + @ubi9 + Scenario: Ensure tar is installed (OPENJDK-1165) + When container is started with args + | arg | value | + | command | tar | + Then available container log should not contain command not found + + @ubi9 + Scenario: Ensure tzdata RPM is properly installed (OPENJDK-2519) + When container is started with args + | arg | value | + | command | rpm -V tzdata | + Then available container log should not contain missing diff --git a/test/tests/features/openshift.feature b/test/tests/features/openshift.feature new file mode 100644 index 0000000..ceb6be8 --- /dev/null +++ b/test/tests/features/openshift.feature @@ -0,0 +1,17 @@ +Feature: Tests for all openshift images + + @ubi9 + Scenario: Check that common labels are correctly set + Given image is built + # UBI base image versions are the RHEL version, e.g. "9.2", whereas all of + # our image versions (so far) have been 1.x + Then the image should contain label version containing value 1. + And the image should contain label name containing value openjdk + + # builder-only test + @ubi9/openjdk-11 + @ubi9/openjdk-17 + @ubi9/openjdk-21 + Scenario: Check that builder labels are correctly set + Given image is built + Then the image should contain label io.openshift.s2i.scripts-url with value image:///usr/local/s2i diff --git a/test/tests/features/ports.feature b/test/tests/features/ports.feature new file mode 100644 index 0000000..6542c24 --- /dev/null +++ b/test/tests/features/ports.feature @@ -0,0 +1,13 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK port tests + + Scenario: Check ports are available + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from undertow-servlet + Then check that port 8080 is open + Then check that port 8443 is open + Then inspect container + | path | value | + | /Config/ExposedPorts | 8080/tcp | + | /Config/ExposedPorts | 8443/tcp | diff --git a/test/tests/features/runtime.feature b/test/tests/features/runtime.feature new file mode 100644 index 0000000..4104541 --- /dev/null +++ b/test/tests/features/runtime.feature @@ -0,0 +1,68 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift OpenJDK Runtime tests + + @ubi9 + Scenario: Check JAVA_OPTS overrides defaults + Given container is started with env + | variable | value | + | JAVA_OPTS | --show-version | + Then container log should not contain -XX:MaxRAMPercentage + + @ubi9 + Scenario: Check empty JAVA_OPTS overrides defaults + Given container is started with env + | variable | value | + | JAVA_OPTS | | + Then container log should not contain -XX:MaxRAMPercentage + + @ubi9 + Scenario: Check JAVA_OPTS overrides JAVA_OPTS_APPEND + Given container is started with env + | variable | value | + | JAVA_OPTS | -verbose:gc | + | JAVA_OPTS_APPEND | -Xint | + Then container log should contain -verbose:gc + And container log should not contain -Xint + + @ubi9 + Scenario: Check JAVA_APP_NAME can contain spaces (OPENJDK-1551) + Given container is started with env + | variable | value | + | JAVA_APP_NAME | foo bar | + Then container log should not contain exec: bar': not found + + @ubi9 + Scenario: Check default JAVA_APP_DIR (OPENJDK-2034) + When container is ready + Then available container log should contain INFO running in /deployments + + @ubi9 + Scenario: Check custom JAVA_APP_DIR (OPENJDK-2034) + Given container is started with env + | variable | value | + | JAVA_APP_DIR | /home/default | + Then available container log should contain INFO running in /home/default + + @ubi9 + Scenario: Check relative path JAVA_APP_DIR (OPENJDK-2034) + Given container is started with env + | variable | value | + | JAVA_APP_DIR | . | + Then available container log should contain INFO running in /home/default + + @ubi9 + Scenario: Check non-existent path JAVA_APP_DIR (OPENJDK-2034) + Given container is started with env + | variable | value | + | JAVA_APP_DIR | /nope | + Then available container log should contain ERROR No directory /nope found for auto detection + + # Builder images only + Scenario: Ensure JAVA_APP_DIR and S2I work together (OPENJDK-2034) + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from undertow-servlet + | variable | value | + | JAVA_APP_DIR | /home/default | + | S2I_TARGET_DEPLOYMENTS_DIR | /home/default | + Then container log should contain /home/default/undertow-servlet.jar diff --git a/test/tests/features/s2i-core.feature b/test/tests/features/s2i-core.feature new file mode 100644 index 0000000..cf4b362 --- /dev/null +++ b/test/tests/features/s2i-core.feature @@ -0,0 +1,8 @@ +@ubi9/openjdk-11 +@ubi9/openjdk-17 +@ubi9/openjdk-21 +Feature: Openshift S2I tests + # OPENJDK-84 - /tmp/src should not be present after build + Scenario: run an s2i build and check that /tmp/src has been removed afterwards + Given s2i build https://github.com/jboss-container-images/openjdk-test-applications from spring-boot-sample-simple + Then run stat /tmp/src in container and immediately check its output does not contain File: