diff 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
line wrap: on
line diff
--- a/bin/collector_loadtest.py	Sat May 21 17:06:25 2022 -0700
+++ b/bin/collector_loadtest.py	Sat May 21 19:16:34 2022 -0700
@@ -1,11 +1,16 @@
-import sys
-sys.path.append('bin')
-from run_local import log
+#!bin/python
+import logging
+import time
+from typing import cast
+
+import twisted.internet.reactor
 from light9.collector.collector_client import sendToCollector
-from light9.namespaces import L9, DEV
-from twisted.internet import reactor
-import time
-import logging
+from light9.effect.settings import DeviceSettings
+from light9.namespaces import DEV, L9
+from light9.run_local import log
+from twisted.internet.interfaces import IReactorCore
+
+reactor = cast(IReactorCore, twisted.internet.reactor)
 log.setLevel(logging.DEBUG)
 
 
@@ -20,17 +25,23 @@
         def send(i):
             if i % 100 == 0:
                 log.info('sendToCollector %s', i)
-            d = sendToCollector("http://localhost:999999/", session,
-                                [[DEV["backlight1"], L9["color"], "#ffffff"],
-                                 [DEV["backlight2"], L9["color"], "#ffffff"],
-                                 [DEV["backlight3"], L9["color"], "#ffffff"],
-                                 [DEV["backlight4"], L9["color"], "#ffffff"],
-                                 [DEV["backlight5"], L9["color"], "#ffffff"],
-                                 [DEV["down2"], L9["color"], "#ffffff"],
-                                 [DEV["down3"], L9["color"], "#ffffff"],
-                                 [DEV["down4"], L9["color"], "#ffffff"],
-                                 [DEV["houseSide"], L9["level"], .8],
-                                 [DEV["backlight5"], L9["uv"], 0.011]])
+            d = sendToCollector(
+                "http://localhost:8202/",
+                session,
+                DeviceSettings(
+                    graph=None,
+                    settingsList=[
+                        [DEV["backlight1"], L9["color"], "#ffffff"],  #
+                        [DEV["backlight2"], L9["color"], "#ffffff"],
+                        [DEV["backlight3"], L9["color"], "#ffffff"],
+                        [DEV["backlight4"], L9["color"], "#ffffff"],
+                        [DEV["backlight5"], L9["color"], "#ffffff"],
+                        [DEV["down2"], L9["color"], "#ffffff"],
+                        [DEV["down3"], L9["color"], "#ffffff"],
+                        [DEV["down4"], L9["color"], "#ffffff"],
+                        [DEV["houseSide"], L9["level"], .8],
+                        [DEV["backlight5"], L9["uv"], 0.011]
+                    ]))
 
             def ontime(dt, i=i):
                 times[i] = dt