[ARVADOS] updated: 4556f61d8f4ec294afa7980d1b00882e2a1ffdfa

git at public.curoverse.com git at public.curoverse.com
Fri May 9 02:59:59 EDT 2014


Summary of changes:
 doc/sdk/python/sdk-python.html.textile.liquid |    2 +-
 sdk/python/arvados/api.py                     |    7 +++--
 sdk/python/run_test_server.py                 |   26 +++++++++++++++++-------
 sdk/python/test_mount.py                      |    6 ++--
 sdk/python/test_pipeline_template.py          |   10 ++++----
 sdk/python/test_websockets.py                 |    4 +-
 services/api/config/application.default.yml   |   10 +++++++++
 services/api/config/application.yml.example   |    7 ------
 services/api/config/initializers/eventbus.rb  |    6 +---
 9 files changed, 45 insertions(+), 33 deletions(-)

       via  4556f61d8f4ec294afa7980d1b00882e2a1ffdfa (commit)
      from  dc068f04e966c35eee87af8da280bbbeb9ba3595 (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 4556f61d8f4ec294afa7980d1b00882e2a1ffdfa
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 9 02:57:27 2014 -0400

    Fix python SDK test suite issues.

diff --git a/doc/sdk/python/sdk-python.html.textile.liquid b/doc/sdk/python/sdk-python.html.textile.liquid
index ea55a96..89b77c9 100644
--- a/doc/sdk/python/sdk-python.html.textile.liquid
+++ b/doc/sdk/python/sdk-python.html.textile.liquid
@@ -24,7 +24,7 @@ h4. Option 1: install with PyPI
 
 <notextile>
 <pre>
-$ <code class="userinput">sudo apt-get install python-pip python-dev libattr1-dev libfuse-dev pkg-config</code>
+$ <code class="userinput">sudo apt-get install python-pip python-dev libattr1-dev libfuse-dev pkg-config python-yaml</code>
 $ <code class="userinput">sudo pip install arvados-python-client</code>
 </pre>
 </notextile>
diff --git a/sdk/python/arvados/api.py b/sdk/python/arvados/api.py
index 4413167..30acdc4 100644
--- a/sdk/python/arvados/api.py
+++ b/sdk/python/arvados/api.py
@@ -55,13 +55,13 @@ def http_cache(data_type):
         path = None
     return path
 
-def api(version=None):
+def api(version=None, cache=True):
     global services
 
     if 'ARVADOS_DEBUG' in config.settings():
         logging.basicConfig(level=logging.DEBUG)
 
-    if not services.get(version):
+    if not cache or not services.get(version):
         apiVersion = version
         if not version:
             apiVersion = 'v1'
@@ -80,12 +80,13 @@ def api(version=None):
             ca_certs = None             # use httplib2 default
 
         http = httplib2.Http(ca_certs=ca_certs,
-                             cache=http_cache('discovery'))
+                             cache=(http_cache('discovery') if cache else None))
         http = credentials.authorize(http)
         if re.match(r'(?i)^(true|1|yes)$',
                     config.get('ARVADOS_API_HOST_INSECURE', 'no')):
             http.disable_ssl_certificate_validation=True
         services[version] = apiclient.discovery.build(
             'arvados', apiVersion, http=http, discoveryServiceUrl=url)
+        http.cache = None
     return services[version]
 
diff --git a/sdk/python/run_test_server.py b/sdk/python/run_test_server.py
index fce8981..a71b403 100644
--- a/sdk/python/run_test_server.py
+++ b/sdk/python/run_test_server.py
@@ -6,13 +6,14 @@ import yaml
 import sys
 import argparse
 import arvados.config
+import arvados.api
 import shutil
 import tempfile
 
 ARV_API_SERVER_DIR = '../../services/api'
 KEEP_SERVER_DIR = '../../services/keep'
-SERVER_PID_PATH = 'tmp/pids/server.pid'
-WEBSOCKETS_SERVER_PID_PATH = 'tmp/pids/passenger.3001.pid'
+SERVER_PID_PATH = 'tmp/pids/webrick-test.pid'
+WEBSOCKETS_SERVER_PID_PATH = 'tmp/pids/passenger-test.pid'
 
 def find_server_pid(PID_PATH, wait=10):
     now = time.time()
@@ -65,10 +66,11 @@ def run(websockets=False, reuse_server=False):
             stop()
 
         # delete cached discovery document
-        shutil.rmtree(os.path.join("~", ".cache", "arvados", "discovery"), True)
+        shutil.rmtree(arvados.http_cache('discovery'))
 
         # Setup database
         os.environ["RAILS_ENV"] = "test"
+        subprocess.call(['bundle', 'exec', 'rake', 'tmp:cache:clear'])
         subprocess.call(['bundle', 'exec', 'rake', 'db:test:load'])
         subprocess.call(['bundle', 'exec', 'rake', 'db:fixtures:load'])
 
@@ -79,16 +81,23 @@ def run(websockets=False, reuse_server=False):
                              '-keyout', './self-signed.key',
                              '-days', '3650',
                              '-subj', '/CN=localhost'])
-            subprocess.call(['passenger', 'start', '-d', '-p3001', '--ssl',
+            subprocess.call(['bundle', 'exec',
+                             'passenger', 'start', '-d', '-p3333',
+                             '--pid-file',
+                             os.path.join(os.getcwd(), WEBSOCKETS_SERVER_PID_PATH),
+                             '--ssl',
                              '--ssl-certificate', 'self-signed.pem',
                              '--ssl-certificate-key', 'self-signed.key'])
+            os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3333"
         else:
-            subprocess.call(['bundle', 'exec', 'rails', 'server', '-d', '-p3001'])
+            subprocess.call(['bundle', 'exec', 'rails', 'server', '-d',
+                             '--pid',
+                             os.path.join(os.getcwd(), SERVER_PID_PATH),
+                             '-p3001'])
+            os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3001"
 
         pid = find_server_pid(SERVER_PID_PATH)
 
-    #os.environ["ARVADOS_API_HOST"] = "localhost:3001"
-    os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3001"
     os.environ["ARVADOS_API_HOST_INSECURE"] = "true"
     os.environ["ARVADOS_API_TOKEN"] = ""
     os.chdir(cwd)
@@ -175,6 +184,7 @@ def fixture(fix):
 def authorize_with(token):
     '''token is the symbolic name of the token from the api_client_authorizations fixture'''
     arvados.config.settings()["ARVADOS_API_TOKEN"] = fixture("api_client_authorizations")[token]["api_token"]
+    arvados.config.settings()["ARVADOS_API_HOST"] = os.environ.get("ARVADOS_API_HOST")
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser()
@@ -185,7 +195,7 @@ if __name__ == "__main__":
     args = parser.parse_args()
 
     if args.action == 'start':
-        run(args.websockets, args.reuse)
+        run(websockets=args.websockets, reuse_server=args.reuse)
         if args.auth != None:
             authorize_with(args.auth)
             print("export ARVADOS_API_HOST={}".format(arvados.config.settings()["ARVADOS_API_HOST"]))
diff --git a/sdk/python/test_mount.py b/sdk/python/test_mount.py
index 356c9d4..fd7348b 100644
--- a/sdk/python/test_mount.py
+++ b/sdk/python/test_mount.py
@@ -163,7 +163,7 @@ class FuseTagsTest(MountTestBase):
 
     def runTest(self):
         run_test_server.authorize_with("admin")
-        api = arvados.api('v1')
+        api = arvados.api('v1', cache=False)
 
         operations = fuse.Operations(os.getuid(), os.getgid())
         e = operations.inodes.add_entry(fuse.TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
@@ -204,7 +204,7 @@ class FuseTagsUpdateTestBase(MountTestBase):
 
     def runRealTest(self):
         run_test_server.authorize_with("admin")
-        api = arvados.api('v1')
+        api = arvados.api('v1', cache=False)
 
         operations = fuse.Operations(os.getuid(), os.getgid())
         e = operations.inodes.add_entry(fuse.TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api, poll_time=1))
@@ -290,7 +290,7 @@ class FuseGroupsTest(MountTestBase):
 
     def runTest(self):
         run_test_server.authorize_with("admin")
-        api = arvados.api('v1')
+        api = arvados.api('v1', cache=False)
 
         operations = fuse.Operations(os.getuid(), os.getgid())
         e = operations.inodes.add_entry(fuse.GroupsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
diff --git a/sdk/python/test_pipeline_template.py b/sdk/python/test_pipeline_template.py
index bc82271..54539b0 100644
--- a/sdk/python/test_pipeline_template.py
+++ b/sdk/python/test_pipeline_template.py
@@ -13,7 +13,7 @@ class PipelineTemplateTest(unittest.TestCase):
 
     def runTest(self):
         run_test_server.authorize_with("admin")
-        pt_uuid = arvados.api('v1').pipeline_templates().create(
+        pt_uuid = arvados.api('v1', cache=False).pipeline_templates().create(
             body={'name':__file__}
             ).execute()['uuid']
         self.assertEqual(len(pt_uuid), 27,
@@ -27,7 +27,7 @@ class PipelineTemplateTest(unittest.TestCase):
             'spass_box': False,
             'spass-box': [True, 'Maybe', False]
             }
-        update_response = arvados.api('v1').pipeline_templates().update(
+        update_response = arvados.api('v1', cache=False).pipeline_templates().update(
             uuid=pt_uuid,
             body={'components':components}
             ).execute()
@@ -39,20 +39,20 @@ class PipelineTemplateTest(unittest.TestCase):
         self.assertEqual(update_response['name'], __file__,
                          'update() response has a different name (%s, not %s)'
                          % (update_response['name'], __file__))
-        get_response = arvados.api('v1').pipeline_templates().get(
+        get_response = arvados.api('v1', cache=False).pipeline_templates().get(
             uuid=pt_uuid
             ).execute()
         self.assertEqual(get_response['components'], components,
                          'components got munged by server (%s -> %s)'
                          % (components, update_response['components']))
-        delete_response = arvados.api('v1').pipeline_templates().delete(
+        delete_response = arvados.api('v1', cache=False).pipeline_templates().delete(
             uuid=pt_uuid
             ).execute()
         self.assertEqual(delete_response['uuid'], pt_uuid,
                          'delete() response has wrong uuid (%s, not %s)'
                          % (delete_response['uuid'], pt_uuid))
         with self.assertRaises(apiclient.errors.HttpError):
-            geterror_response = arvados.api('v1').pipeline_templates().get(
+            geterror_response = arvados.api('v1', cache=False).pipeline_templates().get(
                 uuid=pt_uuid
                 ).execute()
 
diff --git a/sdk/python/test_websockets.py b/sdk/python/test_websockets.py
index 92974ca..6b57fe3 100644
--- a/sdk/python/test_websockets.py
+++ b/sdk/python/test_websockets.py
@@ -6,7 +6,7 @@ import time
 
 class WebsocketTest(unittest.TestCase):
     def setUp(self):
-        run_test_server.run(True)
+        run_test_server.run(websockets=True)
 
     def on_event(self, ev):
         if self.state == 1:
@@ -22,7 +22,7 @@ class WebsocketTest(unittest.TestCase):
         self.state = 1
 
         run_test_server.authorize_with("admin")
-        api = arvados.api('v1')
+        api = arvados.api('v1', cache=False)
         arvados.events.subscribe(api, [['object_uuid', 'is_a', 'arvados#human']], lambda ev: self.on_event(ev))
         time.sleep(1)
         self.h = api.humans().create(body={}).execute()
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index 37bb1c3..67aa401 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -112,3 +112,13 @@ common:
   assets.version: "1.0"
 
   arvados_theme: default
+
+  # Default: do not advertise a websocket server.
+  websocket_address: false
+
+  # You can run the websocket server separately from the regular HTTP service
+  # by setting "ARVADOS_WEBSOCKETS=ws-only" in the environment before running
+  # the websocket server.  When you do this, you need to set the following
+  # configuration variable so that the primary server can give out the correct
+  # address of the dedicated websocket server:
+  #websocket_address: wss://127.0.0.1:3333/websocket
diff --git a/services/api/config/application.yml.example b/services/api/config/application.yml.example
index 2705fa1..9162fc4 100644
--- a/services/api/config/application.yml.example
+++ b/services/api/config/application.yml.example
@@ -39,10 +39,3 @@ test:
 common:
   #git_repositories_dir: /var/cache/git
   #git_internal_dir: /var/cache/arvados/internal.git
-
-  # You can run the websocket server separately from the regular HTTP service
-  # by setting "ARVADOS_WEBSOCKETS=ws-only" in the environment before running
-  # the websocket server.  When you do this, you need to set the following
-  # configuration variable so that the primary server can give out the correct
-  # address of the dedicated websocket server:
-  #websocket_address: wss://websocket.local/websocket
diff --git a/services/api/config/initializers/eventbus.rb b/services/api/config/initializers/eventbus.rb
index 7da8ade..4a6141c 100644
--- a/services/api/config/initializers/eventbus.rb
+++ b/services/api/config/initializers/eventbus.rb
@@ -1,5 +1,7 @@
 require 'eventbus'
 
+# See application.yml for details about configuring the websocket service.
+
 Server::Application.configure do
   # Enables websockets if ARVADOS_WEBSOCKETS is defined with any value.  If
   # ARVADOS_WEBSOCKETS=ws-only, server will only accept websocket connections
@@ -11,8 +13,4 @@ Server::Application.configure do
       :websocket_only => (ENV['ARVADOS_WEBSOCKETS'] == "ws-only")
     }
   end
-
-  # Define websocket_address configuration option, can be overridden in config files.
-  # See application.yml.example for details.
-  config.websocket_address = nil
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list