Skip to content

Commit

Permalink
Tests: merge install_script.sh into test.sh
Browse files Browse the repository at this point in the history
These two scripts are always called one after the other. Make it
explicit. Especially considering that the second heavily depends
on the first.

Mostly just code movement, no refactoring (which would be very welcomed
in a later commit).
  • Loading branch information
Radu Carpa committed Oct 11, 2023
1 parent b4c5471 commit c298919
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 94 deletions.
85 changes: 0 additions & 85 deletions tools/test/install_script.sh

This file was deleted.

8 changes: 2 additions & 6 deletions tools/test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''),
]
)
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down
78 changes: 75 additions & 3 deletions tools/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c298919

Please sign in to comment.