Re: [Grinder-development] Initialization of object once per thread
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
|
From: Darren B. <bal...@gm...> - 2015-04-15 15:28:46
|
This is exactly what I am getting along with the script, any insight as to
why the object is not available inside of the __call__ method would be
great.
2015-04-15 15:25:14,768 INFO i-ccfd793a-1 thread-0: starting, will do 1 run
2015-04-15 15:25:14,768 INFO i-ccfd793a-1 : start time is 1429111514767 ms
since Epoch
2015-04-15 15:25:14,851 ERROR i-ccfd793a-1 thread-0 [ run-0 ]: aborted run
- Java exception calling TestRunner
net.grinder.scriptengine.jython.JythonScriptExecutionException: Java
exception calling TestRunner
createAppPerf.createApp(1,100)
File "/home/grinder/./i-ccfd793a-file-store/current/createapp.py", line 13,
in __call__
java.lang.NullPointerException: null
The script:
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from com.myapp.api.controllers.perf.app import CreateAppPerf
createAppTest = Test(1, "Create APP 1 Table 100 Fields")
createAppPerf = CreateAppPerf()
createAppPerf.initialize()
createAppTest.record(createAppPerf.createApp)
class TestRunner:
def __call__(self):
createAppPerf.createApp(1,100)
On Wed, Apr 15, 2015 at 11:05 AM, Darren Ball <bal...@gm...> wrote:
> Hi All,
>
> I recently found the following example online:
>
> If you want one instance for all worker threads in a process, call it
> from the top level of your script.
>
>
> from mypackage import MyTest
>
> myTest = MyTest()
> myTest.init()
>
> class TestRunner:
> def __call__(self):
> # use myTest
>
> I have this exact code with onle the MyTest object being the
> differentiator, and in the call I get a null pointer exception.
>
>
> from net.grinder.script import Test
> from net.grinder.script.Grinder import grinder
> from com.myapp.api.controllers.perf.app import CreateAppPerf
>
> createAppPerf = CreateAppPerf()
> createAppPerf.initialize()
>
> createAppTest = Test(1, "Create APP 1 Table 100 Fields")
> createAppTest.record(createAppPerf.createApp)
>
> class TestRunner:
> def __call__(self):
> createAppPerf.createApp(1,100)
>
>
>
> Moving the createAppPerf.initialize() to the __init__ method works, but
> this is not what I would like. I would to initialize only once.
>
> Any suggestions as how to do this so that createAppPerf is not null in
> __call__?
>
>
> Thanks,
> Darren
>
|