3021: Refactor run_test_server.
authorTom Clegg <tom@curoverse.com>
Mon, 2 Feb 2015 00:48:09 +0000 (19:48 -0500)
committerTom Clegg <tom@curoverse.com>
Mon, 2 Feb 2015 05:29:01 +0000 (00:29 -0500)
* Always start API server with both https:// and wss:// enabled. Use
  mocks to test the websocket-not-available case.

* Leave the API server running between tests; just hit reset() when
  needed. Wait until exiting the process to stop the server.

* Do not use rake (tmp:cache:clear, db:test:load, db:fixtures:load) to
  reset the API server's database before starting up a new
  server. Instead, call /database/reset after starting it. (If that
  doesn't work, crash instead of proceeding with undefined results.)

* If a parent process has already started an API server and put its
  endpoint in ARVADOS_TEST_API_HOST, use that instead of starting a
  new one, and leave it running at exit.

* Start servers on random port numbers, so [some] test suites can run
  concurrently with others on a single host (assuming they're
  configured to use different databases).

.gitignore
sdk/python/tests/run_test_server.py
sdk/python/tests/test_api.py
sdk/python/tests/test_keep_client.py
sdk/python/tests/test_pipeline_template.py
sdk/python/tests/test_websockets.py
services/api/config/application.default.yml
services/fuse/tests/test_mount.py

index 8cc6b89324311d0cd7db51f9c6a5e7ba400253dc..ae824a2e5f6931d81ab0615fef39ad74fc53acd7 100644 (file)
@@ -17,3 +17,4 @@ apps/workbench/vendor/bundle
 services/api/vendor/bundle
 sdk/java/log
 sdk/cli/vendor
+/tmp
index 739c75499509fabb24312bdd6c87a9cb5d8f48e8..534c767b8702cfae8d5566c465cadcf242dab781 100644 (file)
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
 
 import argparse
+import atexit
+import httplib2
 import os
+import pipes
+import random
+import re
 import shutil
 import signal
 import subprocess
@@ -21,18 +26,19 @@ if __name__ == '__main__' and os.path.exists(
 import arvados.api
 import arvados.config
 
-SERVICES_SRC_DIR = os.path.join(MY_DIRNAME, '../../../services')
-SERVER_PID_PATH = 'tmp/pids/webrick-test.pid'
-WEBSOCKETS_SERVER_PID_PATH = 'tmp/pids/passenger-test.pid'
+ARVADOS_DIR = os.path.realpath(os.path.join(MY_DIRNAME, '../../..'))
+SERVICES_SRC_DIR = os.path.join(ARVADOS_DIR, 'services')
+SERVER_PID_PATH = 'tmp/pids/test-server.pid'
 if 'GOPATH' in os.environ:
     gopaths = os.environ['GOPATH'].split(':')
     gobins = [os.path.join(path, 'bin') for path in gopaths]
     os.environ['PATH'] = ':'.join(gobins) + ':' + os.environ['PATH']
 
-if os.path.isdir('tests'):
-    TEST_TMPDIR = 'tests/tmp'
-else:
-    TEST_TMPDIR = 'tmp'
+TEST_TMPDIR = os.path.join(ARVADOS_DIR, 'tmp')
+if not os.path.exists(TEST_TMPDIR):
+    os.mkdir(TEST_TMPDIR)
+
+my_api_host = None
 
 def find_server_pid(PID_PATH, wait=10):
     now = time.time()
@@ -55,11 +61,15 @@ def find_server_pid(PID_PATH, wait=10):
 
     return server_pid
 
-def kill_server_pid(PID_PATH, wait=10):
+def kill_server_pid(pidfile, wait=10):
+    # Must re-import modules in order to work during atexit
+    import os
+    import signal
+    import time
     try:
         now = time.time()
         timeout = now + wait
-        with open(PID_PATH, 'r') as f:
+        with open(pidfile, 'r') as f:
             server_pid = int(f.read())
         while now <= timeout:
             os.kill(server_pid, signal.SIGTERM)
@@ -67,78 +77,111 @@ def kill_server_pid(PID_PATH, wait=10):
             now = time.time()
             time.sleep(0.1)
     except IOError:
-        good_pid = False
+        pass
     except OSError:
-        good_pid = False
-
-def run(websockets=False, reuse_server=False):
-    cwd = os.getcwd()
-    os.chdir(os.path.join(SERVICES_SRC_DIR, 'api'))
-
-    if websockets:
-        pid_file = WEBSOCKETS_SERVER_PID_PATH
-    else:
-        pid_file = SERVER_PID_PATH
-
-    test_pid = find_server_pid(pid_file, 0)
-
-    if test_pid is None or not reuse_server:
-        # do not try to run both server variants at once
-        stop()
-
-        # delete cached discovery document
-        shutil.rmtree(arvados.http_cache('discovery'))
+        pass
 
-        # 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'])
+def run(leave_running_atexit=False):
+    """Ensure an API server is running, and ARVADOS_API_* env vars have
+    admin credentials for it.
+    """
+    global my_api_host
 
-        subprocess.call(['bundle', 'exec', 'rails', 'server', '-d',
-                         '--pid',
-                         os.path.join(os.getcwd(), SERVER_PID_PATH),
-                         '-p3000'])
-        os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3000"
+    # Delete cached discovery document.
+    shutil.rmtree(arvados.http_cache('discovery'))
 
-        if websockets:
-            os.environ["ARVADOS_WEBSOCKETS"] = "ws-only"
-            subprocess.call(['bundle', 'exec',
-                             'passenger', 'start', '-d', '-p3333',
-                             '--pid-file',
-                             os.path.join(os.getcwd(), WEBSOCKETS_SERVER_PID_PATH)
-                         ])
+    os.environ['ARVADOS_API_TOKEN'] = auth_token('admin')
+    os.environ['ARVADOS_API_HOST_INSECURE'] = 'true'
 
-        pid = find_server_pid(SERVER_PID_PATH)
+    pid_file = os.path.join(SERVICES_SRC_DIR, 'api', SERVER_PID_PATH)
+    pid_file_ok = find_server_pid(pid_file, 0)
 
-    os.environ["ARVADOS_API_HOST_INSECURE"] = "true"
-    os.environ["ARVADOS_API_TOKEN"] = ""
-    os.chdir(cwd)
+    if pid_file_ok:
+        try:
+            reset()
+            return
+        except:
+            pass
 
-def stop():
-    cwd = os.getcwd()
+    restore_cwd = os.getcwd()
     os.chdir(os.path.join(SERVICES_SRC_DIR, 'api'))
 
-    kill_server_pid(WEBSOCKETS_SERVER_PID_PATH, 0)
-    kill_server_pid(SERVER_PID_PATH, 0)
-
-    try:
-        os.unlink('self-signed.pem')
-    except:
-        pass
-
-    try:
-        os.unlink('self-signed.key')
-    except:
-        pass
-
-    os.chdir(cwd)
+    # Either we haven't started a server of our own yet, or it has
+    # died, or we have lost our credentials, or something else is
+    # preventing us from calling reset(). Start a new one.
+
+    if not os.path.exists('tmp/self-signed.pem'):
+        # We assume here that either passenger reports its listening
+        # address as https:/0.0.0.0:port/. If it reports "127.0.0.1"
+        # then the certificate won't match the host and reset() will
+        # fail certificate verification. If it reports "localhost",
+        # clients (notably Python SDK's websocket client) might
+        # resolve localhost as ::1 and then fail to connect.
+        subprocess.check_call([
+            'openssl', 'req', '-new', '-x509', '-nodes',
+            '-out', 'tmp/self-signed.pem',
+            '-keyout', 'tmp/self-signed.key',
+            '-days', '3650',
+            '-subj', '/CN=0.0.0.0'])
+
+    port = random.randint(20000, 40000)
+    env = os.environ.copy()
+    env['RAILS_ENV'] = 'test'
+    env['ARVADOS_WEBSOCKETS'] = 'yes'
+    env.pop('ARVADOS_TEST_API_HOST', None)
+    env.pop('ARVADOS_API_HOST', None)
+    env.pop('ARVADOS_API_HOST_INSECURE', None)
+    env.pop('ARVADOS_API_TOKEN', None)
+    start_msg = subprocess.check_output(
+        ['bundle', 'exec',
+         'passenger', 'start', '-d', '-p{}'.format(port),
+         '--pid-file', os.path.join(os.getcwd(), pid_file),
+         '--log-file', os.path.join(os.getcwd(), 'log/test.log'),
+         '--ssl',
+         '--ssl-certificate', 'tmp/self-signed.pem',
+         '--ssl-certificate-key', 'tmp/self-signed.key'],
+        env=env)
+
+    if not leave_running_atexit:
+        atexit.register(kill_server_pid, pid_file)
+
+    match = re.search(r'Accessible via: https://(.*?)/', start_msg)
+    if not match:
+        raise Exception(
+            "Passenger did not report endpoint: {}".format(start_msg))
+    my_api_host = match.group(1)
+    os.environ['ARVADOS_API_HOST'] = my_api_host
+
+    # Make sure the server has written its pid file before continuing
+    find_server_pid(pid_file)
+
+    reset()
+    os.chdir(restore_cwd)
+
+def reset():
+    token = auth_token('admin')
+    httpclient = httplib2.Http(ca_certs=os.path.join(
+        SERVICES_SRC_DIR, 'api', 'tmp', 'self-signed.pem'))
+    httpclient.request(
+        'https://{}/database/reset'.format(os.environ['ARVADOS_API_HOST']),
+        'POST',
+        headers={'Authorization': 'OAuth2 {}'.format(token)})
+
+def stop(force=False):
+    """Stop the API server, if one is running. If force==True, kill it
+    even if we didn't start it ourselves.
+    """
+    global my_api_host
+    if force or my_api_host is not None:
+        kill_server_pid(os.path.join(SERVICES_SRC_DIR, 'api', SERVER_PID_PATH))
+        my_api_host = None
 
 def _start_keep(n, keep_args):
     keep0 = tempfile.mkdtemp()
+    port = random.randint(20000, 40000)
     keep_cmd = ["keepstore",
                 "-volumes={}".format(keep0),
-                "-listen=:{}".format(25107+n),
+                "-listen=:{}".format(port),
                 "-pid={}".format("{}/keep{}.pid".format(TEST_TMPDIR, n))]
 
     for arg, val in keep_args.iteritems():
@@ -151,12 +194,11 @@ def _start_keep(n, keep_args):
     with open("{}/keep{}.volume".format(TEST_TMPDIR, n), 'w') as f:
         f.write(keep0)
 
+    return port
+
 def run_keep(blob_signing_key=None, enforce_permissions=False):
     stop_keep()
 
-    if not os.path.exists(TEST_TMPDIR):
-        os.mkdir(TEST_TMPDIR)
-
     keep_args = {}
     if blob_signing_key:
         with open(os.path.join(TEST_TMPDIR, "keep.blob_signing_key"), "w") as f:
@@ -165,33 +207,28 @@ def run_keep(blob_signing_key=None, enforce_permissions=False):
     if enforce_permissions:
         keep_args['--enforce-permissions'] = 'true'
 
-    _start_keep(0, keep_args)
-    _start_keep(1, keep_args)
-
-    os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3000"
-    os.environ["ARVADOS_API_HOST_INSECURE"] = "true"
-
-    authorize_with("admin")
-    api = arvados.api('v1', cache=False)
+    api = arvados.api(
+        'v1', cache=False,
+        host=os.environ['ARVADOS_API_HOST'],
+        token=os.environ['ARVADOS_API_TOKEN'],
+        insecure=True)
     for d in api.keep_services().list().execute()['items']:
         api.keep_services().delete(uuid=d['uuid']).execute()
     for d in api.keep_disks().list().execute()['items']:
         api.keep_disks().delete(uuid=d['uuid']).execute()
 
-    s1 = api.keep_services().create(body={"keep_service": {
-                "uuid": "zzzzz-bi6l4-5bo5n1iekkjyz6b",
-                "service_host": "localhost",
-                "service_port": 25107,
-                "service_type": "disk"
-                }}).execute()
-    s2 = api.keep_services().create(body={"keep_service": {
-                "uuid": "zzzzz-bi6l4-2nz60e0ksj7vr3s",
-                "service_host": "localhost",
-                "service_port": 25108,
-                "service_type": "disk"
-                }}).execute()
-    api.keep_disks().create(body={"keep_disk": {"keep_service_uuid": s1["uuid"] } }).execute()
-    api.keep_disks().create(body={"keep_disk": {"keep_service_uuid": s2["uuid"] } }).execute()
+    for d in range(0, 2):
+        port = _start_keep(d, keep_args)
+        svc = api.keep_services().create(body={'keep_service': {
+            'uuid': 'zzzzz-bi6l4-keepdisk{:07d}'.format(d),
+            'service_host': 'localhost',
+            'service_port': port,
+            'service_type': 'disk',
+            'service_ssl_flag': False,
+        }}).execute()
+        api.keep_disks().create(body={
+            'keep_disk': {'keep_service_uuid': svc['uuid'] }
+        }).execute()
 
 def _stop_keep(n):
     kill_server_pid("{}/keep{}.pid".format(TEST_TMPDIR, n), 0)
@@ -206,25 +243,34 @@ def stop_keep():
     _stop_keep(0)
     _stop_keep(1)
 
-def run_keep_proxy(auth):
+def run_keep_proxy():
     stop_keep_proxy()
 
-    if not os.path.exists(TEST_TMPDIR):
-        os.mkdir(TEST_TMPDIR)
-
-    os.environ["ARVADOS_API_HOST"] = "127.0.0.1:3000"
-    os.environ["ARVADOS_API_HOST_INSECURE"] = "true"
-    os.environ["ARVADOS_API_TOKEN"] = fixture("api_client_authorizations")[auth]["api_token"]
-
-    kp0 = subprocess.Popen(["keepproxy",
-                            "-pid={}/keepproxy.pid".format(TEST_TMPDIR),
-                            "-listen=:{}".format(25101)])
-
-    authorize_with("admin")
-    api = arvados.api('v1', cache=False)
-    api.keep_services().create(body={"keep_service": {"service_host": "localhost",  "service_port": 25101, "service_type": "proxy"} }).execute()
-
-    os.environ["ARVADOS_KEEP_PROXY"] = "http://localhost:25101"
+    admin_token = auth_token('admin')
+    port = random.randint(20000,40000)
+    env = os.environ.copy()
+    env['ARVADOS_API_TOKEN'] = admin_token
+    kp = subprocess.Popen(
+        ['keepproxy',
+         '-pid={}/keepproxy.pid'.format(TEST_TMPDIR),
+         '-listen=:{}'.format(port)],
+        env=env)
+
+    api = arvados.api(
+        'v1', cache=False,
+        host=os.environ['ARVADOS_API_HOST'],
+        token=admin_token,
+        insecure=True)
+    for d in api.keep_services().list(
+            filters=[['service_type','=','proxy']]).execute()['items']:
+        api.keep_services().delete(uuid=d['uuid']).execute()
+    api.keep_services().create(body={'keep_service': {
+        'service_host': 'localhost',
+        'service_port': port,
+        'service_type': 'proxy',
+        'service_ssl_flag': False,
+    }}).execute()
+    os.environ["ARVADOS_KEEP_PROXY"] = "http://localhost:{}".format(port)
 
 def stop_keep_proxy():
     kill_server_pid(os.path.join(TEST_TMPDIR, "keepproxy.pid"), 0)
@@ -241,9 +287,12 @@ def fixture(fix):
           pass
         return yaml.load(yaml_file)
 
-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"]
+def auth_token(token_name):
+    return fixture("api_client_authorizations")[token_name]["api_token"]
+
+def authorize_with(token_name):
+    '''token_name is the symbolic name of the token from the api_client_authorizations fixture'''
+    arvados.config.settings()["ARVADOS_API_TOKEN"] = auth_token(token_name)
     arvados.config.settings()["ARVADOS_API_HOST"] = os.environ.get("ARVADOS_API_HOST")
     arvados.config.settings()["ARVADOS_API_HOST_INSECURE"] = "true"
 
@@ -279,16 +328,15 @@ class TestCaseWithServers(unittest.TestCase):
         cls._orig_environ = os.environ.copy()
         cls._orig_config = arvados.config.settings().copy()
         cls._cleanup_funcs = []
+        os.environ.pop('ARVADOS_KEEP_PROXY', None)
+        os.environ.pop('ARVADOS_EXTERNAL_CLIENT', None)
         for server_kwargs, start_func, stop_func in (
-              (cls.MAIN_SERVER, run, stop),
-              (cls.KEEP_SERVER, run_keep, stop_keep),
-              (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy)):
+                (cls.MAIN_SERVER, run, reset),
+                (cls.KEEP_SERVER, run_keep, stop_keep),
+                (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy)):
             if server_kwargs is not None:
                 start_func(**server_kwargs)
                 cls._cleanup_funcs.append(stop_func)
-        os.environ.pop('ARVADOS_EXTERNAL_CLIENT', None)
-        if cls.KEEP_PROXY_SERVER is None:
-            os.environ.pop('ARVADOS_KEEP_PROXY', None)
         if (cls.KEEP_SERVER is None) and (cls.KEEP_PROXY_SERVER is None):
             cls.local_store = tempfile.mkdtemp()
             os.environ['KEEP_LOCAL_STORE'] = cls.local_store
@@ -307,29 +355,34 @@ class TestCaseWithServers(unittest.TestCase):
 
 
 if __name__ == "__main__":
+    actions = ['start', 'stop',
+               'start_keep', 'stop_keep',
+               'start_keep_proxy', 'stop_keep_proxy']
     parser = argparse.ArgumentParser()
-    parser.add_argument('action', type=str, help='''one of "start", "stop", "start_keep", "stop_keep"''')
-    parser.add_argument('--websockets', action='store_true', default=False)
-    parser.add_argument('--reuse', action='store_true', default=False)
-    parser.add_argument('--auth', type=str, help='Print authorization info for given api_client_authorizations fixture')
+    parser.add_argument('action', type=str, help="one of {}".format(actions))
+    parser.add_argument('--auth', type=str, metavar='FIXTURE_NAME', help='Print authorization info for given api_client_authorizations fixture')
     args = parser.parse_args()
 
     if args.action == 'start':
-        run(websockets=args.websockets, reuse_server=args.reuse)
+        stop(force=('ARVADOS_TEST_API_HOST' not in os.environ))
+        run(leave_running_atexit=True)
+        host = os.environ['ARVADOS_API_HOST']
         if args.auth is not None:
-            authorize_with(args.auth)
-            print("export ARVADOS_API_HOST={}".format(arvados.config.settings()["ARVADOS_API_HOST"]))
-            print("export ARVADOS_API_TOKEN={}".format(arvados.config.settings()["ARVADOS_API_TOKEN"]))
-            print("export ARVADOS_API_HOST_INSECURE={}".format(arvados.config.settings()["ARVADOS_API_HOST_INSECURE"]))
+            token = auth_token(args.auth)
+            print("export ARVADOS_API_TOKEN={}".format(pipes.quote(token)))
+            print("export ARVADOS_API_HOST={}".format(pipes.quote(host)))
+            print("export ARVADOS_API_HOST_INSECURE=true")
+        else:
+            print(host)
     elif args.action == 'stop':
-        stop()
+        stop(force=('ARVADOS_TEST_API_HOST' not in os.environ))
     elif args.action == 'start_keep':
         run_keep()
     elif args.action == 'stop_keep':
         stop_keep()
     elif args.action == 'start_keep_proxy':
-        run_keep_proxy("admin")
+        run_keep_proxy()
     elif args.action == 'stop_keep_proxy':
         stop_keep_proxy()
     else:
-        print('Unrecognized action "{}", actions are "start", "stop", "start_keep", "stop_keep"'.format(args.action))
+        print("Unrecognized action '{}'. Actions are: {}.".format(args.action, actions))
index 4d03ae7744814f8629edd0b9cc37be7d9b41269c..576e47ae3d661f5469409651e597cc26ad0f5499 100644 (file)
@@ -48,9 +48,8 @@ class ArvadosApiClientTest(unittest.TestCase):
                               insecure=True,
                               requestBuilder=req_builder)
 
-    @classmethod
-    def tearDownClass(cls):
-        run_test_server.stop()
+    def tearDown(cls):
+        run_test_server.reset()
 
     def test_new_api_objects_with_cache(self):
         clients = [arvados.api('v1', cache=True,
index 37f274a16118f6e46966df5770f7686cd6e45131..9aafbea3c9509ab188cf799c4095d42be32ba3ca 100644 (file)
@@ -188,11 +188,12 @@ class KeepOptionalPermission(run_test_server.TestCaseWithServers):
 class KeepProxyTestCase(run_test_server.TestCaseWithServers):
     MAIN_SERVER = {}
     KEEP_SERVER = {}
-    KEEP_PROXY_SERVER = {'auth': 'admin'}
+    KEEP_PROXY_SERVER = {}
 
     @classmethod
     def setUpClass(cls):
         super(KeepProxyTestCase, cls).setUpClass()
+        run_test_server.authorize_with('active')
         cls.api_client = arvados.api('v1')
 
     def tearDown(self):
index bc82271f9c4f0019e6565086f2405e20ee8d3bcc..fa9fef28266bd668d61b1513adcf47395a937a6d 100644 (file)
@@ -7,9 +7,9 @@ import arvados
 import apiclient
 import run_test_server
 
-class PipelineTemplateTest(unittest.TestCase):
-    def setUp(self):
-        run_test_server.run()
+class PipelineTemplateTest(run_test_server.TestCaseWithServers):
+    MAIN_SERVER = {}
+    KEEP_SERVER = {}
 
     def runTest(self):
         run_test_server.authorize_with("admin")
@@ -55,6 +55,3 @@ class PipelineTemplateTest(unittest.TestCase):
             geterror_response = arvados.api('v1').pipeline_templates().get(
                 uuid=pt_uuid
                 ).execute()
-
-    def tearDown(self):
-        run_test_server.stop()
index 61fb54df225cf6c4a299314493d55b4b2134ef93..20fa97c41bba66cd83f3a975af26bc846085cac1 100644 (file)
@@ -3,37 +3,37 @@ import run_test_server
 import unittest
 import arvados
 import arvados.events
+import mock
 import threading
 
-class EventTestBase(object):
-    def runTest(self):
-        run_test_server.authorize_with("admin")
+class WebsocketTest(run_test_server.TestCaseWithServers):
+    MAIN_SERVER = {}
+
+    def setUp(self):
+        self.ws = None
+
+    def tearDown(self):
+        if self.ws:
+            self.ws.close()
+
+    def _test_subscribe(self, poll_fallback, expect_type):
+        run_test_server.authorize_with('active')
         events = Queue.Queue(3)
         self.ws = arvados.events.subscribe(
             arvados.api('v1'), [['object_uuid', 'is_a', 'arvados#human']],
-            events.put, poll_fallback=2)
-        self.assertIsInstance(self.ws, self.WS_TYPE)
+            events.put, poll_fallback=poll_fallback)
+        self.assertIsInstance(self.ws, expect_type)
         self.assertEqual(200, events.get(True, 10)['status'])
         human = arvados.api('v1').humans().create(body={}).execute()
         self.assertEqual(human['uuid'], events.get(True, 10)['object_uuid'])
         self.assertTrue(events.empty(), "got more events than expected")
 
+    def test_subscribe_websocket(self):
+        self._test_subscribe(
+            poll_fallback=False, expect_type=arvados.events.EventClient)
 
-class WebsocketTest(run_test_server.TestCaseWithServers, EventTestBase):
-    MAIN_SERVER = {'websockets': True}
-    WS_TYPE = arvados.events.EventClient
-
-    def tearDown(self):
-        if self.ws:
-            self.ws.close()
-        super(WebsocketTest, self).tearDown()
-
-
-class PollClientTest(run_test_server.TestCaseWithServers, EventTestBase):
-    MAIN_SERVER = {}
-    WS_TYPE = arvados.events.PollClient
-
-    def tearDown(self):
-        if self.ws:
-            self.ws.close()
-        super(PollClientTest, self).tearDown()
+    @mock.patch('arvados.events.EventClient.__init__')
+    def test_subscribe_poll(self, event_client_constr):
+        event_client_constr.side_effect = Exception('All is well')
+        self._test_subscribe(
+            poll_fallback=1, expect_type=arvados.events.PollClient)
index ed2c533f5662e008bc4d25f5ae4b29c7556b0a49..2d62e40f034a6bcbaca3697768d9ca7e48246ad4 100644 (file)
@@ -45,7 +45,6 @@ test:
   blob_signing_key: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc
   user_profile_notification_address: arvados@example.com
   workbench_address: https://localhost:3001/
-  websocket_address: ws://127.0.0.1:3333/websocket
 
 common:
   uuid_prefix: <%= Digest::MD5.hexdigest(`hostname`).to_i(16).to_s(36)[0..4] %>
index 84dceee13764ea6d1ab2327b27f44f1973af3ce7..d279b4f45041cf739f2978299966cdd15e1a552d 100644 (file)
@@ -17,7 +17,7 @@ class MountTestBase(unittest.TestCase):
         self.keeptmp = tempfile.mkdtemp()
         os.environ['KEEP_LOCAL_STORE'] = self.keeptmp
         self.mounttmp = tempfile.mkdtemp()
-        run_test_server.run(False)
+        run_test_server.run()
         run_test_server.authorize_with("admin")
         self.api = api = fuse.SafeApi(arvados.config)
 
@@ -31,7 +31,7 @@ class MountTestBase(unittest.TestCase):
         operations.initlock.wait()
 
     def tearDown(self):
-        run_test_server.stop()
+        run_test_server.reset()
 
         # llfuse.close is buggy, so use fusermount instead.
         #llfuse.close(unmount=True)