consul.passthru.tests: Refactor into functions.
For better naming and commentary.
This commit is contained in:
parent
a59a972413
commit
701c0eb489
1 changed files with 41 additions and 23 deletions
|
@ -107,40 +107,58 @@ in {
|
||||||
for m in machines:
|
for m in machines:
|
||||||
m.wait_for_unit("consul.service")
|
m.wait_for_unit("consul.service")
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_healthy_servers():
|
||||||
|
for m in machines:
|
||||||
|
m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
|
||||||
|
|
||||||
|
|
||||||
|
wait_for_healthy_servers()
|
||||||
|
# Also wait for clients to be alive.
|
||||||
for m in machines:
|
for m in machines:
|
||||||
m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
|
m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
|
||||||
|
|
||||||
client1.succeed("consul kv put testkey 42")
|
client1.succeed("consul kv put testkey 42")
|
||||||
client2.succeed("[ $(consul kv get testkey) == 42 ]")
|
client2.succeed("[ $(consul kv get testkey) == 42 ]")
|
||||||
|
|
||||||
# Test that the cluster can tolearate failures of any single server:
|
|
||||||
for server in servers:
|
|
||||||
server.crash()
|
|
||||||
|
|
||||||
# For each client, wait until they have connection again
|
def rolling_reboot_test():
|
||||||
# using `kv get -recurse` before issuing commands.
|
"""
|
||||||
client1.wait_until_succeeds("consul kv get -recurse")
|
Tests that the cluster can tolearate failures of any single server,
|
||||||
client2.wait_until_succeeds("consul kv get -recurse")
|
following the recommended rolling upgrade procedure from
|
||||||
|
https://www.consul.io/docs/upgrading#standard-upgrades
|
||||||
|
"""
|
||||||
|
|
||||||
# Do some consul actions while one server is down.
|
for server in servers:
|
||||||
client1.succeed("consul kv put testkey 43")
|
server.crash()
|
||||||
client2.succeed("[ $(consul kv get testkey) == 43 ]")
|
|
||||||
client2.succeed("consul kv delete testkey")
|
|
||||||
|
|
||||||
# Restart crashed machine.
|
# For each client, wait until they have connection again
|
||||||
server.start()
|
# using `kv get -recurse` before issuing commands.
|
||||||
|
client1.wait_until_succeeds("consul kv get -recurse")
|
||||||
|
client2.wait_until_succeeds("consul kv get -recurse")
|
||||||
|
|
||||||
# Wait for recovery.
|
# Do some consul actions while one server is down.
|
||||||
for m in machines:
|
client1.succeed("consul kv put testkey 43")
|
||||||
m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
|
client2.succeed("[ $(consul kv get testkey) == 43 ]")
|
||||||
|
client2.succeed("consul kv delete testkey")
|
||||||
|
|
||||||
# Wait for client connections.
|
# Restart crashed machine.
|
||||||
client1.wait_until_succeeds("consul kv get -recurse")
|
server.start()
|
||||||
client2.wait_until_succeeds("consul kv get -recurse")
|
|
||||||
|
|
||||||
# Do some consul actions with server back up.
|
# Wait for recovery.
|
||||||
client1.succeed("consul kv put testkey 44")
|
wait_for_healthy_servers()
|
||||||
client2.succeed("[ $(consul kv get testkey) == 44 ]")
|
|
||||||
client2.succeed("consul kv delete testkey")
|
# Wait for client connections.
|
||||||
|
client1.wait_until_succeeds("consul kv get -recurse")
|
||||||
|
client2.wait_until_succeeds("consul kv get -recurse")
|
||||||
|
|
||||||
|
# Do some consul actions with server back up.
|
||||||
|
client1.succeed("consul kv put testkey 44")
|
||||||
|
client2.succeed("[ $(consul kv get testkey) == 44 ]")
|
||||||
|
client2.succeed("consul kv delete testkey")
|
||||||
|
|
||||||
|
|
||||||
|
# Run the tests.
|
||||||
|
rolling_reboot_test()
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue