-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_etcd.py
executable file
·39 lines (35 loc) · 926 Bytes
/
test_etcd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
"""
Test suite for etcd-py
"""
import sys
from etcd import *
if __name__ == '__main__':
if len(sys.argv) > 1:
host = sys.argv[1]
else:
host = "127.0.0.1"
e = Etcd(host)
print e.set("message", "hello world")
print e.set("message", "Hello World!")
print e.get("message")
try:
print e.get("nonexist")
except EtcdError as err:
print err
print e.delete("message")
try:
print e.delete("nonexist")
except EtcdError as err:
print err
print e.set("message", "HELLO WORLD!!", 5)
print e.watch("foo", timeout=2)
print e.watch("message")
e.set("message", "Goodbye, World")
print e.testandset("message", "Goodbye, World", "Hey Wait!")
try:
e.testandset("message", "Goodbye, World", "Try it again")
except EtcdError as err:
print err
print e.machines()
print e.leader()