-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-provider.sh
87 lines (67 loc) · 1.88 KB
/
test-provider.sh
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
#!/bin/bash
provider=$1
signed=$2
regpath=$3
showcols=$4
anoncolcheck=$5
if [ -z "$provider" ]; then
echo "provider (arg 1) must be set"
exit 1
fi
if [ -z "$signed" ]; then
echo "signed (arg 2) must be set (true/false))"
exit 1
else
SIGNED=$signed
fi
echo "testing provider: $provider"
if [ -z "$regpath" ]; then
regpath=$(pwd)
fi
echo "registry path: $regpath"
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# install packages
pip install pandas
pip install psycopg[binary]
# download and unzip stackql binary
if [ ! -f stackql ]
then
wget -q https://releases.stackql.io/stackql/latest/stackql_linux_amd64.zip
unzip stackql_linux_amd64.zip
fi
chmod +x stackql
# show version
./stackql --version
# do checks
# set registry path
if [ "$SIGNED" = "true" ]; then
REG='{"url": "file://'${regpath}'", "localDocRoot": "'${regpath}'", "verifyConfig": {"nopVerify": false}}'
else
REG='{"url": "file://'${regpath}'", "localDocRoot": "'${regpath}'", "verifyConfig": {"nopVerify": true}}'
fi
# start the server if not running
echo "checking if server is running"
if ! pgrep -f "stackql --registry=" > /dev/null; then
echo "starting server with registry: $REG"
nohup ./stackql --registry="${REG}" --pgsrv.port=5444 srv &> stackql.log &
STACKQL_PID=$! # Capture the server process ID
echo "stackql server started with PID: $STACKQL_PID"
sleep 5
else
echo "server is already running"
STACKQL_PID=$(pgrep -f "stackql --registry=")
echo "existing stackql server PID: $STACKQL_PID"
fi
if [ -z "$showcols" ]; then
python3 test-provider.py $provider
else
python3 test-provider.py $provider $showcols
# TODO implement anoncolcheck for server tests
fi
# Deactivate virtual environment
# deactivate
echo "stopping server with PID: $STACKQL_PID"
kill -9 $STACKQL_PID
echo "stackql server stopped"