-
Notifications
You must be signed in to change notification settings - Fork 336
/
integration-tests.sh
executable file
·95 lines (81 loc) · 3.16 KB
/
integration-tests.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
88
89
90
91
92
93
94
95
#!/bin/bash -e
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BASE_DIR=$DIR/..
TEST_DIR=$1
FAILURE_TEST_TYPE=$2
if test -z "$TEST_DIR"; then
echo
echo " USAGE:"
echo
echo " ${BASH_SOURCE[0]##*/} \"<dirname to run tests in>\" [zopkio args...]"
echo
exit 0
fi
# always use absolute paths for ABS_TEST_DIR
ABS_TEST_DIR=$(cd $(dirname $TEST_DIR); pwd)/$(basename $TEST_DIR)
SCRIPTS_DIR=$ABS_TEST_DIR/scripts
# safety check for virtualenv
if [ -f $HOME/.pydistutils.cfg ]; then
echo "Virtualenv can't run while $HOME/.pydistutils.cfg exists."
echo "Please remove $HOME/.pydistutils.cfg, and try again."
exit 0
fi
# build integration test tarball
./gradlew releaseTestJobs
# create integration test directory
mkdir -p $ABS_TEST_DIR
rm -rf $SCRIPTS_DIR
cp -r samza-test/src/main/python/ $SCRIPTS_DIR
cp ./samza-test/build/distributions/samza-test*.tgz $ABS_TEST_DIR
cd $ABS_TEST_DIR
# setup virtualenv locally if it's not already there
VIRTUAL_ENV=virtualenv-15.0.1
if [[ ! -d "${ABS_TEST_DIR}/${VIRTUAL_ENV}" ]] ; then
# using --location to follow any redirects
curl -O --location https://pypi.python.org/packages/source/v/virtualenv/$VIRTUAL_ENV.tar.gz
tar xvfz $VIRTUAL_ENV.tar.gz
fi
# build a clean virtual environment
SAMZA_INTEGRATION_TESTS_DIR=$ABS_TEST_DIR/samza-integration-tests
if [[ ! -d "${SAMZA_INTEGRATION_TESTS_DIR}" ]] ; then
python $VIRTUAL_ENV/virtualenv.py $SAMZA_INTEGRATION_TESTS_DIR
fi
# activate the virtual environment
source $SAMZA_INTEGRATION_TESTS_DIR/bin/activate
# install zopkio and requests
pip install -r $SCRIPTS_DIR/requirements.txt
# treat all trailing parameters (after dirname, test_type) as zopkio switches
SWITCHES="${@:3}"
# default to info-level debugging if not specified
if [[ $SWITCHES != *"console-log-level"* ]]; then
SWITCHES="$SWITCHES --console-log-level INFO"
fi
if [[ ${FAILURE_TEST_TYPE} == "yarn-integration-tests" ]]; then
echo "Running yarn integration tests."
zopkio --config-overrides remote_install_path=$ABS_TEST_DIR $SWITCHES $SCRIPTS_DIR/integration_tests.py
elif [[ ${FAILURE_TEST_TYPE} == "standalone-integration-tests" ]]; then
echo "Running standalone integration tests."
zopkio --config-overrides remote_install_path=$ABS_TEST_DIR $SWITCHES $SCRIPTS_DIR/standalone_integration_tests.py
else
echo "Invalid failure test type: $FAILURE_TEST_TYPE"
exit -1
fi
# go back to execution directory
deactivate
cd $DIR