Skip to content

Commit 0151244

Browse files
committed
cleanup watch util failover test
1 parent 681d39c commit 0151244

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/test_watch_util.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def test_watcher(client, etcd_cluster):
113113
@pytest.mark.skipif(NO_DOCKER_SERVICE, reason="no docker service available")
114114
def test_watcher_cluster(client, etcd_cluster):
115115
w = client.Watcher(all=True, progress_notify=True, prev_kv=True)
116+
client.timeout = 2
116117
w.set_default_timeout(2)
117118
put_list = []
118119
w.onEvent(EventType.PUT, lambda e: put_list.append(e))
@@ -130,21 +131,21 @@ def test_watcher_cluster(client, etcd_cluster):
130131

131132
assert w.watching
132133
assert w._thread.is_alive
134+
assert client.current_endpoint == client.endpoints[0]
133135

134-
for i in range(6):
136+
# hard rolling restart with write and calls to status after killing each node
137+
for i in range(3):
135138
c = etcd_cluster.containers[i%3]
136-
etcd_cluster.etcdctl("put key%s val" % i)
137139
c.kill()
140+
etcd_cluster.etcdctl("put key%s val" % i)
138141
while not len(put_list) == i+1:
139142
time.sleep(0.5)
143+
client.status()
140144
c.restart()
145+
assert w.watching
141146
etcd_cluster.wait_ready()
142-
# refresh docker dynamically allocated endpoints
143-
client.endpoints = etcd_cluster.get_endpoints()
144147
w.stop()
145148

146149
assert w._resp.raw.closed
147150
# ensure all events have been reported
148-
assert len(put_list) == 6
149-
# doing a rolling restart twice must generate at least 2 errors
150-
assert len(w.errors) >= 2
151+
assert len(put_list) == 3

0 commit comments

Comments
 (0)