Skip to content

RockyLinux OS test of OpenQuake Engine #750

RockyLinux OS test of OpenQuake Engine

RockyLinux OS test of OpenQuake Engine #750

Workflow file for this run

name: RockyLinux OS test of OpenQuake Engine
on:
workflow_dispatch:
inputs:
git-ref:
description: Git Ref
default: master
required: true
schedule:
- cron: "0 13 * * *"
jobs:
install_and_test:
runs-on: ubuntu-latest
env:
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_DEF_BR: ${{ github.event.repository.default_branch }}
GITHUB_REF: ${{ github.ref }}
GITHUB_HD_REF: ${{ github.head_ref }}
GITHUB_BS_REF: ${{ github.base_ref }}
#more $GITHUB_EVENT_PATH
strategy:
matrix:
python-version: [3.8, 3.9]
#container: ["rockylinux:8", "ubuntu:focal"]
container: ["rockylinux:8"]
container:
image: ${{ matrix.container }}
steps:
# This Checkout use git-ref keyword from dispatch
- name: Clone Repository (Master)
uses: actions/checkout@v2
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v2
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Set up Python ${{ matrix.python-version }}
run: |
set -x
pyver=`echo ${{ matrix.python-version }} | tr -d .`
dnf update -y
dnf install -y python${pyver}
dnf install -y git git-lfs nc procps
pip3 -V
python3 -c "import sys; print(sys.version)"
#
- name: Install engine with install script
env:
BRANCH: ${{ github.event.inputs.git-ref }}
run: |
set -x
export PIP_DEFAULT_TIMEOUT=100
#
pip3 install --default-timeout=100 -U pip wheel setuptools
echo "branch to test: ${BRANCH}"
if [[ "$BRANCH" != "" ]]
then
pwd
cd ..
python3 oq-engine/install.py devel_server --version ${BRANCH}
else
python3 install.py devel_server
fi
- name: Run webui test
run: |
set -x
source /opt/openquake/venv/bin/activate
mkdir /var/log/oq-engine/
chown -R openquake /var/log/oq-engine/
runuser -l openquake -c '/opt/openquake/venv/bin/oq dbserver start &'
# Wait the DbServer to come up
echo "Waiting DBServer up on port 1907...."
while ! nc -z localhost 1907; do
sleep 5 # wait
done
echo "Add settings for login and logging on webui before to start"
cd /__w/oq-engine/oq-engine/
cd openquake/server
cat > local_settings.py << EOF
LOCKDOWN = True
#
WEBUI_ACCESS_LOG_DIR = '/var/log/oq-engine'
EOF
echo "DISPLAY content of local_settings"
cat local_settings.py
# START WEBUI
runuser -l openquake -c '/opt/openquake/venv/bin/oq webui start -s &'
echo "Waiting WEBUI up on port 8800...."
while ! nc -z localhost 8800; do
sleep 5
done
ls -lrt /var/log/oq-engine/
sleep 1
# Perform migration after setup local_settings
cd /__w/oq-engine/oq-engine/openquake/engine/
runuser -l openquake -c '/opt/openquake/venv/bin/oq webui migrate'
sleep 1
curl --fail -L -I -X GET http://127.0.0.1:8800/accounts/login/
echo -n "TEST DJANGO LOGIN "
LOGIN_URL=http://127.0.0.1:8800/accounts/login/
YOUR_USER='username'
YOUR_PASS='password'
COOKIES=cookies.txt
CURL_BIN="curl --fail -s -c $COOKIES -b $COOKIES -e $LOGIN_URL"
echo -n "Django Auth: get csrftoken ..."
$CURL_BIN $LOGIN_URL > /dev/null
DJANGO_TOKEN="csrfmiddlewaretoken=$(grep csrftoken $COOKIES | sed 's/^.*csrftoken\s*//')"
echo " perform login ..."
$CURL_BIN \
-d "$DJANGO_TOKEN&username=$YOUR_USER&password=$YOUR_PASS" \
-X POST $LOGIN_URL > /dev/null
echo "--------------------"
echo "display log of webui"
echo "--------------------"
cat /var/log/oq-engine/webui-access.log
echo "test WebUI tools"
sleep 5
cd /__w/oq-engine/oq-engine/
cd openquake/server
cat > local_settings.py
echo "DISPLAY content of local_settings"
cat local_settings.py
# RESTART WEBUI
pkill oq-webui
runuser -l openquake -c '/opt/openquake/venv/bin/oq webui start -s &'
echo "Waiting WEBUI up on port 8800...."
while ! nc -z localhost 8800; do
sleep 5
done
curl --fail -I -L -X GET http://127.0.0.1:8800/
sleep 1
curl --fail -I -L -X GET http://127.0.0.1:8800/taxtweb
sleep 1
curl --fail -I -L -X GET http://127.0.0.1:8800/taxonomy
sleep 1
curl --fail -I -L -X GET http://127.0.0.1:8800/ipt
- name: Run tests
run: |
source /opt/openquake/venv/bin/activate
pip install pytest
runuser -l openquake -c '/opt/openquake/venv/bin/oq dbserver start &'
export PYTEST_ADDOPTS="--color=yes"
# set owner to openquake to run test and create cache for pytest
chown -R openquake /__w/oq-engine/
runuser -l openquake -c 'cd /__w/oq-engine/oq-engine/openquake/ && /opt/openquake/venv/bin/pytest -vsx --color=yes hazardlib/tests/gsim/kotha_2020_test.py sep sep/tests/test_utils.py'
runuser -l openquake -c '/opt/openquake/venv/bin/oq engine --run https://downloads.openquake.org/jobs/risk_test.zip '