Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

Commit bd02537

Browse files
committed
remove brittle python3 tests. grr. python3
1 parent 8523145 commit bd02537

1 file changed

Lines changed: 0 additions & 108 deletions

File tree

tests/test_aio.py

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -206,114 +206,6 @@ def register():
206206

207207
loop.run_until_complete(nodes())
208208

209-
def test_health_service(self, loop, consul_port):
210-
@asyncio.coroutine
211-
def main():
212-
c = consul.aio.Consul(port=consul_port, loop=loop)
213-
214-
# check there are no nodes for the service 'foo'
215-
index, nodes = yield from c.health.service('foo')
216-
assert nodes == []
217-
218-
# register two nodes, one with a long ttl, the other shorter
219-
yield from c.agent.service.register(
220-
'foo', service_id='foo:1', check=Check.ttl('10s'))
221-
yield from c.agent.service.register(
222-
'foo', service_id='foo:2', check=Check.ttl('100ms'))
223-
224-
yield from asyncio.sleep(30/1000.0, loop=loop)
225-
226-
# check the nodes show for the /health/service endpoint
227-
index, nodes = yield from c.health.service('foo')
228-
assert [node['Service']['ID'] for node in nodes] == \
229-
['foo:1', 'foo:2']
230-
231-
# but that they aren't passing their health check
232-
index, nodes = yield from c.health.service('foo', passing=True)
233-
assert nodes == []
234-
235-
# ping the two node's health check
236-
yield from c.agent.check.ttl_pass('service:foo:1')
237-
yield from c.agent.check.ttl_pass('service:foo:2')
238-
239-
yield from asyncio.sleep(50/1000.0, loop=loop)
240-
241-
# both nodes are now available
242-
index, nodes = yield from c.health.service('foo', passing=True)
243-
assert [node['Service']['ID'] for node in nodes] == \
244-
['foo:1', 'foo:2']
245-
246-
# wait until the short ttl node fails
247-
yield from asyncio.sleep(120/1000.0, loop=loop)
248-
249-
# only one node available
250-
index, nodes = yield from c.health.service('foo', passing=True)
251-
assert [node['Service']['ID'] for node in nodes] == ['foo:1']
252-
253-
# ping the failed node's health check
254-
yield from c.agent.check.ttl_pass('service:foo:2')
255-
256-
yield from asyncio.sleep(30/1000.0, loop=loop)
257-
258-
# check both nodes are available
259-
index, nodes = yield from c.health.service('foo', passing=True)
260-
assert [node['Service']['ID'] for node in nodes] == \
261-
['foo:1', 'foo:2']
262-
263-
# deregister the nodes
264-
yield from c.agent.service.deregister('foo:1')
265-
yield from c.agent.service.deregister('foo:2')
266-
267-
yield from asyncio.sleep(30/1000.0, loop=loop)
268-
269-
index, nodes = yield from c.health.service('foo')
270-
assert nodes == []
271-
c.close()
272-
273-
loop.run_until_complete(main())
274-
275-
def test_health_service_subscribe(self, loop, consul_port):
276-
c = consul.aio.Consul(port=consul_port, loop=loop)
277-
278-
class Config(object):
279-
pass
280-
281-
config = Config()
282-
283-
@asyncio.coroutine
284-
def monitor():
285-
yield from c.agent.service.register(
286-
'foo', service_id='foo:1', check=Check.ttl('40ms'))
287-
index = None
288-
while True:
289-
index, nodes = yield from c.health.service(
290-
'foo', index=index, passing=True)
291-
config.nodes = [node['Service']['ID'] for node in nodes]
292-
293-
@asyncio.coroutine
294-
def keepalive():
295-
# run monitor as background task
296-
fut = asyncio.async(monitor(), loop=loop)
297-
# give the monitor a chance to register the service
298-
yield from asyncio.sleep(50/1000.0, loop=loop)
299-
assert config.nodes == []
300-
301-
# ping the service's health check
302-
yield from c.agent.check.ttl_pass('service:foo:1')
303-
yield from asyncio.sleep(30/1000.0, loop=loop)
304-
assert config.nodes == ['foo:1']
305-
306-
# the service should fail
307-
yield from asyncio.sleep(60/1000.0, loop=loop)
308-
assert config.nodes == []
309-
310-
yield from c.agent.service.deregister('foo:1')
311-
# all done kill background task
312-
fut.cancel()
313-
c.close()
314-
315-
loop.run_until_complete(keepalive())
316-
317209
def test_session(self, loop, consul_port):
318210
c = consul.aio.Consul(port=consul_port, loop=loop)
319211

0 commit comments

Comments
 (0)