diff --git a/tools/test/install_script.sh b/tools/test/install_script.sh deleted file mode 100755 index d9c4304050..0000000000 --- a/tools/test/install_script.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# Copyright European Organization for Nuclear Research (CERN) since 2012 -# -# Licensed 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. - -set -eo pipefail - -echo "* Using $(command -v python) $(python --version 2>&1) and $(command -v pip) $(pip --version 2>&1)" - -SOURCE_PATH=/usr/local/src/rucio -CFG_PATH=/usr/local/src/rucio/etc/docker/test/extra/ -RUCIO_HOME=/opt/rucio - -generate_rucio_cfg(){ - local override=$1 - local destination=$2 - - python3 $SOURCE_PATH/tools/merge_rucio_configs.py \ - -s $CFG_PATH/rucio_autotests_common.cfg "$override" \ - --use-env \ - -d "$destination" -} - -if [ "$SUITE" == "client" -o "$SUITE" == "client_syntax" ]; then - cd $SOURCE_PATH - cp etc/docker/test/extra/rucio_client.cfg etc/rucio.cfg - -elif [ "$SUITE" == "syntax" -o "$SUITE" == "docs" ]; then - generate_rucio_cfg "$CFG_PATH"/rucio_syntax.cfg "$SOURCE_PATH"/etc/rucio.cfg - -elif [ "$SUITE" == "votest" ]; then - VOTEST_HELPER=$RUCIO_HOME/tools/test/votest_helper.py - VOTEST_CONFIG_FILE=$RUCIO_HOME/etc/docker/test/matrix_policy_package_tests.yml - echo "VOTEST: Overriding policy section in rucio.cfg" - python $VOTEST_HELPER --vo $POLICY --vo-config --file $VOTEST_CONFIG_FILE - echo "VOTEST: Restarting httpd to load config" - httpd -k restart - -elif [ "$SUITE" == "remote_dbs" ] || [ "$SUITE" == "multi_vo" ]; then - - if [ "$RDBMS" == "oracle" ]; then - generate_rucio_cfg $CFG_PATH/rucio_oracle.cfg $RUCIO_HOME/etc/rucio.cfg - cp $CFG_PATH/alembic_oracle.ini $RUCIO_HOME/etc/alembic.ini - - elif [ "$RDBMS" == "mysql8" ]; then - generate_rucio_cfg $CFG_PATH/rucio_mysql8.cfg $RUCIO_HOME/etc/rucio.cfg - cp $CFG_PATH/alembic_mysql8.ini $RUCIO_HOME/etc/alembic.ini - - elif [ "$RDBMS" == "postgres14" ]; then - if [ "$SUITE" == "multi_vo" ]; then - mkdir -p $RUCIO_HOME/etc/multi_vo/tst/etc - mkdir -p $RUCIO_HOME/etc/multi_vo/ts2/etc - generate_rucio_cfg $CFG_PATH/rucio_multi_vo_tst_postgres14.cfg $RUCIO_HOME/etc/multi_vo/tst/etc/rucio.cfg - generate_rucio_cfg $CFG_PATH/rucio_multi_vo_ts2_postgres14.cfg $RUCIO_HOME/etc/multi_vo/ts2/etc/rucio.cfg - fi - generate_rucio_cfg $CFG_PATH/rucio_postgres14.cfg $RUCIO_HOME/etc/rucio.cfg - cp $CFG_PATH/alembic_postgres14.ini $RUCIO_HOME/etc/alembic.ini - fi - - echo 'Waiting for database to be ready' - if ! python3 -c "from rucio.db.sqla.session import wait_for_database; wait_for_database()" - then - echo 'Cannot access database' - exit 1 - fi - - httpd -k restart - -elif [ "$SUITE" == "sqlite" ]; then - generate_rucio_cfg $CFG_PATH/rucio_sqlite.cfg $RUCIO_HOME/etc/rucio.cfg - cp $CFG_PATH/alembic_sqlite.ini $RUCIO_HOME/etc/alembic.ini - - httpd -k restart -fi \ No newline at end of file diff --git a/tools/test/run_tests.py b/tools/test/run_tests.py index 65a1138b0e..d98317e59f 100755 --- a/tools/test/run_tests.py +++ b/tools/test/run_tests.py @@ -237,7 +237,6 @@ def run_test_directly( pod_net_arg = ['--pod', pod] if use_podman else [] scripts_to_run = ' && '.join( [ - './tools/test/install_script.sh', './tools/test/test.sh' + (' -p' if tests else ''), ] ) @@ -320,10 +319,6 @@ def run_with_httpd( json.loads(run('docker-compose', '-p', project, 'ps', '--format', 'json', return_stdout=True)) ), {}).get('Name', rucio_container) - # Running install_script.sh - run('docker', *namespace_args, 'exec', rucio_container, './tools/test/install_script.sh', - env={**os.environ, **caseenv, **namespace_env}) - # Running test.sh if tests: tests_env = ('--env', 'TESTS=' + ' '.join(tests)) @@ -332,7 +327,8 @@ def run_with_httpd( tests_env = () tests_arg = () - run('docker', *namespace_args, 'exec', *tests_env, rucio_container, './tools/test/test.sh', *tests_arg) + run('docker', *namespace_args, 'exec', *tests_env, rucio_container, './tools/test/test.sh', *tests_arg, + env={**caseenv, **namespace_env}) # if everything went through without an exception, mark this case as a success return True diff --git a/tools/test/test.sh b/tools/test/test.sh index 2212329405..60629f4042 100755 --- a/tools/test/test.sh +++ b/tools/test/test.sh @@ -16,9 +16,81 @@ set -eo pipefail +echo "* Using $(command -v python) $(python --version 2>&1) and $(command -v pip) $(pip --version 2>&1)" + +SOURCE_PATH=/usr/local/src/rucio +CFG_PATH=/usr/local/src/rucio/etc/docker/test/extra/ +RUCIO_HOME=/opt/rucio + +generate_rucio_cfg(){ + local override=$1 + local destination=$2 + + python3 $SOURCE_PATH/tools/merge_rucio_configs.py \ + -s $CFG_PATH/rucio_autotests_common.cfg "$override" \ + --use-env \ + -d "$destination" +} + +# Prepare the test configurations + +if [ "$SUITE" == "client" -o "$SUITE" == "client_syntax" ]; then + cd $SOURCE_PATH + cp etc/docker/test/extra/rucio_client.cfg etc/rucio.cfg + +elif [ "$SUITE" == "syntax" -o "$SUITE" == "docs" ]; then + generate_rucio_cfg "$CFG_PATH"/rucio_syntax.cfg "$SOURCE_PATH"/etc/rucio.cfg + +elif [ "$SUITE" == "votest" ]; then + VOTEST_HELPER=$RUCIO_HOME/tools/test/votest_helper.py + VOTEST_CONFIG_FILE=$RUCIO_HOME/etc/docker/test/matrix_policy_package_tests.yml + echo "VOTEST: Overriding policy section in rucio.cfg" + python $VOTEST_HELPER --vo $POLICY --vo-config --file $VOTEST_CONFIG_FILE + echo "VOTEST: Restarting httpd to load config" + httpd -k restart + +elif [ "$SUITE" == "remote_dbs" ] || [ "$SUITE" == "multi_vo" ]; then + + if [ "$RDBMS" == "oracle" ]; then + generate_rucio_cfg $CFG_PATH/rucio_oracle.cfg $RUCIO_HOME/etc/rucio.cfg + cp $CFG_PATH/alembic_oracle.ini $RUCIO_HOME/etc/alembic.ini + + elif [ "$RDBMS" == "mysql8" ]; then + generate_rucio_cfg $CFG_PATH/rucio_mysql8.cfg $RUCIO_HOME/etc/rucio.cfg + cp $CFG_PATH/alembic_mysql8.ini $RUCIO_HOME/etc/alembic.ini + + elif [ "$RDBMS" == "postgres14" ]; then + if [ "$SUITE" == "multi_vo" ]; then + mkdir -p $RUCIO_HOME/etc/multi_vo/tst/etc + mkdir -p $RUCIO_HOME/etc/multi_vo/ts2/etc + generate_rucio_cfg $CFG_PATH/rucio_multi_vo_tst_postgres14.cfg $RUCIO_HOME/etc/multi_vo/tst/etc/rucio.cfg + generate_rucio_cfg $CFG_PATH/rucio_multi_vo_ts2_postgres14.cfg $RUCIO_HOME/etc/multi_vo/ts2/etc/rucio.cfg + fi + generate_rucio_cfg $CFG_PATH/rucio_postgres14.cfg $RUCIO_HOME/etc/rucio.cfg + cp $CFG_PATH/alembic_postgres14.ini $RUCIO_HOME/etc/alembic.ini + fi + + echo 'Waiting for database to be ready' + if ! python3 -c "from rucio.db.sqla.session import wait_for_database; wait_for_database()" + then + echo 'Cannot access database' + exit 1 + fi + + httpd -k restart + +elif [ "$SUITE" == "sqlite" ]; then + generate_rucio_cfg $CFG_PATH/rucio_sqlite.cfg $RUCIO_HOME/etc/rucio.cfg + cp $CFG_PATH/alembic_sqlite.ini $RUCIO_HOME/etc/alembic.ini + + httpd -k restart +fi + +# Run tests + function srchome() { - export RUCIO_HOME=/usr/local/src/rucio - cd $RUCIO_HOME + export RUCIO_HOME=$SOURCE_PATH + cd $SOURCE_PATH } if [ "$SUITE" == "syntax" ]; then @@ -39,11 +111,11 @@ elif [ "$SUITE" == "docs" ]; then elif [[ "$SUITE" =~ ^client.* ]]; then + srchome if [ "$SUITE" == "client" ]; then tools/run_tests.sh -i fi - srchome if [ "$SUITE" == "client" ]; then tools/pytest.sh -v --tb=short tests/test_clients.py tests/test_bin_rucio.py tests/test_module_import.py elif [ "$SUITE" == "client_syntax" ]; then