Re: Example script for rmi testing
"Velde, Erik Vande [FGCB]" <[email protected]> Wed, 21 May 2014 09:31:37 +0200
| Newsgroups | gmane.comp.java.grinder.user |
|---|---|
| Message-ID | <39A95799168CBC43A59EF83FE0C7A27B01825175@ldam-msx2.fugro-nl.local> |
Thanks for your answer, Philip. As we are not using EJB’s, I decided to follow the Grinder+JUnit track, as described in http://charlesandrews.me/the-grinder-junit-using-unit-tests-as-load-tests/ The problem is that our RMI test case (attached as BusinessServiceTestSpring.java) is using SpringJUnit4ClassRunner, and I didn’t find a way to make it work from the attached junit.py. Somehow the injected businessService was always null, while in a normal java run (same classpath, but main class org.junit.runner.JUnitCore instead of net.grinder.Grinder) the service was injected correctly by spring. Currently I’m using the BusinessServiceTester.java class in combination with exportBusinessEntities.py. Only one problem left: when I run the exact same test without console (runs = 25) I see a big difference in execution time between a ‘businessServiceTester = BusinessServiceTester(False)’ in the script and a ‘businessServiceTester = BusinessServiceTester(True)’. When I run it from the console (runs = 0) there is no time difference between both scenario’s. I’m too new to ‘the grinder’ to understand the difference in the results, maybe you see the reason for this ??? Kind regards, Fugro GeoConsulting Erik Vande Velde Senior Software Coordinator Telephone: +32 (0)2 77 60 034 / Fax: +32 (0)2 77 60 319 E-mail: [email protected] / Website: www.fugro.be Address: Av. de Broqueville 12, 1150 Brussels, Belgium VAT Nr: BE0418609636 From: Philip Aston [mailto:[email protected]] Sent: 20 May 2014 19:23 To: grinder-use Subject: Re: [Grinder-use] Example script for rmi testing Yes, RMI is no problem for The Grinder. The EJB example (http://grinder.sourceforge.net/g3/script-gallery.html#ejb.py) uses RMI. You simply need to "translate" what a Java client would do into Jython (which often amounts to removing the type declarations, replacing braces with indentation, and getting the import statements right), then add the Spring libraries to the classpath used by the worker process. - Phil On 19/05/14 16:15, Velde, Erik Vande [FGCB] wrote: Hello, According to http://grinder.sourceforge.net/g3/features.html#Standards grinder supports the RMI protocol. Does anyone have an example jython script available to test such communication? I looked in the http://grinder.sourceforge.net/g3/script-gallery.html, but to no avail. We are using spring remoting over RMI for our client/server communication, and I would like to do some load testing of the server. Currently I’m trying to decide if jmeter or The Grinder is the best tool to execute such tests, RMI support is a key criterion for us … Kind regards, Fugro GeoConsulting Erik Vande Velde Senior Software Coordinator ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ grinder-use mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/grinder-use
BusinessServiceTestSpring.java
(application/octet-stream, 2.3 KB) - not displayed
junit.py
(application/octet-stream, 1.5 KB)
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from junit.framework import TestSuite
from junit.framework import TestResult
from com.fugro.gwf.grinder import BusinessServiceTestSpring
from com.fugro.gwf.grinder import BusinessServiceTestNoSpring
from com.fugro.gwf.grinder import BasicTest
log = grinder.logger.info
class TestRunner:
def __call__(self):
# Turn off automatic reporting for the current worker thread.
grinder.statistics.delayReports = 1
# Creates a Test Suite.
# suite = TestSuite(BasicTest().getClass());
suite = TestSuite(BusinessServiceTestNoSpring().getClass());
# Returns the tests as an enumeration.
tests = suite.tests();
# Iterate over the tests.
testNumber = 0
for test in tests:
testNumber += 1
testCase = Test(testNumber, test.getName()).wrap(suite)
testResult = TestResult()
testCase.runTest(test, testResult)
log("errorCount: %d" % testResult.errorCount())
log("failureCount: %d" % testResult.failureCount())
if testResult.errorCount() > 0:
grinder.statistics.forLastTest.success = 0
for error in testResult.errors():
log("error: %s" % error.trace())
elif testResult.failureCount() > 0:
grinder.statistics.forLastTest.success = 0
for failure in testResult.failures():
log("failure: %s" % failure.exceptionMessage())
BusinessServiceTester.java
(application/octet-stream, 2.2 KB) - not displayed
exportBusinessEntities.py
(application/octet-stream, 918 B)
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from junit.framework import TestSuite
from junit.framework import TestResult
from com.fugro.gwf.grinder import BusinessServiceTester
class TestRunner:
def __call__(self):
# Turn off automatic reporting for the current worker thread.
# grinder.statistics.delayReports = 1
test = Test(1, "Business Service Export")
# argument 'True' means that the constructor does the service lookup, and lookup time is not included in results
# 'False' means that the exportBusinessEntities does the lookup, and lookup time is included in results
businessServiceTester = BusinessServiceTester(False)
test.record(businessServiceTester)
businessServiceTester.exportBusinessEntities()
if not businessServiceTester.isOk():
grinder.statistics.forLastTest.success = 0