-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
test_monitor.py
45 lines (36 loc) · 936 Bytes
/
test_monitor.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
40
41
42
43
44
45
import pytest
import redis
from django_q import async
from django_q.cluster import Cluster
from django_q.monitor import monitor, Stat, ping_redis, info
@pytest.mark.django_db
def test_monitor():
assert Stat.get(0).sentinel == 0
c = Cluster()
c.start()
stats = monitor(run_once=True)
c.stop()
assert len(stats) > 0
found_c = False
for stat in stats:
if stat.cluster_id == c.pid:
found_c = True
assert stat.uptime() > 0
assert stat.empty_queues() is True
break
assert found_c is True
@pytest.mark.django_db
def test_info():
info()
do_sync()
info()
for _ in range(24):
do_sync()
info()
def do_sync():
async('django_q.tests.tasks.countdown', 1, sync=True, save=True)
@pytest.mark.django_db
def test_ping_redis():
r = redis.StrictRedis(port=6388)
with pytest.raises(Exception):
ping_redis(r)