diff --git a/.github/workflows/docker-stack-test.yml b/.github/workflows/docker-stack-test.yml new file mode 100644 index 00000000000..b76dc605d3c --- /dev/null +++ b/.github/workflows/docker-stack-test.yml @@ -0,0 +1,97 @@ +name: Docker-Stack-Test + +on: + # every Monday at 4:30 AM + + schedule: + - cron: '30 4 * * 1' + + +env: + R_LIBS_USER: /usr/local/lib/R/site-library + LC_ALL: en_US.UTF-8 + NCPUS: 2 + PGHOST: postgres + CI: true + +jobs: + + + # ---------------------------------------------------------------------- + # DOCKER STACK TESTS + # ---------------------------------------------------------------------- + Stack-Test: + + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + strategy: + fail-fast: false + + + services: + postgres: + image: mdillon/postgis:9.5 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + container: + image: pecan/depends + + steps: + # checkout source code + - name: work around https://github.com/actions/checkout/issues/766 + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - uses: actions/checkout@v3 + with: + set-safe-directory: false + + - name: Set up Docker Compose + run: | + sudo apt-get update + sudo apt-get -y install docker-compose + - name: Build and run containers + run: | + docker system prune --all --force + cp docker/env.example .env + echo "COMPOSE_PROJECT_NAME=pecan" >> .env + echo "PECAN_VERSION=develop" >> .env + echo "UID=$(id -u)" >> .env + echo "GID=$(id -g)" >> .env + docker-compose up -d postgres + docker run --rm --network pecan_pecan pecan/db + + docker-compose run bety user guestuser guestuser "Guest User" guestuser@example.com 4 4 + + docker-compose run bety user carya illinois "Carya Demo User" carya@example.com 1 1 + docker run --rm --network pecan_pecan --volume pecan_pecan:/data --env FQDN=docker pecan/data:develop + docker run --rm --network pecan_pecan --volume pecan_pecan:/data pecan/data:develop chown -R "$(id -u).$(id -g)" /data + + docker run --user="$(id -u)" --rm --network pecan_pecan --volume pecan_pecan:/data --env FQDN=docker pecan/data:develop + + docker-compose up -d + + + - name: Wait for services to start + run: | + + docker-compose ps + sleep 20 # Adjust the duration as needed + docker-compose ps + sleep 20 + docker-compose ps + sleep 20 + + + - name: Display running containers + run: | + docker-compose ps + docker network ls + docker network inspect bridge + + # run tests against the full docker stack + - name: Run Integration Test + run: | + chmod +x ./tests/Docker-Stack-Test.sh + ./tests/Docker-Stack-Test.sh + diff --git a/docker-compose.yml b/docker-compose.yml index 180c5653834..a093b940ba0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -300,6 +300,7 @@ services: api: image: pecan/api:${PECAN_VERSION:-latest} user: "${UID:-1001}:${GID:-1001}" + restart: unless-stopped networks: - pecan environment: diff --git a/tests/Docker-Stack-Test.sh b/tests/Docker-Stack-Test.sh new file mode 100644 index 00000000000..61a31fdb7e0 --- /dev/null +++ b/tests/Docker-Stack-Test.sh @@ -0,0 +1,47 @@ +curl -v -L -X POST -H "Host: pecan.localhost" \ + -F 'hostname=docker' \ + -F 'modelid=1000000014' \ + -F 'sitegroupid=1' \ + -F 'siteid=756' \ + -F 'sitename=Duke Forest - loblolly pine (US-Dk3)' \ + -F 'pft[]=temperate.coniferous' \ + -F 'start=2004/01/01' \ + -F 'end=2004/12/31' \ + -F 'input_met=CRUNCEP' \ + -F 'email=' \ + -F 'notes=' \ +'http://172.17.0.1/pecan/04-runpecan.php' + +sleep 200 + +curl -v -L -H "Host: pecan.localhost" \ +'http://172.17.0.1/pecan/dataset.php?workflowid=99000000001&type=file&name=out/99000000001/sipnet.out' + + +# ----------------------------------------------- +# cURL Request Template +#----------------------------------------------- + +# Be sure to use the -H header and also use the bridge IP address of the Docker host (172.17.0.1) and not localhost + + +# curl -v -L -X POST -H "Host: pecan.localhost" \ +# -F 'hostname=' \ +# -F 'modelid=' \ +# -F 'sitegroupid=' \ +# -F 'siteid=' \ +# -F 'sitename=' \ +# -F 'pft[]=' \ +# -F 'start=' \ +# -F 'end=' \ +# -F 'input_met=' \ +# -F 'email=' \ +# -F 'notes=' \ +# 'http://172.17.0.1/pecan/04-runpecan.php' + +# Adjust the sleep time according to the model you are running + +# Append the workflowid and ID after `out/` by 1 for every consecutive run + +# curl -v -L -H "Host: pecan.localhost" \ +# 'http://172.17.0.1/pecan/dataset.php?workflowid=(ID)&type=file&name=out/(ID)/sipnet.out' \ No newline at end of file