Skip to content

Commit 3eb857a

Browse files
authored
Merge pull request #499 from basho/fixes/lrb/travis-ci
Add security tests to Travis CI
2 parents 8c592c1 + 78523c2 commit 3eb857a

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

.runner

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ function lint
5454

5555
function run_tests
5656
{
57+
local protocol="${1:-pbc}"
58+
export RIAK_TEST_PROTOCOL="$protocol"
5759
if [[ $have_tox == 'true' ]]
5860
then
5961
tox
@@ -73,16 +75,22 @@ function run_tests_each_protocol
7375
{
7476
for protocol in pbc http
7577
do
76-
export RIAK_TEST_PROTOCOL="$protocol"
77-
run_tests
78+
run_tests "$protocol"
7879
done
7980
}
8081

81-
function export_test_environment_vars
82+
function export_host_environment_vars
8283
{
8384
local riak_test_host="${RIAK_TEST_HOST:-localhost}"
8485
local -i riak_test_pb_port="${RIAK_TEST_PB_PORT:-8087}"
8586
local -i riak_test_http_port="${RIAK_TEST_HTTP_PORT:-8098}"
87+
export RIAK_TEST_HOST="$riak_test_host"
88+
export RIAK_TEST_PB_PORT="$riak_test_pb_port"
89+
export RIAK_TEST_HTTP_PORT="$riak_test_http_port"
90+
}
91+
92+
function export_test_environment_vars
93+
{
8694
export RUN_BTYPES=1
8795
export RUN_CLIENT=1
8896
export RUN_DATATYPES=1
@@ -92,19 +100,30 @@ function export_test_environment_vars
92100
export RUN_RESOLVE=1
93101
export RUN_TIMESERIES=1
94102
export RUN_YZ=1
95-
export RIAK_TEST_HOST="$riak_test_host"
96-
export RIAK_TEST_PB_PORT="$riak_test_pb_port"
97-
export RIAK_TEST_HTTP_PORT="$riak_test_http_port"
103+
}
104+
105+
function unexport_test_environment_vars
106+
{
107+
export RUN_BTYPES=0
108+
export RUN_CLIENT=0
109+
export RUN_DATATYPES=0
110+
export RUN_INDEXES=0
111+
export RUN_KV=0
112+
export RUN_MAPREDUCE=0
113+
export RUN_RESOLVE=0
114+
export RUN_TIMESERIES=0
115+
export RUN_YZ=0
98116
}
99117

100118
function security_test
101119
{
102120
if [[ $have_riak_admin == 'true' ]]
103121
then
104-
export_test_environment_vars
122+
export_host_environment_vars
123+
unexport_test_environment_vars
105124
export RUN_SECURITY=1
106125
$riak_admin security enable
107-
run_tests_each_protocol
126+
run_tests 'pbc'
108127
else
109128
echo '[ERROR] riak-admin must be in PATH, RIAK_ADMIN var set to path, or RIAK_DIR set.' 1>&2
110129
exit 1
@@ -113,6 +132,7 @@ function security_test
113132

114133
function integration_test
115134
{
135+
export_host_environment_vars
116136
export_test_environment_vars
117137
run_tests_each_protocol
118138
}

.travis.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
4+
flake8 --exclude=riak/pb riak *.py
5+
6+
sudo riak-admin security disable
7+
8+
python setup.py test
9+
10+
sudo riak-admin security enable
11+
12+
if [[ $RIAK_TEST_PROTOCOL == 'pbc' ]]
13+
then
14+
export RUN_SECURITY=1
15+
python setup.py test --test-suite riak.tests.test_security
16+
else
17+
echo '[INFO]: security tests run on PB protocol only'
18+
fi

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ python:
77
- '3.4'
88
- '3.5'
99
- nightly
10+
addons:
11+
hosts:
12+
- riak-test
1013
install:
1114
- pip install --upgrade pip setuptools flake8
1215
before_script:
1316
- sudo ./tools/travis-ci/riak-install -d "$RIAK_DOWNLOAD_URL"
14-
- sudo ./tools/setup-riak
17+
- sudo ./tools/setup-riak -s
1518
env:
1619
matrix:
1720
- RIAK_TEST_PROTOCOL=pbc RIAK_DOWNLOAD_URL=http://s3.amazonaws.com/downloads.basho.com/riak/2.0/2.0.7/ubuntu/trusty/riak_2.0.7-1_amd64.deb
@@ -29,9 +32,9 @@ env:
2932
- RUN_YZ=1
3033
- RUN_DATATYPES=1
3134
- RUN_INDEXES=1
35+
- RUN_SECURITY=0
3236
script:
33-
- flake8 --exclude=riak/pb riak *.py
34-
- python setup.py test
37+
- ./.travis.sh
3538
notifications:
3639
slack:
3740
secure: kU1XcvTAliCWKuYpMWEMbD4qkbmlnWGLAIKbBQjtIh5ZRzISgjdUFzGcC31eHoQFv12LQdp5KAFj0Y1FyEvLxi0W8VeWKpsBGc06ntuECaN9MNHRBzKKclrTMGTfpBWZ5IO17XSUu2lKaNz6GDGRkiZA+sxYAVPfZSXY3u86IuY=

riak/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def hostname_resolves(hostname):
4040
PROTOCOL = os.environ.get('RIAK_TEST_PROTOCOL', 'pbc')
4141

4242
PB_HOST = os.environ.get('RIAK_TEST_PB_HOST', HOST)
43-
PB_PORT = int(os.environ.get('RIAK_TEST_PB_PORT', '10017'))
43+
PB_PORT = int(os.environ.get('RIAK_TEST_PB_PORT', '8087'))
4444

4545
HTTP_HOST = os.environ.get('RIAK_TEST_HTTP_HOST', HOST)
46-
HTTP_PORT = int(os.environ.get('RIAK_TEST_HTTP_PORT', '10018'))
46+
HTTP_PORT = int(os.environ.get('RIAK_TEST_HTTP_PORT', '8098'))
4747

4848
# these ports are used to simulate errors, there shouldn't
4949
# be anything listening on either port.

0 commit comments

Comments
 (0)