forked from aleph-zero-foundation/aleph-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_python_general.sh
More file actions
executable file
·84 lines (75 loc) · 2.13 KB
/
test_python_general.sh
File metadata and controls
executable file
·84 lines (75 loc) · 2.13 KB
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
#!/usr/bin/env bash
# This script is used for running e2e tests via python framework, and intended to run in CI
set -euo pipefail
function usage(){
cat << EOF
Usage:
$0
--aleph-node BINARY
path to aleph-node binary
--chain-bootstrapper BINARY
path to chain-bootstrapper binary
--testcase NAME
name of python file in local-tests directory to run
EOF
exit 0
}
while [[ $# -gt 0 ]]; do
case "$1" in
--aleph-node)
ALEPH_NODE_BINARY="$2"
shift;shift
;;
--chain-bootstrapper)
CHAIN_BOOTSTRAPPER="$2"
shift;shift
;;
--testcase)
TESTCASE="$2"
shift;shift
;;
--help)
usage
shift
;;
*)
echo "Unrecognized argument $1!"
;;
esac
done
# relative paths should be improved in python scripts CI, as it matters that below line is
pushd local-tests/ > /dev/null
if [[ ! -f "${ALEPH_NODE_BINARY}" ]]; then
echo "Error: aleph-node binary does not exist at given path ${ALEPH_NODE_BINARY}"
exit 1
fi
if [[ ! -f "${CHAIN_BOOTSTRAPPER}" ]]; then
echo "Error: chain-bootstrapper binary does not exist at given path ${CHAIN_BOOTSTRAPPER}"
exit 1
fi
if [[ -z "${TESTCASE}" ]]; then
echo "Error: TESTCASE name must not be empty."
exit 1
fi
file_name_to_run="${TESTCASE}.py"
if [[ ! -x "${file_name_to_run}" ]]; then
echo "Error: testcase ${file_name_to_run} does not exist or it's not executable."
popd > /dev/null
exit 1
fi
chmod +x "${ALEPH_NODE_BINARY}"
chmod +x "${CHAIN_BOOTSTRAPPER}"
echo "Installing python requirements"
pip install -r requirements.txt
# https://stackoverflow.com/questions/59812009/what-is-the-use-of-pythonunbuffered-in-docker-file
# Setting PYTHONUNBUFFERED to a non-empty value different from 0 ensures that the python output i.e.
# the stdout and stderr streams are sent straight to terminal (e.g. your container log) without being
# first buffered and that you can see the output of your application.
export PYTHONUNBUFFERED=y
export ALEPH_NODE_BINARY
export CHAIN_BOOTSTRAPPER
export RUST_LOG=debug
export WORKDIR=$(mktemp -d)
echo "WORKDIR is ${WORKDIR}"
eval "./${file_name_to_run}"
popd > /dev/null