2752: Adapt Go tests to the new Python test infrastructure.
authorBrett Smith <brett@curoverse.com>
Thu, 29 May 2014 13:28:30 +0000 (09:28 -0400)
committerBrett Smith <brett@curoverse.com>
Thu, 29 May 2014 13:28:30 +0000 (09:28 -0400)
Refs #2752.  There's two pieces to this: pointing the Go tests at the
new home of run_test_server.py, and having run_test_server.py add the
arvados module source to sys.path as needed.

sdk/go/src/arvados.org/keepclient/keepclient_test.go
sdk/python/tests/run_test_server.py
services/keep/src/arvados.org/keepproxy/keepproxy_test.go

index 8eedadd64b8a87d79a1a7f9dfe0fc9eb478138e1..753a0ace28e559dbbf6add635206ad6ca84ba64b 100644 (file)
@@ -36,7 +36,7 @@ type StandaloneSuite struct{}
 
 func pythonDir() string {
        gopath := os.Getenv("GOPATH")
-       return fmt.Sprintf("%s/../python", strings.Split(gopath, ":")[0])
+       return fmt.Sprintf("%s/../python/tests", strings.Split(gopath, ":")[0])
 }
 
 func (s *ServerRequiredSuite) SetUpSuite(c *C) {
index 5b4097d3501cacd5b35d0895947b092972942382..dc95d8a9a5ac3f0781ed4aec9fa10d713f66479b 100644 (file)
@@ -1,14 +1,24 @@
-import subprocess
-import time
+#!/usr/bin/env python
+
+import argparse
 import os
+import shutil
 import signal
-import yaml
+import subprocess
 import sys
-import argparse
-import arvados.config
-import arvados.api
-import shutil
 import tempfile
+import time
+import yaml
+
+MY_DIRNAME = os.path.dirname(os.path.realpath(__file__))
+if __name__ == '__main__' and os.path.exists(
+      os.path.join(MY_DIRNAME, '..', 'arvados', '__init__.py')):
+    # We're being launched to support another test suite.
+    # Add the Python SDK source to the library path.
+    sys.path.insert(1, os.path.dirname(MY_DIRNAME))
+
+import arvados.api
+import arvados.config
 
 ARV_API_SERVER_DIR = '../../../services/api'
 KEEP_SERVER_DIR = '../../../services/keep'
@@ -54,7 +64,7 @@ def kill_server_pid(PID_PATH, wait=10):
 
 def run(websockets=False, reuse_server=False):
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), ARV_API_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, ARV_API_SERVER_DIR))
 
     if websockets:
         pid_file = WEBSOCKETS_SERVER_PID_PATH
@@ -106,7 +116,7 @@ def run(websockets=False, reuse_server=False):
 
 def stop():
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), ARV_API_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, ARV_API_SERVER_DIR))
 
     kill_server_pid(WEBSOCKETS_SERVER_PID_PATH, 0)
     kill_server_pid(SERVER_PID_PATH, 0)
@@ -144,7 +154,7 @@ def run_keep(blob_signing_key=None, enforce_permissions=False):
     stop_keep()
 
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), KEEP_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR))
     if os.environ.get('GOPATH') == None:
         os.environ["GOPATH"] = os.getcwd()
     else:
@@ -194,7 +204,7 @@ def _stop_keep(n):
 
 def stop_keep():
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), KEEP_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR))
 
     _stop_keep(0)
     _stop_keep(1)
@@ -205,7 +215,7 @@ def run_keep_proxy(auth):
     stop_keep_proxy()
 
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), KEEP_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR))
     if os.environ.get('GOPATH') == None:
         os.environ["GOPATH"] = os.getcwd()
     else:
@@ -232,13 +242,13 @@ def run_keep_proxy(auth):
 
 def stop_keep_proxy():
     cwd = os.getcwd()
-    os.chdir(os.path.join(os.path.dirname(__file__), KEEP_SERVER_DIR))
+    os.chdir(os.path.join(MY_DIRNAME, KEEP_SERVER_DIR))
     kill_server_pid("tmp/keepproxy.pid", 0)
     os.chdir(cwd)
 
 def fixture(fix):
     '''load a fixture yaml file'''
-    with open(os.path.join(os.path.dirname(__file__), ARV_API_SERVER_DIR, "test", "fixtures",
+    with open(os.path.join(MY_DIRNAME, ARV_API_SERVER_DIR, "test", "fixtures",
                            fix + ".yml")) as f:
         return yaml.load(f.read())
 
index 9e78223596cbaaea4ea561f26126a50d997dc3f0..47c33b4e1b2384e724a8b0194957d522de22c3e8 100644 (file)
@@ -31,7 +31,7 @@ type ServerRequiredSuite struct{}
 
 func pythonDir() string {
        gopath := os.Getenv("GOPATH")
-       return fmt.Sprintf("%s/../../sdk/python", strings.Split(gopath, ":")[0])
+       return fmt.Sprintf("%s/../../sdk/python/tests", strings.Split(gopath, ":")[0])
 }
 
 func (s *ServerRequiredSuite) SetUpSuite(c *C) {