Fix directory when dropping API server database connections.
authorBrett Smith <brett@curoverse.com>
Mon, 8 Jun 2015 17:38:06 +0000 (13:38 -0400)
committerBrett Smith <brett@curoverse.com>
Mon, 8 Jun 2015 17:38:06 +0000 (13:38 -0400)
The Python one-liner is written with the expectation that it's in this
directory, and usually fails to find <config/database.yml> otherwise.
No issue #.

jenkins/run-tests.sh

index 1a699a85512224cb971efe41deea4c4f6b01437a..cd6e1d0da99dbeba0067165b6f958a07bad9660a 100755 (executable)
@@ -609,8 +609,9 @@ install_apiserver() {
     # 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" \
+        && 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 \