From 525d08408dbb8aef405e4841289274500ddd0da0 Mon Sep 17 00:00:00 2001 From: Siwan Yang <123605713+siwany@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:47:28 -0400 Subject: [PATCH] Update test.sh/test.yml (#7) * add listener * update listener * inventory listener update * edit minor part * test case update * update inventory test 2 * 3 test cases * EndpointIT * test.sh * update test.sh * testApp.sh * testApp.sh final * delete scripts * test.yml updates --- .github/workflows/test.yml | 75 +++++++++++++++++++++++++++++++ finish/scripts/buildImages.sh | 10 ----- finish/scripts/packageApps.sh | 9 ---- finish/scripts/startContainers.sh | 41 ----------------- finish/scripts/stopContainers.sh | 9 ---- scripts/testApp.sh | 29 ++++++++++++ 6 files changed, 104 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100755 finish/scripts/buildImages.sh delete mode 100755 finish/scripts/packageApps.sh delete mode 100755 finish/scripts/startContainers.sh delete mode 100755 finish/scripts/stopContainers.sh create mode 100755 scripts/testApp.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b06d0d4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,75 @@ +name: Test application + +on: + pull_request: + branches: [ prod, staging, draft ] + +jobs: + check-files: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + outputs: + canSkip: ${{ steps.Checker.outputs.canSkip }} + steps: + - name: Get files + uses: actions/checkout@v2 + - name: Get tools + uses: actions/checkout@v2 + with: + path: tools/ + repository: openliberty/guides-common + - id: Checker + shell: bash + run: bash ./tools/pr-checker/checker.sh ${{ github.repository }} ${{ github.event.pull_request.number }} | tee checker.log + - id: Lint-Code-Base + if: "! github.event.pull_request.head.repo.fork" + uses: github/super-linter@latest + env: + VALIDATE_ALL_CODEBASE: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: ./tools/pr-checker/linters/ + DEFAULT_BRANCH: draft + - name: Summary + if: "! github.event.pull_request.head.repo.fork" + run: | + < ./checker.log tail -n +2; echo "====== Super Linter ======" + < ./super-linter.log sed -n '/.*The script has completed.*/,$p' | tail -n +4 | sed 's/.*\(\[[A-Z]\+\]\)/\1/' + echo "====== Examine logs in Checker and Super-Linter steps for more details ======" + if [ '${{ steps.Checker.outcome }}' != 'success' ] || [ '${{ steps.Lint-Code-Base.outcome }}' != 'success' ]; then exit 1; fi + test-app: + runs-on: ubuntu-latest + needs: [check-files] + if: "!contains(needs.check-files.outputs.canSkip, 'true')" + defaults: + run: + working-directory: finish + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - run: unset _JAVA_OPTIONS + - name: Run tests + run: | + chmod +x ../scripts/testApp.sh + sudo ../scripts/testApp.sh + - name: Post tests + if: always() + run: | + logsPath=$(sudo find . -name "console.log" | grep inventory); + sudo cat "$logsPath" | sudo grep Launching + logsPath=$(sudo find . -name "console.log" | grep system); + sudo cat "$logsPath" | sudo grep Launching + - name: Archive finish inventory logs if failed + if: failure() + uses: actions/upload-artifact@v2 + with: + name: finish-inventory-logs + path: finish/inventory/target/liberty/wlp/usr/servers/defaultServer/logs/ + - name: Archive finish system logs if failed + if: failure() + uses: actions/upload-artifact@v2 + with: + name: finish-system-logs + path: finish/system/target/liberty/wlp/usr/servers/defaultServer/logs/ diff --git a/finish/scripts/buildImages.sh b/finish/scripts/buildImages.sh deleted file mode 100755 index cc9d8a0..0000000 --- a/finish/scripts/buildImages.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -echo Building images - -docker build -t command:1.0-SNAPSHOT command/. & -docker build -t query:1.0-SNAPSHOT query/. & -docker build -t inventory:1.0-SNAPSHOT inventory/. & -wait - -echo Images building completed diff --git a/finish/scripts/packageApps.sh b/finish/scripts/packageApps.sh deleted file mode 100755 index 06abcb4..0000000 --- a/finish/scripts/packageApps.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -mvn -ntp -Dhttp.keepAlive=false \ - -Dmaven.wagon.http.pool=false \ - -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ - -pl models clean install -mvn -ntp -Dhttp.keepAlive=false \ - -Dmaven.wagon.http.pool=false \ - -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ - -q clean package diff --git a/finish/scripts/startContainers.sh b/finish/scripts/startContainers.sh deleted file mode 100755 index d8a4127..0000000 --- a/finish/scripts/startContainers.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -NETWORK=cqrs-app - -docker network create $NETWORK - -docker run -d \ - --network=$NETWORK \ - --name postgres-container \ - --rm \ - postgres-sample --max_prepared_transactions=100 - -sleep 10 - -docker run -d \ - -e POSTGRES_HOSTNAME=postgres-container \ - -e QUERY_JMS_ADDRESS=query:7277 \ - --network=$NETWORK \ - --name=command \ - --rm \ - command:1.0-SNAPSHOT & - -docker run -d \ - -e POSTGRES_HOSTNAME=postgres-container \ - -e CACHE_JMS_ADDRESS=inventory:7278 \ - --network=$NETWORK \ - --name=query \ - --rm \ - query:1.0-SNAPSHOT & - -docker run -d \ - -e COMMAND_JMS_ADDRESS=command:7276 \ - -p 9080:9080 \ - --network=$NETWORK \ - --name=inventory \ - --rm \ - inventory:1.0-SNAPSHOT & - -wait - -sleep 10 diff --git a/finish/scripts/stopContainers.sh b/finish/scripts/stopContainers.sh deleted file mode 100755 index 7c2d882..0000000 --- a/finish/scripts/stopContainers.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -docker stop command query inventory postgres-container - -docker network rm cqrs-app - -docker ps - -docker container ls -a diff --git a/scripts/testApp.sh b/scripts/testApp.sh new file mode 100755 index 0000000..9e9ff60 --- /dev/null +++ b/scripts/testApp.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euxo pipefail + +mvn -pl models clean install + +mvn -ntp -Dhttp.keepAlive=false \ + -Dmaven.wagon.http.pool=false \ + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ + -pl system -q clean package liberty:create liberty:install-feature liberty:deploy + +mvn -ntp -Dhttp.keepAlive=false \ + -Dmaven.wagon.http.pool=false \ + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ + -pl inventory -q clean package liberty:create liberty:install-feature liberty:deploy + +mvn -ntp -pl inventory liberty:start +sleep 10 +mvn -ntp -pl system liberty:start +sleep 15 + +mvn -ntp -Dhttp.keepAlive=false \ + -Dmaven.wagon.http.pool=false \ + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ + -pl inventory failsafe:integration-test + +mvn -ntp -pl inventory failsafe:verify + +mvn -pl system liberty:stop +mvn -pl inventory liberty:stop