-
Notifications
You must be signed in to change notification settings - Fork 182
/
.runner
executable file
·162 lines (145 loc) · 3.12 KB
/
.runner
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
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env bash
set -o errexit
set -o nounset
have_tox='false'
if hash tox 2>/dev/null
then
echo '[INFO] tox command present, will use that to run tests'
have_tox='true'
fi
have_py2='false'
if hash python2 2>/dev/null
then
have_py2='true'
fi
have_py3='false'
if hash python3 2>/dev/null
then
have_py3='true'
fi
have_riak_admin='false'
if hash riak-admin 2>/dev/null
then
have_riak_admin='true'
$riak_admin='riak-admin'
else
set +o nounset
if [[ -x $RIAK_ADMIN ]]
then
have_riak_admin='true'
riak_admin="$RIAK_ADMIN"
elif [[ -x $RIAK_DIR/bin/riak-admin ]]
then
have_riak_admin='true'
riak_admin="$RIAK_DIR/bin/riak-admin"
fi
set -o nounset
fi
function lint
{
if ! hash flake8 2>/dev/null
then
pip install --upgrade flake8
fi
flake8 --exclude=riak/pb riak *.py
}
function run_tests
{
local protocol="${1:-pbc}"
export RIAK_TEST_PROTOCOL="$protocol"
if [[ $have_tox == 'true' ]]
then
tox
else
if [[ $have_py2 == 'true' ]]
then
python2 setup.py test
fi
if [[ $have_py3 == 'true' ]]
then
python3 setup.py test
fi
fi
}
function run_tests_each_protocol
{
for protocol in pbc http
do
run_tests "$protocol"
done
}
function export_host_environment_vars
{
local riak_test_host="${RIAK_TEST_HOST:-localhost}"
local -i riak_test_pb_port="${RIAK_TEST_PB_PORT:-8087}"
local -i riak_test_http_port="${RIAK_TEST_HTTP_PORT:-8098}"
export RIAK_TEST_HOST="$riak_test_host"
export RIAK_TEST_PB_PORT="$riak_test_pb_port"
export RIAK_TEST_HTTP_PORT="$riak_test_http_port"
}
function export_test_environment_vars
{
export RUN_BTYPES=1
export RUN_CLIENT=1
export RUN_DATATYPES=1
export RUN_INDEXES=1
export RUN_KV=1
export RUN_MAPREDUCE=1
export RUN_RESOLVE=1
export RUN_TIMESERIES=1
export RUN_YZ=1
}
function unexport_test_environment_vars
{
export RUN_BTYPES=0
export RUN_CLIENT=0
export RUN_DATATYPES=0
export RUN_INDEXES=0
export RUN_KV=0
export RUN_MAPREDUCE=0
export RUN_RESOLVE=0
export RUN_TIMESERIES=0
export RUN_YZ=0
}
function security_test
{
if [[ $have_riak_admin == 'true' ]]
then
export_host_environment_vars
unexport_test_environment_vars
export RUN_SECURITY=1
$riak_admin security enable
run_tests 'pbc'
else
echo '[ERROR] riak-admin must be in PATH, RIAK_ADMIN var set to path, or RIAK_DIR set.' 1>&2
exit 1
fi
}
function integration_test
{
export_host_environment_vars
export_test_environment_vars
run_tests_each_protocol
}
function timeseries_test
{
unexport_test_environment_vars
export RUN_TIMESERIES=1
run_tests_each_protocol
}
arg="${1:-lint}"
case "$arg" in
'lint')
lint;;
'unit-test')
run_tests;;
'integration-test')
integration_test;;
'security-test')
security_test;;
'timeseries-test')
timeseries_test;;
*)
echo "[ERROR] unknown argument: '$arg'" 1>&2
exit 1;;
esac