From 3ff10c204b89ca4fda14b1745e0fa86f2e13d5b6 Mon Sep 17 00:00:00 2001 From: Sietse Snel Date: Thu, 25 Jul 2024 08:52:19 +0200 Subject: [PATCH] YDA-5389: add smoke test This initial version of the smoke test just checks if the portal is responding at all. We might want to expand this later. --- .github/workflows/smoke-test.yml | 102 +++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/smoke-test.yml diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml new file mode 100644 index 00000000..32b73177 --- /dev/null +++ b/.github/workflows/smoke-test.yml @@ -0,0 +1,102 @@ +name: Run smoke test + +on: + push: + branches: + - development + - "**-str" + # We can force a smoke test run without opening a PR by pushing to a branch name that ends with "-str" + pull_request: + +jobs: + build: + runs-on: ubuntu-22.04 + if: | + ${{ ! contains(github.event.head_commit.message, '#nosmoketest') && + ( github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name + ) + }} + steps: + + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.8 + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + # We currently always use the development branch for the main Yoda repo. This can + # be customized later. + - name: Determine Yoda repository branch + run: | + echo "branch=release-1.9" >> $GITHUB_OUTPUT + id: yoda_repo_branch + + - name: Install test dependencies + run: | + sudo apt install -y docker-compose + + - name: Clone Yoda repo for Docker Setup + run: | + git clone -b "${{ steps.yoda_repo_branch.outputs.branch }}" --single-branch https://github.com/UtrechtUniversity/yoda.git + + - name: Prepare hosts file for API tests + run: | + sudo echo "127.0.0.1 portal.yoda eus.yoda data.yoda public.yoda" | sudo tee -a /etc/hosts + + - name: Start Dockerized Yoda + run: | + cd yoda/docker/compose + docker-compose pull + ../up.sh -d + + - name: Wait until Dockerized setup is ready or the maximum wait time has been reached + shell: bash + run: | + MAX_WAIT_TIME=120 + WAIT_INTERVAL=1 + WAIT_TIME=0 + while [ "$WAIT_TIME" -lt "$MAX_WAIT_TIME" ]; do if curl -k --output /dev/null --silent --head --fail https://portal.yoda:8443 ; then echo "Portal is up."; break; else; echo "Waiting for portal to start ($WAIT_TIME/$MAX_WAIT_TIME)"; fi; WAIT_TIME=$((WAIT_TIME + WAIT_INTERVAL)) ; sleep "$WAIT_TIME"; done + docker exec provider.yoda sh -c 'while ! pgrep irodsServer > /dev/null ; do echo Waiting for iRODS to start ... ; sleep 1; done' + + - name: Pull and install latest version of ruleset + shell: bash + run: | + cd yoda/docker/compose + docker exec provider.yoda sh -c 'set -x ; cd /etc/irods/yoda-ruleset && sudo chown irods:irods -R /etc/irods/yoda-ruleset && sudo -u irods git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && sudo -u irods git pull && sudo -u irods git status' + docker exec provider.yoda sh -c "set -x ; cd /etc/irods/yoda-ruleset && ( sudo -u irods git checkout ${{ steps.extract_branch.outputs.branch }} || sudo -u irods git checkout development) && sudo -u irods python -m pip --no-cache-dir install --user -r /etc/irods/yoda-ruleset/requirements.txt && sudo -u irods make && sudo -u irods make install" + docker exec provider.yoda sh -c "set -x ; sudo -u irods /var/lib/irods/irodsctl restart" + + - name: Pull and install branch version of the portal + shell: bash + run: | + cd yoda/docker/compose + docker exec portal.yoda sh -c 'set -x ; cd /var/www/yoda && git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git pull' + docker exec portal.yoda sh -c 'set -x ; cd /var/www/yoda && git checkout ${{ steps.extract_branch.outputs.branch }}' + docker exec portal.yoda sh -c 'set -x ; cd /var/www/yoda && git status' + docker exec portal.yoda sh -c 'set -x ; touch /var/www/yoda/*.wsgi' + + - name: Run smoke test + shell: bash + run: | + curl -k --fail --silent --output /dev/stdout https://portal.yoda:8443 + + - name: Output logs in case of failure + if: failure() + run: | + docker exec portal.yoda sh -c 'set -x; cat /var/log/apache2/error.log || echo "Apache error log file not found."' + docker exec provider.yoda sh -c 'set -x ; cat /var/lib/irods/log/rodsLog*' + +# Uncomment section below when needed for debugging. +# +# - name: Setup tmate session for debugging +# uses: mxschmitt/action-tmate@v3 +# if: ${{ failure() }} +# with: +# limit-access-to-actor: true