-
-
Save NotoriousBIT/6ff6edcb5b9b4d2fe5e035a633a534e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Thread = Java.type("java.lang.Thread"); | |
| var System = Java.type("java.lang.System"); | |
| var String = Java.type("java.lang.String"); | |
| var topic = "service/ping"; | |
| function execute(action) { | |
| out("Test Script: " + action.getName()); | |
| for (var i = 0; i < 1000; i++) { | |
| randomTimeSeriesPing(); | |
| Thread.sleep(2000); | |
| } | |
| action.setExitCode(0); | |
| action.setResultText("done."); | |
| out("Test Script: Done"); | |
| return action; | |
| } | |
| function randomTimeSeriesPing() { | |
| var millis = System.currentTimeMillis(); | |
| out("time published: " + millis); | |
| var message = String.format("{ \"timestamp\": %d, \"value\": %f }", millis, Math.random()*100); | |
| mqttManager.publish(topic, message); | |
| } | |
| function out(message){ | |
| output.print(message); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment