mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Adds more unique service tests
This commit is contained in:
parent
2815983e40
commit
501ec1ff23
@ -60,13 +60,11 @@ def test_unique_service(rr):
|
|||||||
svcreg.unique_service('example-role', candidate={})
|
svcreg.unique_service('example-role', candidate={})
|
||||||
svc01 = {
|
svc01 = {
|
||||||
"role": "example-role",
|
"role": "example-role",
|
||||||
"load": 0.0,
|
|
||||||
"heartbeat_interval": 0.4,
|
"heartbeat_interval": 0.4,
|
||||||
"node": "test01.example.com"
|
"node": "test01.example.com"
|
||||||
}
|
}
|
||||||
svc02 = {
|
svc02 = {
|
||||||
"role": "example-role",
|
"role": "example-role",
|
||||||
"load": 0.0,
|
|
||||||
"heartbeat_interval": 0.4,
|
"heartbeat_interval": 0.4,
|
||||||
"node": "test02.example.com"
|
"node": "test02.example.com"
|
||||||
}
|
}
|
||||||
@ -76,8 +74,17 @@ def test_unique_service(rr):
|
|||||||
# try to register svc02. Output should still be svc01.
|
# try to register svc02. Output should still be svc01.
|
||||||
output = svcreg.unique_service('example-role', candidate=svc02)
|
output = svcreg.unique_service('example-role', candidate=svc02)
|
||||||
assert output['node'] == svc01['node']
|
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')
|
svcreg.unregister('example-role')
|
||||||
|
|
||||||
|
|
||||||
def test_service_registry(rr):
|
def test_service_registry(rr):
|
||||||
svcreg = doublethink.ServiceRegistry(rr)
|
svcreg = doublethink.ServiceRegistry(rr)
|
||||||
# missing required fields
|
# missing required fields
|
||||||
|
Loading…
x
Reference in New Issue
Block a user