Skip to content

Commit

Permalink
Tests: merge run_tests.sh and run_tests_docker.sh
Browse files Browse the repository at this point in the history
Why do we even have two of them ?
  • Loading branch information
Radu Carpa committed Oct 11, 2023
1 parent 1b8f89c commit 752d68e
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
shell: bash
run: |
docker exec -t dev_rucio_1 cp etc/rse-accounts.cfg.template etc/rse-accounts.cfg
docker exec -t dev_rucio_1 tools/run_tests_docker.sh -ir
docker exec -t dev_rucio_1 tools/run_tests.sh -ir
- name: File Upload/Download Test
run: docker exec -t dev_rucio_1 tools/pytest.sh -v --tb=short tests/test_rucio_server.py
- name: UploadClient Test
Expand Down
10 changes: 5 additions & 5 deletions etc/docker/dev/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Finally, you can jump into the container with::

To verify that everything is in order, you can now either run the full unit tests or only set up the database. Running the full testing suite takes ~10 minutes::

tools/run_tests_docker.sh
tools/run_tests.sh

Alternatively, you can bootstrap the test environment once with the `-i` option and then selectively or repeatedly run test case modules, test case groups, or even single test cases, for example::

tools/run_tests_docker.sh -i
tools/run_tests.sh -i
tools/pytest.sh tests/test_replica.py
tools/pytest.sh -vvv tests/test_replica.py::TestReplicaCore
tools/pytest.sh -vvv --full-trace tests/test_replica.py::TestReplicaCore::test_delete_replicas
Expand All @@ -69,7 +69,7 @@ This should show you a few more running containers: the Rucio server, the Postgr

With this container you can upload and download data to/from the storage and submit data transfers. To set this up, add the `-r` option to the setup.::

tools/run_tests_docker.sh -ir
tools/run_tests.sh -ir

This creates a few random files and uploads them, creates a few datasets and containers, and requests a replication rule for the container, which starts in state REPLICATING. To demonstrate the transfer capability, the daemons can be run in single-execution mode in order:::

Expand All @@ -96,7 +96,7 @@ Now you will have the same containers as before plus a full monitoring stack wit

To create some events and write them to Elasticsearch first run again the tests as before::

tools/run_tests_docker.sh -ir
tools/run_tests.sh -ir


Then you will have to run the transfer daemons (conveyor-\*) and messaging daemon (hermes) to send the events to ActiveMQ. There a script for that which repeats these daemons in single execution mode from the section in a loop::
Expand Down Expand Up @@ -210,7 +210,7 @@ Start the daemons

Daemons are not running in the docker environment, but all daemons support single-execution mode with the --run-once argument. Reset the system first with::

tools/run_tests_docker.sh -ir
tools/run_tests.sh -ir


Some files are created. Let's add them to a new dataset::
Expand Down
133 changes: 104 additions & 29 deletions tools/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,55 @@
# See the License for the specific language governing permissions and
# limitations under the License.

memcached -u root -d

function usage {
echo "Usage: $0 [OPTION]..."
echo 'Run Rucio test suite'
echo ''
echo ''
echo ' -h Show usage'
echo ' -2 Run tests twice'
echo ' -c Add pytest options'
echo ' -i Do only the initialization'
echo ' -p Also run pylint tests'
echo ' -p Indicate test selection by TESTS environment variable'
echo ' -k Keep database from previous test'
echo ' -a Disable alembic tests'
echo ' -i Do only the initialization'
echo ' -l Also run lint tests'
echo ' -r Activate default RSEs (XRD1, XRD2, XRD3, SSH1)'
echo ' -s Run special tests for Dirac. Includes using BelleII schema'
echo ' -t Verbose output from pytest'
echo ' -a Skip alembic downgrade/upgrade test'
echo ' -u Update pip dependencies only'
echo ' -x Stop running tests after the first problem'
echo ' -x exit instantly on first error or failed test'
exit
}

alembic="true"
iterations=1

while getopts h2rcipkaux opt
while getopts h2cpkilrstaux opt
do
case "$opt" in
h) usage;;
2) iterations=2;;
c) pytestextra="$OPTARG";;
i) init_only="true";;
p) pylint="true";;
k) keep_db="true";;
a) alembic="";;
u) pip_only="true";;
x) stop_on_failure="--exitfirst";;
esac
case "$opt" in
h) usage;;
2) iterations=2;;
p) selection="true";;
k) keep_db="true";;
i) init_only="true";;
l) pylint="true";;
r) activate_rse="true";;
s) special="true";selection="true";TESTS="test_dirac.py";;
t) trace="true";;
a) alembic="";;
u) pip_only="true";;
x) stop_on_failure="--exitfirst";;
*) usae; exit 1;
esac
done

echo 'Clearing memcache'
echo flush_all > /dev/tcp/127.0.0.1/11211

echo 'Graceful restart of Apache'
httpd -k graceful

echo 'Update dependencies with pip'
pip install --upgrade -r requirements.txt

Expand All @@ -62,9 +76,28 @@ find lib -iname "*.pyc" | xargs rm
echo 'Cleaning old authentication tokens'
rm -rf /tmp/.rucio_*/

echo 'Cleaning storage for local test RSEs'
echo 'Cleaning local RSE directories'
rm -rf /tmp/rucio_rse/*

echo 'Removing old SQLite databases'
rm -f /tmp/rucio.db

if test ${special}; then
if [ -f /opt/rucio/etc/rucio.cfg ]; then
echo 'Remove rucio.cfg'
rm /opt/rucio/etc/rucio.cfg
fi
echo 'Using the special config'
ln -s /opt/rucio/etc/rucio.cfg.special /opt/rucio/etc/rucio.cfg
else
if [ -f /opt/rucio/etc/rucio.cfg ]; then
echo 'Using the standard config'
else
echo 'rucio.cfg not found. Will try to do a symlink'
ln -s /opt/rucio/etc/rucio.cfg.default /opt/rucio/etc/rucio.cfg
fi
fi

echo 'Running flake8 code style checker'
flake8 --exclude=*.cfg bin/* lib/ tools/*.py
if [ $? != 0 ]; then
Expand Down Expand Up @@ -92,41 +125,83 @@ else

if [ $? != 0 ]; then
echo 'Failed to reset the database!'
exit
exit 1
fi

if [ -f /tmp/rucio.db ]; then
echo 'Disable SQLite database access restriction'
chmod 777 /tmp/rucio.db
echo 'Disable SQLite database access restriction'
chmod 777 /tmp/rucio.db
fi
fi

if test ${alembic}; then
echo 'Running full alembic migration'
tools/alembic_migration.sh
ALEMBIC_CONFIG="/opt/rucio/etc/alembic.ini" tools/alembic_migration.sh
if [ $? != 0 ]; then
echo 'Failed to run alembic migration!'
exit 1
fi
fi

echo 'Bootstrapping tests'
tools/bootstrap_tests.py
if [ $? != 0 ]; then
echo 'Failed to bootstrap!'
exit 1
fi

echo 'Sync rse_repository'
tools/sync_rses.py
if test ${special}; then
tools/sync_rses.py etc/rse_repository.json.special
if [ $? != 0 ]; then
echo 'Failed to sync!'
exit 1
fi
else
tools/sync_rses.py
if [ $? != 0 ]; then
echo 'Failed to sync!'
exit 1
fi
fi

echo 'Sync metadata keys'
tools/sync_meta.py
if [ $? != 0 ]; then
echo 'Failed to sync!'
exit 1
fi

echo 'Bootstrap tests: Create jdoe account/mock scope'
tools/bootstrap_tests.py
if test ${activate_rse}; then
echo 'Activating default RSEs (XRD1, XRD2, XRD3, SSH1)'
tools/docker_activate_rses.sh
fi

if test ${init_only}; then
exit
fi

PYTEST_SH_ARGS="$stop_on_failure"

if test ${trace}; then
echo 'Running tests in verbose mode'
PYTEST_SH_ARGS="-vvv $PYTEST_SH_ARGS"
else
echo 'Running tests'
PYTEST_SH_ARGS="-v --tb=short $PYTEST_SH_ARGS"
fi

for i in $iterations
do
echo 'Running test iteration' $i
echo tools/pytest.sh -v --tb=short $stop_on_failure $pytestextra
tools/pytest.sh -v --tb=short $stop_on_failure $pytestextra

if test ${selection}; then
echo "Running the following tests:"
echo $TESTS | tr " " "\n"
tools/pytest.sh $PYTEST_SH_ARGS $TESTS
else
TESTS=''
fi
echo 'Running test iteration' $i
echo tools/pytest.sh $PYTEST_SH_ARGS $TESTS
tools/pytest.sh $PYTEST_SH_ARGS $TESTS
done
Loading

0 comments on commit 752d68e

Please sign in to comment.