From 93d29ebfa786ac5b57abc7dce28e9a12233e3c11 Mon Sep 17 00:00:00 2001 From: Dave Buchfuhrer Date: Mon, 21 Nov 2016 18:07:40 -0800 Subject: [PATCH] Sets wait_jitter in worker_test.py (#1927) Many tests in worker_test.py set wait_interval to 0.1 but leave wait_jitter at its default value of 5.0. This sets wait_jitter to 0.05 in all such tests, which maintains the expected 0.1 jitter time. This should reduce each wait by about 2.5 seconds, and I've found that it decreases the running time of the worker tests on my machine by about 15 seconds. --- test/worker_test.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/worker_test.py b/test/worker_test.py index 9de2212f3c..145d865c71 100644 --- a/test/worker_test.py +++ b/test/worker_test.py @@ -545,7 +545,7 @@ def run(self): sch = Scheduler(retry_delay=100, remove_delay=1000, worker_disconnect_delay=10) with Worker(scheduler=sch, worker_id='X', keep_alive=True, count_uniques=True) as w: - with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1) as w2: + with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1, wait_jitter=0.05) as w2: self.assertTrue(w.add(a)) self.assertTrue(w2.add(b)) @@ -579,7 +579,7 @@ def run(self): sch = Scheduler(retry_delay=100, remove_delay=1000, worker_disconnect_delay=10) with Worker(scheduler=sch, worker_id='X', keep_alive=True, count_uniques=True) as w: - with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1) as w2: + with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1, wait_jitter=0.05) as w2: self.assertTrue(w.add(b)) self.assertTrue(w2.add(b)) @@ -1644,7 +1644,7 @@ def requires(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: self.assertTrue(w1.add(wt)) self.assertFalse(w1.run()) @@ -1683,9 +1683,9 @@ def requires(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: - with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2: - with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1) as w3: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: + with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2: + with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w3: self.assertTrue(w1.add(wt)) self.assertTrue(w2.add(e2)) self.assertTrue(w3.add(e1)) @@ -1727,7 +1727,7 @@ def requires(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: self.assertTrue(w1.add(wt)) self.assertFalse(w1.run()) @@ -1765,9 +1765,9 @@ def requires(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: - with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2: - with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1) as w3: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: + with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2: + with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w3: self.assertTrue(w1.add(wt)) self.assertTrue(w2.add(e1)) self.assertTrue(w3.add(s1)) @@ -1818,7 +1818,7 @@ def run(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: self.assertTrue(w1.add(wt)) self.assertFalse(w1.run()) @@ -1866,8 +1866,8 @@ def run(self): wt = TestWrapperTask() - with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1: - with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2: + with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1: + with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2: self.assertTrue(w1.add(wt)) self.assertTrue(w2.add(s1))