-
Notifications
You must be signed in to change notification settings - Fork 277
149 lines (148 loc) · 5.56 KB
/
webui_rh_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
name: Test WebUI on RH based OS
on:
workflow_dispatch:
inputs:
git-ref:
description: Git Ref Branch
default: master
required: true
schedule:
- cron: "05 15 * * *"
jobs:
test_ui:
name: Test on RH based (fedora container)
runs-on: ubuntu-latest
env:
GITHUB_DEF_BR: ${{ github.event.repository.default_branch }}
strategy:
matrix:
python-version: [python3.11]
req-version: [py311]
container:
image: fedora:39
options: --privileged
steps:
- name: Clone Repository (Master)
uses: actions/checkout@v4
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v4
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Set up Python ${{ matrix.python-version }} and install OQ
run: |
set -x
if [ -z ${{ github.event.inputs.git-ref }} ];
then
BRANCH=master
else
BRANCH=${{ github.event.inputs.git-ref }}
fi
# Add openquake user
useradd -m -u 1000 -s /bin/bash openquake
# update system and install utilities
dnf update -y
dnf install -y ${{ matrix.python-version }}
dnf install -y git git-lfs nc procps
# define it
mypython=${{ matrix.python-version }}
reqpython=${{ matrix.req-version }}
#run it
eval '$mypython -c "import sys; print(sys.version)"'
#
# Add PIP to $mypython
eval '$mypython -m ensurepip --upgrade'
export PIP_DEFAULT_TIMEOUT=100
#
echo "branch to test: ${BRANCH}"
cd /__w/oq-engine/oq-engine/
eval '$mypython -m pip install -U pip setuptools wheel'
eval '$mypython -m venv /opt/openquake/venv '
source /opt/openquake/venv/bin/activate
eval '$mypython -m pip install -r "requirements-$reqpython-linux64.txt"'
eval '$mypython -m pip install -e . '
## Standalone apps
echo "Downloading standalone apps"
for app in oq-platform-standalone oq-platform-ipt oq-platform-taxtweb oq-platform-taxonomy; do
git clone -b ${BRANCH} --depth=1 https://github.com/gem/${app}.git
eval '$mypython -m pip install -e ./${app}'
if [ "$app" = "oq-platform-taxtweb" ]; then
export PYBUILD_NAME="oq-taxonomy"
eval '$mypython -m pip install -e ./${app}'
unset PYBUILD_NAME
fi
done
deactivate
- name: Test WebUI and run https calculation
run: |
set -x
source /opt/openquake/venv/bin/activate
pip freeze
mkdir /var/log/oq-engine/
chown -R openquake /var/log/oq-engine/
runuser -l openquake -c '/opt/openquake/venv/bin/oq dbserver upgrade &'
# Wait the DbServer to come up
#echo "Waiting DBServer up on port 1907...."
#while ! nc -z localhost 1907; do
# sleep 2 # wait for 1/10 of the second before check again
#done
#sleep 3
oq --version
#
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 127.0.0.1:8800 -s &'
echo "Waiting WEBUI up on port 8800...."
while ! nc -z localhost 8800; do
sleep 5 # wait for 1/10 of the second before check again
done
echo "Test WebUI with curl before to test django"
sleep 1
# Perform migration after setup local_settings
cd /__w/oq-engine/oq-engine/openquake/engine/
runuser -l openquake -c 'cd /__w/oq-engine/oq-engine/openquake/server/; /opt/openquake/venv/bin/python3 manage.py migrate'
sleep 1
curl --fail -L -I -X GET http://127.0.0.1:8800/accounts/login/
echo -n "Test Standalone Tools pages"
curl --fail -I -L -X GET http://127.0.0.1:8800/
curl --fail -I -L -X GET http://127.0.0.1:8800/taxtweb
curl --fail -I -L -X GET http://127.0.0.1:8800/taxonomy
curl --fail -I -L -X GET http://127.0.0.1:8800/ipt
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 -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
if [ -s /var/log/oq-engine/webui-access.log ]; then
# The file is not-empty.
cat /var/log/oq-engine/webui-access.log
else
## The file is empty.
echo "Something not work as expected"
exit 1
fi
# Run a calcs using https
oq engine --run https://downloads.openquake.org/jobs/risk_test.zip