[ARVADOS] updated: 4470ba26b332cb92d347af00cdb26c716b1a6953

git at public.curoverse.com git at public.curoverse.com
Mon Feb 2 15:38:52 EST 2015


Summary of changes:
 .gitignore                            |  6 ++----
 sdk/python/tests/run_test_server.py   | 21 ++++++++++++++++-----
 services/api/test/websocket_runner.rb | 10 ++++++++--
 3 files changed, 26 insertions(+), 11 deletions(-)

       via  4470ba26b332cb92d347af00cdb26c716b1a6953 (commit)
       via  d01477c59395e6d0895fffe0f60cce6bda9bb083 (commit)
      from  5c1cee516b4d41a355fd40a538cf695325e0b712 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 4470ba26b332cb92d347af00cdb26c716b1a6953
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 2 14:36:46 2015 -0500

    3021: Use `passenger stop` to shut down passenger. Restore database fixtures after running DatabaseCleaner-powered tests.

diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py
index 534c767..ddc2799 100644
--- a/sdk/python/tests/run_test_server.py
+++ b/sdk/python/tests/run_test_server.py
@@ -61,21 +61,32 @@ def find_server_pid(PID_PATH, wait=10):
 
     return server_pid
 
-def kill_server_pid(pidfile, wait=10):
+def kill_server_pid(pidfile, wait=10, passenger=False):
     # Must re-import modules in order to work during atexit
     import os
     import signal
+    import subprocess
     import time
     try:
+        if passenger:
+            # First try to shut down nicely
+            restore_cwd = os.getcwd()
+            os.chdir(os.path.join(SERVICES_SRC_DIR, 'api'))
+            subprocess.call([
+                'bundle', 'exec', 'passenger', 'stop', '--pid-file', pidfile])
+            os.chdir(restore_cwd)
         now = time.time()
         timeout = now + wait
         with open(pidfile, 'r') as f:
             server_pid = int(f.read())
         while now <= timeout:
-            os.kill(server_pid, signal.SIGTERM)
-            os.getpgid(server_pid) # throw OSError if no such pid
-            now = time.time()
+            if not passenger or timeout - now < wait / 2:
+                # Half timeout has elapsed. Start sending SIGTERM
+                os.kill(server_pid, signal.SIGTERM)
+            # Raise OSError if process has disappeared
+            os.getpgid(server_pid)
             time.sleep(0.1)
+            now = time.time()
     except IOError:
         pass
     except OSError:
@@ -143,7 +154,7 @@ def run(leave_running_atexit=False):
         env=env)
 
     if not leave_running_atexit:
-        atexit.register(kill_server_pid, pid_file)
+        atexit.register(kill_server_pid, pidfile, passenger=True)
 
     match = re.search(r'Accessible via: https://(.*?)/', start_msg)
     if not match:
diff --git a/services/api/test/websocket_runner.rb b/services/api/test/websocket_runner.rb
index df72e24..65af8ce 100644
--- a/services/api/test/websocket_runner.rb
+++ b/services/api/test/websocket_runner.rb
@@ -7,7 +7,7 @@ class WebsocketTestRunner < MiniTest::Unit
   def _system(*cmd)
     Bundler.with_clean_env do
       if not system({'ARVADOS_WEBSOCKETS' => 'ws-only', 'RAILS_ENV' => 'test'}, *cmd)
-        raise RuntimeError, "#{cmd[0]} returned exit code #{$?.exitstatus}"
+        raise RuntimeError, "Command failed with exit status #{$?}: #{cmd.inspect}"
       end
     end
   end
@@ -34,7 +34,13 @@ class WebsocketTestRunner < MiniTest::Unit
     begin
       super(args)
     ensure
-      Process.kill('TERM', server_pid)
+      Dir.chdir($ARV_API_SERVER_DIR) do
+        _system('passenger', 'stop', '-p3002')
+      end
+      # DatabaseCleaner leaves the database empty. Prefer to leave it full.
+      dc = DatabaseController.new
+      dc.define_singleton_method :render do |*args| end
+      dc.reset
     end
   end
 end

commit d01477c59395e6d0895fffe0f60cce6bda9bb083
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 2 03:41:27 2015 -0500

    3021: gitignore **/vendor

diff --git a/.gitignore b/.gitignore
index ae824a2..eec4758 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,11 +10,9 @@ sdk/perl/MYMETA.*
 sdk/perl/Makefile
 sdk/perl/blib
 sdk/perl/pm_to_blib
-*/vendor/bundle
+*/vendor
+*/*/vendor
 sdk/java/target
 *.class
-apps/workbench/vendor/bundle
-services/api/vendor/bundle
 sdk/java/log
-sdk/cli/vendor
 /tmp

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list