comparison bin/collector_loadtest.py @ 2070:2951a690f1ba

collector takes requests from bin/collector_loadtest.py
author drewp@bigasterisk.com
date Sat, 21 May 2022 19:16:34 -0700
parents 3c523c71da29
children d5f1cc9615af
comparison
equal deleted inserted replaced
2069:d678c2757cd4 2070:2951a690f1ba
1 import sys 1 #!bin/python
2 sys.path.append('bin') 2 import logging
3 from run_local import log 3 import time
4 from typing import cast
5
6 import twisted.internet.reactor
4 from light9.collector.collector_client import sendToCollector 7 from light9.collector.collector_client import sendToCollector
5 from light9.namespaces import L9, DEV 8 from light9.effect.settings import DeviceSettings
6 from twisted.internet import reactor 9 from light9.namespaces import DEV, L9
7 import time 10 from light9.run_local import log
8 import logging 11 from twisted.internet.interfaces import IReactorCore
12
13 reactor = cast(IReactorCore, twisted.internet.reactor)
9 log.setLevel(logging.DEBUG) 14 log.setLevel(logging.DEBUG)
10 15
11 16
12 def loadTest(): 17 def loadTest():
13 print("scheduling loadtest") 18 print("scheduling loadtest")
18 for i in range(n): 23 for i in range(n):
19 24
20 def send(i): 25 def send(i):
21 if i % 100 == 0: 26 if i % 100 == 0:
22 log.info('sendToCollector %s', i) 27 log.info('sendToCollector %s', i)
23 d = sendToCollector("http://localhost:999999/", session, 28 d = sendToCollector(
24 [[DEV["backlight1"], L9["color"], "#ffffff"], 29 "http://localhost:8202/",
25 [DEV["backlight2"], L9["color"], "#ffffff"], 30 session,
26 [DEV["backlight3"], L9["color"], "#ffffff"], 31 DeviceSettings(
27 [DEV["backlight4"], L9["color"], "#ffffff"], 32 graph=None,
28 [DEV["backlight5"], L9["color"], "#ffffff"], 33 settingsList=[
29 [DEV["down2"], L9["color"], "#ffffff"], 34 [DEV["backlight1"], L9["color"], "#ffffff"], #
30 [DEV["down3"], L9["color"], "#ffffff"], 35 [DEV["backlight2"], L9["color"], "#ffffff"],
31 [DEV["down4"], L9["color"], "#ffffff"], 36 [DEV["backlight3"], L9["color"], "#ffffff"],
32 [DEV["houseSide"], L9["level"], .8], 37 [DEV["backlight4"], L9["color"], "#ffffff"],
33 [DEV["backlight5"], L9["uv"], 0.011]]) 38 [DEV["backlight5"], L9["color"], "#ffffff"],
39 [DEV["down2"], L9["color"], "#ffffff"],
40 [DEV["down3"], L9["color"], "#ffffff"],
41 [DEV["down4"], L9["color"], "#ffffff"],
42 [DEV["houseSide"], L9["level"], .8],
43 [DEV["backlight5"], L9["uv"], 0.011]
44 ]))
34 45
35 def ontime(dt, i=i): 46 def ontime(dt, i=i):
36 times[i] = dt 47 times[i] = dt
37 48
38 d.addCallback(ontime) 49 d.addCallback(ontime)