comparison bin/collector_loadtest.py @ 1493:4294ed82ee16

move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though Ignore-this: 9f32a0cb0ba3c1b29ccbe7330ed15bf4
author drewp@bigasterisk.com
date Mon, 13 Jun 2016 20:04:11 +0000
parents
children 8e0e5b3db301
comparison
equal deleted inserted replaced
1492:ce97f298bfb8 1493:4294ed82ee16
1 import sys
2 sys.path.append('bin')
3 from run_local import log
4 from light9.effect.sequencer import sendToCollector, sendToCollectorZmq
5 from light9.namespaces import L9, DEV
6 from twisted.internet import reactor
7 import time
8 import logging
9 log.setLevel(logging.DEBUG)
10 def loadTest():
11 print "scheduling loadtest"
12 n = 2500
13 times = [None] * n
14 session = "loadtest%s" % time.time()
15 offset = 0
16 for i in range(n):
17 def send(i):
18 if i % 100 == 0:
19 log.info('sendToCollector %s', i)
20 d = sendToCollector("http://localhost:999999/", session,
21 [[DEV["backlight1"], L9["color"], "#ffffff"],
22 [DEV["backlight2"], L9["color"], "#ffffff"],
23 [DEV["backlight3"], L9["color"], "#ffffff"],
24 [DEV["backlight4"], L9["color"], "#ffffff"],
25 [DEV["backlight5"], L9["color"], "#ffffff"],
26 [DEV["down2"], L9["color"], "#ffffff"],
27 [DEV["down3"], L9["color"], "#ffffff"],
28 [DEV["down4"], L9["color"], "#ffffff"],
29 [DEV["houseSide"], L9["level"], .8],
30 [DEV["backlight5"], L9["uv"], 0.011]])
31 def ontime(dt, i=i):
32 times[i] = dt
33 d.addCallback(ontime)
34 reactor.callLater(offset, send, i)
35 offset += .002
36
37 def done():
38 print "loadtest done"
39 with open('/tmp/times', 'w') as f:
40 f.write(''.join('%s\n' % t for t in times))
41 reactor.stop()
42 reactor.callLater(offset+.5, done)
43 reactor.run()
44
45 if __name__ == '__main__':
46 loadTest()