5416: Terminate connections on the configured test database (not necessarily arvados_...
authorTom Clegg <tom@curoverse.com>
Fri, 3 Apr 2015 00:15:58 +0000 (20:15 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 10 Apr 2015 01:18:09 +0000 (21:18 -0400)
jenkins/run-tests.sh

index f835f95291cb02250964b06f556739a05a6736ad..6700712cce0b37e6c3e009a2084c5ab3f27c884e 100755 (executable)
@@ -548,9 +548,11 @@ install_apiserver() {
         && git add tmp \
         && git commit -m 'initial commit'
 
-    # Clear out any lingering postgresql connections to arvados_test, so that we can drop it
-    # This assumes the current user is a postgresql superuser
-    psql arvados_test -c "SELECT pg_terminate_backend (pg_stat_activity.procpid::int) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'arvados_test';" 2>/dev/null
+    # Clear out any lingering postgresql connections to the test
+    # database, so that we can drop it. This assumes the current user
+    # is a postgresql superuser.
+    test_database=$(python -c "import yaml; print yaml.load(file('config/database.yml'))['test']['database']")
+    psql "$test_database" -c "SELECT pg_terminate_backend (pg_stat_activity.procpid::int) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$test_database';" 2>/dev/null
 
     cd "$WORKSPACE/services/api" \
         && RAILS_ENV=test bundle exec rake db:drop \