From 501ec1ff234d4ea1e6709b44251b249f497feddb Mon Sep 17 00:00:00 2001 From: James Kafader Date: Mon, 1 May 2017 13:35:09 -0700 Subject: [PATCH] Adds more unique service tests --- tests/test_svcreg.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_svcreg.py b/tests/test_svcreg.py index 6572df6..bbe7ace 100644 --- a/tests/test_svcreg.py +++ b/tests/test_svcreg.py @@ -60,13 +60,11 @@ def test_unique_service(rr): svcreg.unique_service('example-role', candidate={}) svc01 = { "role": "example-role", - "load": 0.0, "heartbeat_interval": 0.4, "node": "test01.example.com" } svc02 = { "role": "example-role", - "load": 0.0, "heartbeat_interval": 0.4, "node": "test02.example.com" } @@ -76,8 +74,17 @@ def test_unique_service(rr): # try to register svc02. Output should still be svc01. output = svcreg.unique_service('example-role', candidate=svc02) assert output['node'] == svc01['node'] + time.sleep(0.2) + output1 = svcreg.unique_service('example-role', candidate=svc01) + assert output1['last_heartbeat'] > output1['first_heartbeat'] + output2 = svcreg.unique_service('example-role', candidate=svc02) + assert output1['last_heartbeat'] == output2['last_heartbeat'] + time.sleep(0.2) + output3 = svcreg.unique_service('example-role', candidate=svc01) + assert output3['last_heartbeat'] > output1['last_heartbeat'] svcreg.unregister('example-role') + def test_service_registry(rr): svcreg = doublethink.ServiceRegistry(rr) # missing required fields