Skip to content

Commit

Permalink
Split acceptance test execution into start and run phases
Browse files Browse the repository at this point in the history
Regularly, you'd keep on running `make
acceptance-tests-[datadir|pgconfig|jdbcconfig]` as usual.

For the github action it's nicer to have the docker compo start and run
in separte steps.
  • Loading branch information
groldan committed Oct 15, 2024
1 parent a3880c4 commit 26d2c9d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 32 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ jobs:
- name: Test
run: |
# `make test` runs mvn verify, which includes mvn package, so no need to run `package` separatedly for the upload step below
make test
#make test
make package
- name: Upload application jar files
uses: actions/upload-artifact@v4
with:
name: application-jars
path: ./**/target/*-bin.jar
path: |
./**/target/*-bin.jar
./**/target/config/
retention-days: 1
compression-level: 0 # no compression

Expand All @@ -69,41 +72,40 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'

- name: Download application jar files
uses: actions/download-artifact@v4
with:
name: application-jars
path: .

- name: Copy config directory
# during the validate phase, the config/ dir is copied to each app's target/config
run: ./mvnw validate -f src/apps -ntp -T1C

- name: Build images
# REPACKAGE=false avoids to re-package the apps during build-image
run: REPACKAGE=false make build-image

- name: Build acceptance tests docker image
run: |
make build-acceptance
- name: Install CI dependencies
id: install-ci
id: installci
run: python3 -m pip install --user --requirement=ci/requirements.txt

- name: Run acceptance tests ${{ matrix.catalog }}
- name: Launch ${{ matrix.catalog }} acceptance tests docker composition
id: start
run: |
make start-acceptance-tests-${{ matrix.catalog }}
- name: Run ${{ matrix.catalog }} acceptance tests
id: acceptance
run: |
make acceptance-tests-${{ matrix.catalog }}
make run-acceptance-tests-${{ matrix.catalog }}
- name: Print docker compose logs
if: steps.build.install-ci == 'success'
if: always()
run: (cd compose && c2cciutils-docker-logs)

- name: Cleanup acceptance tests
if: steps.build.acceptance != 'skipped'
if: always()
run: |
make clean-acceptance-tests-${{ matrix.catalog }}
50 changes: 35 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ install:

.PHONY: package
package:
./mvnw clean package -DskipTests -ntp -U -T1C
./mvnw clean package -Dfmt.skip -DskipTests -ntp -U -T1C

.PHONY: test
test:
./mvnw verify -ntp -T1C
./mvnw verify -Dfmt.skip -ntp -T1C

.PHONY: build-image
build-image: build-base-images build-image-infrastructure build-image-geoserver
Expand Down Expand Up @@ -136,30 +136,50 @@ verify-image:
build-acceptance:
docker build --tag=acceptance:$(TAG) acceptance_tests

.PHONY: acceptance-tests-pgconfig
acceptance-tests-pgconfig: build-acceptance
(cd compose/ && ./acceptance_pgconfig up -d)
(cd compose/ && ./acceptance_pgconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: clean-acceptance-tests-pgconfig
clean-acceptance-tests-pgconfig:
(cd compose/ && ./acceptance_pgconfig down -v)

.PHONY: acceptance-tests-datadir
acceptance-tests-datadir: build-acceptance
acceptance-tests-datadir: build-acceptance start-acceptance-tests-datadir run-acceptance-tests-datadir

.PHONY: start-acceptance-tests-datadir
start-acceptance-tests-datadir:
(cd compose/ && ./acceptance_datadir up -d)
(cd compose/ && ./acceptance_datadir exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: run-acceptance-tests-datadir
run-acceptance-tests-datadir:
(cd compose/ && ./acceptance_datadir run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: clean-acceptance-tests-datadir
clean-acceptance-tests-datadir:
(cd compose/ && ./acceptance_datadir down -v)
rm -rf compose/catalog-datadir/*
touch compose/catalog-datadir/.keep

.PHONY: acceptance-tests-pgconfig
acceptance-tests-pgconfig: build-acceptance start-acceptance-tests-pgconfig run-acceptance-tests-pgconfig
(cd compose/ && ./acceptance_pgconfig up -d)
(cd compose/ && ./acceptance_pgconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: start-acceptance-tests-pgconfig
start-acceptance-tests-pgconfig:
(cd compose/ && ./acceptance_pgconfig up -d)

.PHONY: run-acceptance-tests-pgconfig
run-acceptance-tests-pgconfig:
(cd compose/ && ./acceptance_pgconfig run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: clean-acceptance-tests-pgconfig
clean-acceptance-tests-pgconfig:
(cd compose/ && ./acceptance_pgconfig down -v)

.PHONY: acceptance-tests-jdbcconfig
acceptance-tests-jdbcconfig: build-acceptance
acceptance-tests-jdbcconfig: build-acceptance start-acceptance-tests-jdbcconfig run-acceptance-tests-jdbcconfig

.PHONY: start-acceptance-tests-jdbcconfig
start-acceptance-tests-jdbcconfig:
(cd compose/ && ./acceptance_jdbcconfig up -d)
(cd compose/ && ./acceptance_jdbcconfig exec -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: run-acceptance-tests-jdbcconfig
run-acceptance-tests-jdbcconfig:
(cd compose/ && ./acceptance_jdbcconfig run --rm -T acceptance bash -c 'until [ -f /tmp/healthcheck ]; do echo "Waiting for /tmp/healthcheck to be available..."; sleep 5; done && pytest . -vvv --color=yes')

.PHONY: clean-acceptance-tests-jdbcconfig
clean-acceptance-tests-jdbcconfig:
Expand Down
14 changes: 14 additions & 0 deletions compose/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ services:
interval: 30s
timeout: 10s
retries: 5
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M

acceptance:
image: acceptance:${TAG}
Expand All @@ -39,6 +46,13 @@ services:
condition: service_healthy
acl:
condition: service_started
deploy:
mode: replicated
replicas: 0
resources:
limits:
cpus: "1.0"
memory: 512M

# For github CI
acl:
Expand Down

0 comments on commit 26d2c9d

Please sign in to comment.