mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Lighter weight Selenium test setup for PRs.
The Dockerfile and image update in #4900 baked chrome, chrome-wrapper, xvfb, and a Selenium server into the default Galaxy testing image. This means we should no longer need to run three docker containers in a compose setup to run Selenium tests. This swaps the script target used by Jenkins to use this newer variant of the tests. In addition to simply consuming less CPU and booting up much faster thanks to pre-installed dependencies and pre-migrated database, this setup is much easier to cleanup and so we don't need to restrict it to one test per host - these tests I think should run just like API and framework tests. This should also be easier for people running tests locally. I've kept the old compose setup around and I'll setup a Jenkins job against dev that continues to run it periodically (just not on PRs). It does testing of proxy prefix things this variant doesn't and serves as a good reference implementation for multi-container Galaxy testing - which we may wish to do for various categories of tests in the future. The multi-container variant makes it much easier to bring in various services - lots of which one can imagine writing useful Galaxy tests for - AMQP, statistics collection, Docker itself, etc....
This commit is contained in:
Executable
+124
@@ -0,0 +1,124 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST_DIRECTORY=`dirname $0`
|
||||
|
||||
DEFAULT_COMPOSE_PROJECT_NAME=`basename $TEST_DIRECTORY`
|
||||
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-$DEFAULT_COMPOSE_PROJECT_NAME}
|
||||
# If in Jenkins environment, append ${BUILD_NUMBER} to project so builds don't interfer.
|
||||
if [ ! -z "$BUILD_NUMBER" ];
|
||||
then
|
||||
COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME}${BUILD_NUMBER}"
|
||||
fi
|
||||
export COMPOSE_PROJECT_NAME
|
||||
|
||||
echo "Running Jenkins test from $TEST_DIRECTORY with compose project name $COMPOSE_PROJECT_NAME"
|
||||
|
||||
find lib -iname '*pyc' -exec rm -rf {} \;
|
||||
find test -iname '*pyc' -exec rm -rf {} \;
|
||||
|
||||
./scripts/common_startup.sh --dev-wheels
|
||||
|
||||
. .venv/bin/activate
|
||||
|
||||
pip install docker-compose
|
||||
|
||||
# TODO: Let docker-compose pick these at random.
|
||||
export GALAXY_PORT=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
|
||||
export SELENIUM_PORT=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
|
||||
|
||||
export TARGET_ROOT=`pwd`
|
||||
export TARGET_PATH=/galaxy
|
||||
export MY_UID=$(id -u)
|
||||
|
||||
cd $TEST_DIRECTORY
|
||||
|
||||
echo "Cleaning up previous executions if needed."
|
||||
docker-compose down | true
|
||||
docker-compose build galaxy
|
||||
docker-compose up -d
|
||||
|
||||
function tear_down {
|
||||
docker-compose down
|
||||
}
|
||||
|
||||
trap tear_down EXIT
|
||||
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
echo "Waiting on service ${service_name}"
|
||||
while true
|
||||
do
|
||||
if docker ps | grep -q "${COMPOSE_PROJECT_NAME}_${service_name}"
|
||||
then
|
||||
container_id=`docker ps | grep "${COMPOSE_PROJECT_NAME}_${service_name}" | cut -d " " -f 1`
|
||||
eval "${service_name}_container_id=${container_id}"
|
||||
echo "Service ${service_name} ready - with container ID ${container_id}"
|
||||
break
|
||||
fi
|
||||
printf "."
|
||||
sleep 1;
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
if [ "$1" = "--debug-running-containers" ];
|
||||
then
|
||||
env
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export GALAXY_TEST_EXTERNAL="http://localhost:$GALAXY_PORT/"
|
||||
|
||||
echo "Waiting on docker-compose managed Galaxy server - $GALAXY_TEST_EXTERNAL."
|
||||
while ! curl -s "$GALAXY_TEST_EXTERNAL";
|
||||
do
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
if ! docker ps | grep -q "${COMPOSE_PROJECT_NAME}_${service_name}"
|
||||
then
|
||||
echo "Service ${service_name} stopped before Galaxy came up, exiting and halting containers."
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
container_id_var="${service_name}_container_id"
|
||||
container_id="${!container_id_var}"
|
||||
echo "Dumping logs for $service_name container (${container_id})..."
|
||||
echo "---"
|
||||
docker logs "${container_id}"
|
||||
echo "---"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf "."
|
||||
sleep 4;
|
||||
done;
|
||||
|
||||
# Access Selenium on localhost via port $SELENIUM_PORT
|
||||
export GALAXY_TEST_SELENIUM_REMOTE=1
|
||||
export GALAXY_TEST_SELENIUM_REMOTE_PORT="${SELENIUM_PORT}"
|
||||
|
||||
# Retry all failed Selenium tests a second time to deal
|
||||
# with transiently failing tests. Failure information for
|
||||
# first tests is still populated in database/test_errors
|
||||
# and available at the top of the Jenkins test report.
|
||||
export GALAXY_TEST_SELENIUM_RETRIES=1
|
||||
|
||||
# Access Galaxy on localhost via port $GALAXY_PORT
|
||||
export GALAXY_TEST_PORT="${GALAXY_PORT}"
|
||||
|
||||
# Have Selenium access Galaxy at this URL
|
||||
export GALAXY_TEST_EXTERNAL_FROM_SELENIUM="http://galaxy:8080/galaxypf"
|
||||
export GALAXY_TEST_EXTERNAL="http://localhost:${GALAXY_TEST_PORT}/galaxypf"
|
||||
|
||||
# Point tests at the Master API Key configured in the Dockerfile.
|
||||
export GALAXY_CONFIG_MASTER_API_KEY=94a548bea347a35e457a804bf75bec53
|
||||
|
||||
cd ../../..
|
||||
|
||||
./run_tests.sh --selenium "$@"
|
||||
exit_code=$?
|
||||
|
||||
cd $TEST_DIRECTORY
|
||||
|
||||
exit $exit_code
|
||||
Executable → Regular
+7
-120
@@ -1,124 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST_DIRECTORY=`dirname $0`
|
||||
# Enable retries on tests to reduce chances of transient failures.
|
||||
: ${GALAXY_TEST_SELENIUM_RETRIES:=1}
|
||||
: ${GALAXY_TEST_ERRORS_DIRECTORY:=database/test-errors}
|
||||
|
||||
DEFAULT_COMPOSE_PROJECT_NAME=`basename $TEST_DIRECTORY`
|
||||
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-$DEFAULT_COMPOSE_PROJECT_NAME}
|
||||
# If in Jenkins environment, append ${BUILD_NUMBER} to project so builds don't interfer.
|
||||
if [ ! -z "$BUILD_NUMBER" ];
|
||||
then
|
||||
COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME}${BUILD_NUMBER}"
|
||||
fi
|
||||
export COMPOSE_PROJECT_NAME
|
||||
# Start Selenium server in the test Docker container.
|
||||
DOCKER_RUN_EXTRA_ARGS="-e USE_SELENIUM=1 -e GALAXY_TEST_SELENIUM_RETRIES=${GALAXY_TEST_SELENIUM_RETRIES} -e GALAXY_TEST_ERRORS_DIRECTORY=${GALAXY_TEST_ERRORS_DIRECTORY} ${DOCKER_RUN_EXTRA_ARGS}"
|
||||
export DOCKER_RUN_EXTRA_ARGS
|
||||
|
||||
echo "Running Jenkins test from $TEST_DIRECTORY with compose project name $COMPOSE_PROJECT_NAME"
|
||||
|
||||
find lib -iname '*pyc' -exec rm -rf {} \;
|
||||
find test -iname '*pyc' -exec rm -rf {} \;
|
||||
|
||||
./scripts/common_startup.sh --dev-wheels
|
||||
|
||||
. .venv/bin/activate
|
||||
|
||||
pip install docker-compose
|
||||
|
||||
# TODO: Let docker-compose pick these at random.
|
||||
export GALAXY_PORT=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
|
||||
export SELENIUM_PORT=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
|
||||
|
||||
export TARGET_ROOT=`pwd`
|
||||
export TARGET_PATH=/galaxy
|
||||
export MY_UID=$(id -u)
|
||||
|
||||
cd $TEST_DIRECTORY
|
||||
|
||||
echo "Cleaning up previous executions if needed."
|
||||
docker-compose down | true
|
||||
docker-compose build galaxy
|
||||
docker-compose up -d
|
||||
|
||||
function tear_down {
|
||||
docker-compose down
|
||||
}
|
||||
|
||||
trap tear_down EXIT
|
||||
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
echo "Waiting on service ${service_name}"
|
||||
while true
|
||||
do
|
||||
if docker ps | grep -q "${COMPOSE_PROJECT_NAME}_${service_name}"
|
||||
then
|
||||
container_id=`docker ps | grep "${COMPOSE_PROJECT_NAME}_${service_name}" | cut -d " " -f 1`
|
||||
eval "${service_name}_container_id=${container_id}"
|
||||
echo "Service ${service_name} ready - with container ID ${container_id}"
|
||||
break
|
||||
fi
|
||||
printf "."
|
||||
sleep 1;
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
if [ "$1" = "--debug-running-containers" ];
|
||||
then
|
||||
env
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export GALAXY_TEST_EXTERNAL="http://localhost:$GALAXY_PORT/"
|
||||
|
||||
echo "Waiting on docker-compose managed Galaxy server - $GALAXY_TEST_EXTERNAL."
|
||||
while ! curl -s "$GALAXY_TEST_EXTERNAL";
|
||||
do
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
if ! docker ps | grep -q "${COMPOSE_PROJECT_NAME}_${service_name}"
|
||||
then
|
||||
echo "Service ${service_name} stopped before Galaxy came up, exiting and halting containers."
|
||||
for service_name in postgres galaxy selenium
|
||||
do
|
||||
container_id_var="${service_name}_container_id"
|
||||
container_id="${!container_id_var}"
|
||||
echo "Dumping logs for $service_name container (${container_id})..."
|
||||
echo "---"
|
||||
docker logs "${container_id}"
|
||||
echo "---"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf "."
|
||||
sleep 4;
|
||||
done;
|
||||
|
||||
# Access Selenium on localhost via port $SELENIUM_PORT
|
||||
export GALAXY_TEST_SELENIUM_REMOTE=1
|
||||
export GALAXY_TEST_SELENIUM_REMOTE_PORT="${SELENIUM_PORT}"
|
||||
|
||||
# Retry all failed Selenium tests a second time to deal
|
||||
# with transiently failing tests. Failure information for
|
||||
# first tests is still populated in database/test_errors
|
||||
# and available at the top of the Jenkins test report.
|
||||
export GALAXY_TEST_SELENIUM_RETRIES=1
|
||||
|
||||
# Access Galaxy on localhost via port $GALAXY_PORT
|
||||
export GALAXY_TEST_PORT="${GALAXY_PORT}"
|
||||
|
||||
# Have Selenium access Galaxy at this URL
|
||||
export GALAXY_TEST_EXTERNAL_FROM_SELENIUM="http://galaxy:8080/galaxypf"
|
||||
export GALAXY_TEST_EXTERNAL="http://localhost:${GALAXY_TEST_PORT}/galaxypf"
|
||||
|
||||
# Point tests at the Master API Key configured in the Dockerfile.
|
||||
export GALAXY_CONFIG_MASTER_API_KEY=94a548bea347a35e457a804bf75bec53
|
||||
|
||||
cd ../../..
|
||||
|
||||
./run_tests.sh --selenium "$@"
|
||||
exit_code=$?
|
||||
|
||||
cd $TEST_DIRECTORY
|
||||
|
||||
exit $exit_code
|
||||
./run_tests.sh --dockerize --db postgres --external_tmp --clean_pyc --selenium "$@"
|
||||
|
||||
+1
-5
@@ -285,10 +285,6 @@ then
|
||||
else
|
||||
db_type="sqlite"
|
||||
fi
|
||||
if [ "$1" = "--selenium" ]; then
|
||||
DOCKER_RUN_EXTRA_ARGS="-e USE_SELENIUM=1 ${DOCKER_RUN_EXTRA_ARGS}"
|
||||
shift
|
||||
fi
|
||||
if [ "$1" = "--external_tmp" ]; then
|
||||
# If /tmp is a tmpfs there may be better performance by reusing
|
||||
# the parent's temp file system. Also, it seems to decrease the
|
||||
@@ -301,7 +297,7 @@ then
|
||||
fi
|
||||
MY_UID=$(id -u)
|
||||
DOCKER_RUN_EXTRA_ARGS="-e GALAXY_TEST_UID=${MY_UID} ${DOCKER_RUN_EXTRA_ARGS}"
|
||||
echo "Launching docker container for testing..."
|
||||
echo "Launching docker container for testing with extra args ${DOCKER_RUN_EXTRA_ARGS}..."
|
||||
docker $DOCKER_EXTRA_ARGS run $DOCKER_RUN_EXTRA_ARGS -e "BUILD_NUMBER=$BUILD_NUMBER" -e "GALAXY_TEST_DATABASE_TYPE=$db_type" --rm -v `pwd`:/galaxy $DOCKER_IMAGE "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user