From e890655c54aa1c5377d8a33e5a03383cdedf141c Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Tue, 2 Oct 2018 12:13:32 +0000 Subject: [PATCH] SW-415: use same setup and teardown as in t_lsmrapp_scheduling_functional. TODO: create common bash file with setup/teardown routines. --- SAS/LSMR/test/t_lsmrapp_scheduling_django.run | 13 ----- .../test/t_lsmrapp_scheduling_functional.run | 1 - .../test/t_lsmrapp_specification_django.run | 55 ++++++++++++++++++- .../t_lsmrapp_specification_functional.run | 1 - 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/SAS/LSMR/test/t_lsmrapp_scheduling_django.run b/SAS/LSMR/test/t_lsmrapp_scheduling_django.run index dfbd19a1da4..c59a50753c3 100755 --- a/SAS/LSMR/test/t_lsmrapp_scheduling_django.run +++ b/SAS/LSMR/test/t_lsmrapp_scheduling_django.run @@ -18,21 +18,9 @@ password=lsrm -#keep track of helper application pids to kill in teardown -PIDS= - # setup propagation of signals to child processes teardown() { echo "tearing down test environment" - for PID in $PIDS - do - # get the full command - CMD="`ps --pid $PID h -o command`" - echo "killing helper application: $CMD" - - # and kill it - kill -TERM $PID - done echo "removing test credentials file: $CREDENTIALS_PATH" rm $CREDENTIALS_PATH @@ -48,7 +36,6 @@ export LSMR_DBCREDENTIALS=$DJANGO_TEST_DATABASE_NAME # Run test $LOFARROOT/lib*/python*/site-packages/lofar/sas/lsmr/manage.py test --pattern="t_lsmrapp_scheduling_django.py" --testrunner=postgres_testrunner.PostgresqlTestRunner & TEST_PID=$! -PIDS="$TEST_PID $PIDS" wait "$TEST_PID" # wait again (to get the status code of the test) diff --git a/SAS/LSMR/test/t_lsmrapp_scheduling_functional.run b/SAS/LSMR/test/t_lsmrapp_scheduling_functional.run index 0c637fa29ea..50eb24e21fa 100755 --- a/SAS/LSMR/test/t_lsmrapp_scheduling_functional.run +++ b/SAS/LSMR/test/t_lsmrapp_scheduling_functional.run @@ -63,7 +63,6 @@ export LSMR_DBCREDENTIALS=$DJANGO_TEST_DATABASE_NAME # Run test ./t_lsmrapp_scheduling_functional.py & TEST_PID=$! -PIDS="$TEST_PID $PIDS" wait "$TEST_PID" # wait again (to get the status code of the test) diff --git a/SAS/LSMR/test/t_lsmrapp_specification_django.run b/SAS/LSMR/test/t_lsmrapp_specification_django.run index d3c9ef68b10..e43bfde2f14 100755 --- a/SAS/LSMR/test/t_lsmrapp_specification_django.run +++ b/SAS/LSMR/test/t_lsmrapp_specification_django.run @@ -1,3 +1,54 @@ -#!/bin/sh +#!/bin/bash +set +x + +mkdir -p ~/.lofar/dbcredentials + +DJANGO_TEST_DATABASE_NAME="lsmr_test_`uuidgen | sed 's/-/_/g'`" +CREDENTIALS_PATH="$HOME/.lofar/dbcredentials/$DJANGO_TEST_DATABASE_NAME.ini" + +echo "creating test credentials file: $CREDENTIALS_PATH" +echo "[database:$DJANGO_TEST_DATABASE_NAME] +host=localhost +type=postgres +database=$DJANGO_TEST_DATABASE_NAME +port=7654 +user=lsrm +password=lsrm +" > "$CREDENTIALS_PATH" + + +# setup propagation of signals to child processes +teardown() { + echo "tearing down test environment" + + echo "removing test credentials file: $CREDENTIALS_PATH" + rm $CREDENTIALS_PATH +} + +## Trap upon signals and upon normal exit. +trap 'STATUS=$?; teardown; exit $STATUS' SIGHUP SIGINT SIGQUIT SIGKILL SIGTERM + + +export DJANGO_TEST_PORT=$DJANGO_TEST_PORT +export LSMR_DBCREDENTIALS=$DJANGO_TEST_DATABASE_NAME + +# Run test +$LOFARROOT/lib*/python*/site-packages/lofar/sas/lsmr/manage.py test --pattern="t_lsmrapp_specification_django.py" --testrunner=postgres_testrunner.PostgresqlTestRunner & +TEST_PID=$! + +wait "$TEST_PID" +# wait again (to get the status code of the test) +wait "$TEST_PID" +TEST_EXIT_CODE=$? + +teardown + +exit $TEST_EXIT_CODE + + + + + + + -$LOFARROOT/lib*/python*/site-packages/lofar/sas/lsmr/manage.py test --pattern="t_lsmrapp_specification_django.py" --testrunner=postgres_testrunner.PostgresqlTestRunner diff --git a/SAS/LSMR/test/t_lsmrapp_specification_functional.run b/SAS/LSMR/test/t_lsmrapp_specification_functional.run index 6722f7a83b8..f552f5b0f01 100755 --- a/SAS/LSMR/test/t_lsmrapp_specification_functional.run +++ b/SAS/LSMR/test/t_lsmrapp_specification_functional.run @@ -63,7 +63,6 @@ export LSMR_DBCREDENTIALS=$DJANGO_TEST_DATABASE_NAME # Run test ./t_lsmrapp_specification_functional.py & TEST_PID=$! -PIDS="$TEST_PID $PIDS" wait "$TEST_PID" # wait again (to get the status code of the test) -- GitLab