List dependencies for services - add integration test to verify

This commit is contained in:
Bert Blommers 2020-09-13 16:08:23 +01:00
commit db1d7123f6
41 changed files with 1405 additions and 1245 deletions

65
scripts/int_test.sh Executable file
View file

@ -0,0 +1,65 @@
overwrite() { echo -e "\r\033[1A\033[0K$@"; }
contains() {
[[ $1 =~ (^|[[:space:]])$2($|[[:space:]]) ]] && return 0 || return 1
}
valid_service() {
# Verify whether this is a valid service
# We'll ignore metadata folders, and folders that test generic Moto behaviour
# We'll also ignore CloudFormation, as it will always depend on other services
local ignore_moto_folders="core instance_metadata __pycache__ templates cloudformation"
if echo $ignore_moto_folders | grep -q "$1"; then
return 1
else
return 0
fi
}
test_service() {
service=$1
path_to_test_file=$2
venv_path="test_venv_${service}"
overwrite "Running tests for ${service}.."
virtualenv ${venv_path} -p `which python3` > /dev/null
source ${venv_path}/bin/activate > /dev/null
# Can't just install requirements-file, as it points to all dependencies
pip install -r requirements-tests.txt > /dev/null
pip install .[$service] > /dev/null 2>&1
# Restart venv - ensure these deps are loaded
deactivate
source ${venv_path}/bin/activate > /dev/null
# Run tests for this service
test_result_filename="test_results_${service}.log"
touch $test_result_filename
nosetests -qxs --ignore-files="test_server\.py" --ignore-files="test_${service}_cloudformation\.py" --ignore-files="test_integration\.py" $path_to_test_file >$test_result_filename 2>&1
RESULT=$?
if [[ $RESULT != 0 ]]; then
echo -e "Tests for ${service} have failed!\n"
else
rm $test_result_filename
fi
deactivate
rm -rf ${venv_path}
}
echo "Running Dependency tests..."
ITER=0
for file in moto/*
do
if [[ -d $file ]]; then
service=${file:5}
path_to_test_file="tests/test_${service}"
if valid_service $service && [[ -d $path_to_test_file ]]; then
test_service $service $path_to_test_file &
elif valid_service $service; then
echo -e "No tests for ${service} can be found on ${path_to_test_file}!\n"
fi
if (( $ITER % 4 == 0 )); then
# Ensure we're only processing 4 services at the time
wait
fi
fi
ITER=$(expr $ITER + 1)
done
wait