feat(main): add bounded randomized check-interval jitter across nodes
This commit is contained in:
1 parent
b34ac69ac1
commit
d2fdd5be44
7 files changed
+72
-3
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from main import compute_sleep_interval
|
||||
|
||||
|
||||
class MainSleepIntervalTests(unittest.TestCase):
|
||||
@patch("main.random.uniform", return_value=0.0)
|
||||
def test_compute_sleep_interval_no_jitter(self, _uniform):
|
||||
self.assertEqual(600.0, compute_sleep_interval(600, 0.0))
|
||||
|
||||
@patch("main.random.uniform", return_value=0.10)
|
||||
def test_compute_sleep_interval_applies_positive_jitter(self, _uniform):
|
||||
self.assertEqual(660.0, compute_sleep_interval(600, 0.10))
|
||||
|
||||
@patch("main.random.uniform", return_value=-0.90)
|
||||
def test_compute_sleep_interval_enforces_minimum_sleep(self, _uniform):
|
||||
self.assertEqual(1.0, compute_sleep_interval(1, 0.90))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user