4139: Add environment configuration knobs for Node Manager tests.
authorBrett Smith <brett@curoverse.com>
Thu, 9 Oct 2014 17:31:47 +0000 (13:31 -0400)
committerBrett Smith <brett@curoverse.com>
Thu, 9 Oct 2014 17:32:09 +0000 (13:32 -0400)
These are settings I've fiddled with regularly over the course of
development, and now it looks like we're going to need to fiddle them
some more to accommodate Jenkins.  I'm exposing them as environment
variables so I can stop messing with the code appropriately.
Refs #4139.

services/nodemanager/tests/__init__.py
services/nodemanager/tests/testutil.py

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d374840eafa870c09bc839dcf6495665509e8416 100644 (file)
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import logging
+import os
+
+# Set the ANMTEST_LOGLEVEL environment variable to enable logging at that level.
+loglevel = os.environ.get('ANMTEST_LOGLEVEL', 'CRITICAL')
+logging.basicConfig(level=getattr(logging, loglevel.upper()))
+
+# Many tests wait for an actor to call a mock method.  They poll very
+# regularly (see wait_for_call in ActorTestMixin), but if you've
+# broken something, a long timeout can mean you'll spend a lot of time
+# watching failures come in.  You can set the ANMTEST_TIMEOUT
+# environment variable to arrange a shorter timeout while you're doing
+# regular development.
+pykka_timeout = int(os.environ.get('ANMTEST_TIMEOUT', '10'))
index a33f76fe86a62d7e848846d557efed2c2cd03e1e..7d6549decd1943189ce8491024924bfcfc085e1e 100644 (file)
@@ -7,6 +7,8 @@ import time
 import mock
 import pykka
 
+from . import pykka_timeout
+
 no_sleep = mock.patch('time.sleep', lambda n: None)
 
 def arvados_node_mock(node_num=99, job_uuid=None, age=0, **kwargs):
@@ -60,7 +62,7 @@ class MockTimer(object):
 
 class ActorTestMixin(object):
     FUTURE_CLASS = pykka.ThreadingFuture
-    TIMEOUT = 5
+    TIMEOUT = pykka_timeout
 
     def tearDown(self):
         pykka.ActorRegistry.stop_all()