projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
4533: Merge branch 'master' into 4533-remote-reset
[arvados.git]
/
services
/
nodemanager
/
tests
/
testutil.py
diff --git
a/services/nodemanager/tests/testutil.py
b/services/nodemanager/tests/testutil.py
index 7d6549decd1943189ce8491024924bfcfc085e1e..56f22c8e08fc66f69c90422e30bb116b372dfbf6 100644
(file)
--- a/
services/nodemanager/tests/testutil.py
+++ b/
services/nodemanager/tests/testutil.py
@@
-15,7
+15,7
@@
def arvados_node_mock(node_num=99, job_uuid=None, age=0, **kwargs):
if job_uuid is True:
job_uuid = 'zzzzz-jjjjj-jobjobjobjobjob'
slurm_state = 'idle' if (job_uuid is None) else 'alloc'
if job_uuid is True:
job_uuid = 'zzzzz-jjjjj-jobjobjobjobjob'
slurm_state = 'idle' if (job_uuid is None) else 'alloc'
- node = {'uuid': 'zzzzz-yyyyy-
12345abcde67890'
,
+ node = {'uuid': 'zzzzz-yyyyy-
{:015x}'.format(node_num)
,
'created_at': '2014-01-01T01:02:03Z',
'modified_at': time.strftime('%Y-%m-%dT%H:%M:%SZ',
time.gmtime(time.time() - age)),
'created_at': '2014-01-01T01:02:03Z',
'modified_at': time.strftime('%Y-%m-%dT%H:%M:%SZ',
time.gmtime(time.time() - age)),
@@
-41,6
+41,12
@@
def cloud_node_mock(node_num=99):
def ip_address_mock(last_octet):
return '10.20.30.{}'.format(last_octet)
def ip_address_mock(last_octet):
return '10.20.30.{}'.format(last_octet)
+class MockShutdownTimer(object):
+ def _set_state(self, is_open, next_opening):
+ self.window_open = lambda: is_open
+ self.next_opening = lambda: next_opening
+
+
class MockSize(object):
def __init__(self, factor):
self.id = 'z{}.test'.format(factor)
class MockSize(object):
def __init__(self, factor):
self.id = 'z{}.test'.format(factor)
@@
-67,11
+73,19
@@
class ActorTestMixin(object):
def tearDown(self):
pykka.ActorRegistry.stop_all()
def tearDown(self):
pykka.ActorRegistry.stop_all()
- def wait_for_call(self, mock_func, timeout=TIMEOUT):
+ def stop_proxy(self, proxy):
+ return proxy.actor_ref.stop(timeout=self.TIMEOUT)
+
+ def wait_for_assignment(self, proxy, attr_name, unassigned=None,
+ timeout=TIMEOUT):
deadline = time.time() + timeout
deadline = time.time() + timeout
- while (not mock_func.called) and (time.time() < deadline):
- time.sleep(.1)
- self.assertTrue(mock_func.called, "{} not called".format(mock_func))
+ while True:
+ loop_timeout = deadline - time.time()
+ if loop_timeout <= 0:
+ self.fail("actor did not assign {} in time".format(attr_name))
+ result = getattr(proxy, attr_name).get(loop_timeout)
+ if result is not unassigned:
+ return result
class RemotePollLoopActorTestMixin(ActorTestMixin):
class RemotePollLoopActorTestMixin(ActorTestMixin):