blob: b0e99278ecade5a9921fe5c3fbf55a80efbab9c9 [file] [log] [blame]
#!/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