-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from vpa1977/vpa1977/test-petclinic
Provide a Spring boot webapp unit/integration test run
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.m2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ARG BASE_IMAGE=ubuntu/chiselled-jre:8_edge | ||
ARG USER=app | ||
ARG UID=101 | ||
ARG GROUP=app | ||
ARG GID=101 | ||
|
||
FROM $BASE_IMAGE | ||
|
||
ARG USER | ||
ARG UID | ||
ARG GID | ||
USER $UID:$GID | ||
|
||
# shell is needed for maven surefire plugin | ||
ADD --chown=$UID:$GID sh /bin/sh | ||
ADD --chown=$UID:$GID spring-petclinic /spring-petclinic | ||
ADD --chown=$UID:$GID .m2 /.m2 | ||
|
||
WORKDIR /spring-petclinic | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
# This test builds tests for spring-petclinic with Maven, copies class files | ||
# into the chiselled container and executes them in the container environemnt. | ||
# For OpenJDK 8 we need to use tag on the last commit that used spring-boot 2.X | ||
# as later version requires OpenJDK 17. | ||
|
||
echo "Running Spring Petclinic self-tests" | ||
|
||
# Replace with our development docker when it is ready | ||
BUILD_DOCKER=eclipse-temurin:8u362-b09-jdk-jammy | ||
|
||
# clone petclinic repository, alternative is to have a submodule here | ||
PETCLINIC_TAG=spring-boot-2.7.3 | ||
PETCLINIC_REPO=https://github.com/vpa1977/spring-petclinic | ||
echo cloning $PETCLINIC_TAG $PETCLINIC_REPO | ||
git clone --branch $PETCLINIC_TAG $PETCLINIC_REPO || \ | ||
(cd spring-petclinic && \ | ||
git checkout $PETCLINIC_TAG && | ||
git reset --hard) | ||
|
||
TEST_DIR=`pwd` | ||
PROJECT_DIR=${TEST_DIR}/spring-petclinic | ||
|
||
# Build and run tests with JDK8 container. We should replace Temurin with | ||
# our dev container | ||
docker run -v ${TEST_DIR}:${TEST_DIR} -w ${TEST_DIR}/spring-petclinic \ | ||
$BUILD_DOCKER \ | ||
java -classpath "${PROJECT_DIR}/.mvn/wrapper/maven-wrapper.jar" \ | ||
-Dmaven.repo.local="${TEST_DIR}/.m2" \ | ||
-Dmaven.multiModuleProjectDirectory="${PROJECT_DIR}" \ | ||
org.apache.maven.wrapper.MavenWrapperMain \ | ||
-q \ | ||
test | ||
|
||
cp /bin/sh sh | ||
|
||
# build docker containing maven cache and a project | ||
docker build --build-arg BASE_IMAGE=${BASE_IMAGE:-ubuntu/chiselled-jre:8_edge} \ | ||
-t petclinic . | ||
|
||
# now run the tests within our container | ||
docker run --rm --tmpfs /tmp:exec petclinic \ | ||
-classpath /spring-petclinic/.mvn/wrapper/maven-wrapper.jar \ | ||
-Dmaven.repo.local=/.m2 \ | ||
-Dmaven.multiModuleProjectDirectory=/spring-petclinic \ | ||
-Dmaven.compiler.useIncrementalCompilation=false \ | ||
org.apache.maven.wrapper.MavenWrapperMain \ | ||
test |