Beginner help on running my own Java classes for tests
Niklas Modin <[email protected]> Fri, 27 Mar 2015 10:56:44 +0100
| Newsgroups | gmane.comp.java.grinder.user |
|---|---|
| Message-ID | <CAOMwLxggxPbdaycz65WmzqjOxokc3n4a4QvsoG57kimyntYwvw@mail.gmail.com> |
Hi guys, I've just started evaluation grinder for some web socket related tests, and thus need to run some java classes I've built to connect and send the web socket traffic. I used this tutorial as base for the stuff I've made so far: http://www.cubrid.org/wiki_ngrinder/entry/using-ngrinder-to-perform-load-test-for-a-socket-io-app I take it ngrinder is a fork of grinder but the principles should be the same I assume I've created a python script and a java class for testing and you can check them out in the attachments. The java class is built and packaged into a jar, which I then placed in the grinder-3.11/lib folder. I also updated the properties file to point to my python script. My console and agents start fine, but when I run the tests I get a failure in the .py script which can't find my class (or rather the package/module test). Here's the message I get: 015-03-27 10:34:33,185 ERROR nmodin-mini.local-0: aborting process - Jython exception, <type 'exceptions.ImportError'>: No module named test [initialising test script] net.grinder.scriptengine.jython.JythonScriptExecutionException: <type 'exceptions.ImportError'>: No module named test from test import WebSocketClient File "/Users/nmodin/dev/tools/grinder-3.11/./nmodin-mini.local-file-store/current/websocket.py", line 4, in <module> 2015-03-27 10:34:33,202 INFO agent: finished, waiting for console signal I can't tell if the jar isn't picked up properly, if my jar isn't kosher or if there are any other reasons (config, paths, etc) for this. Any pointers on what I'm doing wrong here ? Any awesome tutorials on how to add your own java classes and have them being called from the scripts ? Let me know if you need more info. Cheers, Niklas ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ grinder-use mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/grinder-use
WebSocketClient.java
(application/octet-stream, 2.3 KB) - not displayed
websocket.py
(text/x-python-script, 1.1 KB)
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from test import WebSocketClient
test1 = Test(1, "testWebsocket")
class TestRunner:
def testWebsocket(self):
# connect
self.client.connectWebSocket("ws://10.161.159.209:8081")
# send message
user = "Thread-%s" % grinder.threadNumber
msg = "test message<%s>." % user
grinder.logger.info("msg:" + msg)
self.client.sendMessage("user : " + msg)
# close
respMsg = self.client.closeWebSocket()
return respMsg
def __init__(self):
grinder.statistics.delayReports=True
#init socket io
#create client object in thread init function. Then every thread will use its own socket.io connection.
self.client = WebSocketClient()
# test method
def __call__(self):
resp = self.testWebsocket()
if "closeWebSocket Ok" in resp :
grinder.statistics.forLastTest.success = 1
else :
grinder.statistics.forLastTest.success = 0
test1.record(TestRunner.testWebsocket)