-
Notifications
You must be signed in to change notification settings - Fork 237
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 #217 from jmesnil/test
Add smoke-test shell script
- Loading branch information
Showing
2 changed files
with
84 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,20 @@ name: Build and push WildFly Docker images | |
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
tags: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
image: | ||
env: | ||
# Put the "latest" tag on this JDK version | ||
JDK_VERSION_FOR_LATEST: 21 | ||
IMAGE_TEST: wildfly-test:latest | ||
strategy: | ||
matrix: | ||
include: | ||
|
@@ -50,14 +56,26 @@ jobs: | |
uses: docker/[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
- name: Build WildFly images | ||
id: docker_build | ||
uses: docker/[email protected] | ||
with: | ||
load: true | ||
tags: ${{ env.IMAGE_TEST }} | ||
- name: Smoke Test | ||
run: | | ||
./scripts/smoke-test.sh ${{ env.IMAGE_TEST }} | ||
- name: Docker Login to Quay.io | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ secrets.REGISTRY }} | ||
username: ${{ secrets.REGISTRY_USER }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
- name: Build and push JDK images | ||
id: docker_build | ||
- name: Push WildFly images to container registry | ||
# Only push to the container registry when a new tag is pushed to the repository | ||
id: docker_push | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
uses: docker/[email protected] | ||
with: | ||
push: true | ||
|
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,64 @@ | ||
WILDFLY_IMAGE=$1 | ||
|
||
check_http_status() { | ||
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:8080/") | ||
if [ "$response" -eq 200 ]; then | ||
echo "Success! Received a 200 OK response." | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
|
||
check_wildfly_up_and_running() { | ||
# wait until WildFLy is up and running | ||
max_time=120 | ||
retry_interval=5 | ||
|
||
start_time=$(date +%s) | ||
while true; do | ||
current_time=$(date +%s) | ||
elapsed_time=$(( current_time - start_time )) | ||
if [ $elapsed_time -ge $max_time ]; then | ||
echo "Failed to get WildFly up and running within $max_time seconds." | ||
return 1 | ||
fi | ||
docker container logs ${CONTAINER_ID} | grep WFLYSRV0025 | ||
if [ $? -eq 0 ]; then | ||
echo "Success! WildFly is up and running." | ||
return 0 | ||
fi | ||
sleep $retry_interval | ||
done | ||
} | ||
|
||
check_wildfly_version() { | ||
docker container logs ${CONTAINER_ID} | grep WFLYSRV0025 | grep ${WILDFLY_VERSION} | ||
if [ $? -eq 0 ]; then | ||
echo "Success! WildFly is using version ${WILDFLY_VERSION}." | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
|
||
WILDFLY_VERSION=$(grep "ENV WILDFLY_VERSION" Dockerfile | rev | cut -d' ' -f1 | rev) | ||
|
||
docker run --rm -p 8080:8080 ${WILDFLY_IMAGE} & | ||
sleep 2 | ||
CONTAINER_ID=$(docker ps -l -q) | ||
|
||
if ! check_wildfly_up_and_running; then | ||
echo "WildFly did not boot up properly." | ||
exit 1 | ||
fi | ||
|
||
if ! check_http_status; then | ||
echo "WildFly did not reply to the HTTP request." | ||
exit 1 | ||
fi | ||
|
||
if ! check_wildfly_version; then | ||
echo "WildFly did not use the expected ${WILDFY_VERSION} version." | ||
exit 1 | ||
fi | ||
|
||
docker kill ${CONTAINER_ID} |