From 02ccedd29b92612fce612c523395ec17d93ab7f2 Mon Sep 17 00:00:00 2001 From: hubertdeng123 Date: Tue, 5 Mar 2024 16:36:01 -0800 Subject: [PATCH] integration test improvements --- .github/workflows/test.yml | 8 +++++++- _integration-test/run.sh | 10 +++++++--- integration-test.sh | 36 ++++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb70139ddd..b3f6af6b00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,6 +64,7 @@ jobs: compose_path: "/usr/local/lib/docker/cli-plugins" - compose_version: "v2.7.0" compose_path: "/usr/local/lib/docker/cli-plugins" + test-group: ["initial-install", "customizations"] env: COMPOSE_PROJECT_NAME: self-hosted-${{ strategy.job-index }} steps: @@ -83,7 +84,12 @@ jobs: sudo chmod +x "${{ matrix.compose_path }}/docker-compose" - name: Integration Test - run: ./integration-test.sh + uses: nick-fields/retry@v3 + with: + max_attempts: 3 + timeout_minutes: 25 + retry_on: error + command: ./integration-test.sh --${{ matrix.test-group }} - name: Inspect failure if: failure() diff --git a/_integration-test/run.sh b/_integration-test/run.sh index 4c7ef9beae..339c403578 100755 --- a/_integration-test/run.sh +++ b/_integration-test/run.sh @@ -28,7 +28,11 @@ teardown() { DID_TEAR_DOWN=1 if [ "$1" != "EXIT" ]; then - echo "An error occurred, caught SIG$1 on line $2" + error_msg="An error occurred, caught SIG$1 on line $2" + echo "$error_msg" + dsn="https://5a620019b5124cbba230a9e62db9b825@o1.ingest.us.sentry.io/6627632" + sentry_cli="docker run --rm -v /tmp:/work -e SENTRY_DSN=$dsn getsentry/sentry-cli" + $sentry_cli send-event -m "$error_msg" --logfile "$log_file" fi echo "Tearing down ..." @@ -41,10 +45,10 @@ echo "${_endgroup}" echo "${_group}Starting Sentry for tests ..." # Disable beacon for e2e tests echo 'SENTRY_BEACON=False' >>$SENTRY_CONFIG_PY -echo y | $dcr web createuser --force-update --superuser --email $TEST_USER --password $TEST_PASS $dc up -d -printf "Waiting for Sentry to be up" timeout 90 bash -c 'until $(curl -Isf -o /dev/null $SENTRY_TEST_HOST); do printf '.'; sleep 0.5; done' +echo y | $dc exec web sentry createuser --force-update --superuser --email $TEST_USER --password $TEST_PASS +printf "Waiting for Sentry to be up" echo "" echo "${_endgroup}" diff --git a/integration-test.sh b/integration-test.sh index 10477f2798..69761034bf 100755 --- a/integration-test.sh +++ b/integration-test.sh @@ -6,24 +6,32 @@ rm -f sentry/enhance-image.sh rm -f sentry/requirements.txt export REPORT_SELF_HOSTED_ISSUES=0 -echo "Testing initial install" -./install.sh -_integration-test/run.sh -_integration-test/ensure-customizations-not-present.sh -_integration-test/ensure-backup-restore-works.sh +test_option="$1" -echo "Make customizations" -cat <sentry/enhance-image.sh +if [[ "$test_option" == "--initial-install" ]]; then + echo "Testing initial install" + ./install.sh + _integration-test/run.sh + _integration-test/ensure-customizations-not-present.sh + _integration-test/ensure-backup-restore-works.sh +elif [[ "$test_option" == "--customizations" ]]; then + echo "Testing customizations" + ./install.sh + source install/dc-detect-version.sh + $dc up -d + echo "Making customizations" + cat <sentry/enhance-image.sh #!/bin/bash touch /created-by-enhance-image apt-get update apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev EOT -chmod +x sentry/enhance-image.sh -printf "python-ldap" >sentry/requirements.txt + chmod +x sentry/enhance-image.sh + printf "python-ldap" >sentry/requirements.txt -echo "Testing in-place upgrade and customizations" -./install.sh --minimize-downtime -_integration-test/run.sh -_integration-test/ensure-customizations-work.sh -_integration-test/ensure-backup-restore-works.sh + echo "Testing in-place upgrade and customizations" + ./install.sh --minimize-downtime + _integration-test/run.sh + _integration-test/ensure-customizations-work.sh + _integration-test/ensure-backup-restore-works.sh +fi