Commit 0b04b188 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

constants: Don't hardcode priorities for LOCK_ATTEMPTS_TIMEOUT



Also include unittest for LOCK_ATTEMPTS_TIMEOUT.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 66abb9ff
......@@ -533,18 +533,6 @@ EXPORT_MODES = frozenset([
EXPORT_MODE_REMOTE,
])
# Lock recalculate mode
LOCKS_REPLACE = "replace"
LOCKS_APPEND = "append"
# Lock timeout (sum) before we should go into blocking acquire (still
# can be reset by priority change); computed as max time (10 hours)
# before we should actually go into blocking acquire given that we
# start from default priority level; in seconds
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
LOCK_ATTEMPTS_MAXWAIT = 15.0
LOCK_ATTEMPTS_MINWAIT = 1.0
# instance creation modes
INSTANCE_CREATE = "create"
INSTANCE_IMPORT = "import"
......@@ -1600,6 +1588,19 @@ OP_PRIO_SUBMIT_VALID = frozenset([
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
# Lock recalculate mode
LOCKS_REPLACE = "replace"
LOCKS_APPEND = "append"
# Lock timeout (sum) before we should go into blocking acquire (still
# can be reset by priority change); computed as max time (10 hours)
# before we should actually go into blocking acquire given that we
# start from default priority level; in seconds
# TODO
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
LOCK_ATTEMPTS_MAXWAIT = 15.0
LOCK_ATTEMPTS_MINWAIT = 1.0
# Execution log types
ELOG_MESSAGE = "message"
ELOG_PROGRESS = "progress"
......
......@@ -40,6 +40,11 @@ class TestLockAttemptTimeoutStrategy(unittest.TestCase):
self.assert_(len(tpa) > LOCK_ATTEMPTS_TIMEOUT / LOCK_ATTEMPTS_MAXWAIT)
self.assert_(sum(tpa) >= LOCK_ATTEMPTS_TIMEOUT)
self.assertTrue(LOCK_ATTEMPTS_TIMEOUT >= 1800,
msg="Waiting less than half an hour per priority")
self.assertTrue(LOCK_ATTEMPTS_TIMEOUT <= 3600,
msg="Waiting more than an hour per priority")
def testSimple(self):
strat = mcpu.LockAttemptTimeoutStrategy(_random_fn=lambda: 0.5,
_time_fn=lambda: 0.0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment