@BeforeThread Not functining In App

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

@BeforeThread Not functining In App

Chris F.
Hi,
        I have a test that I want to login one time only for each thread.  I've put the login logic into the @BeforeThread method like so:
        @BeforeThread
        public void beforeThread() {
                grinder.statistics.delayReports=true;
                grinder.logger.info("before thread.");
                loadMain()
                loadLogin()
                loadSessionLink()
                loadID()
}

This works fine when running though Eclipse, the test functions exactly as intended.  When I try to run it through the nGrinder web application it seems like these functions are never called as the login isn't completed.   Any clues?

Thanks,
Chris F.
               

               
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeThread Not functining In App

junoyoon
Administrator
Did you check the log? In the log if there are "before thread" log, which means.. that the @BeforeThread logic  is executed.

If you can see this log and still have the problem. it might be caused by the old ngrinder bug.
What version of ngrinder "agent" are you using?
In ngrinder 3.2, it creates only one TestRunner object for all threads per process.
So if you used a member variable in loadMain(), loadLogin() ... method, the member variable value may be overwritten by several threads(which means.. it's not thread safe) and cause some problems.

If you're using ngrinder 3.2 version(especially, agent side), please upgrade it to ngrinder 3.2.3
or wait until next week when 3.3 version is released.
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeThread Not functining In App

Chris F.
I am running version 3.2.3.  I just checked through the logging after adding a bit of messaging to track the process.  I found that I was incorrect it is executing the methods from @BeforeThread it is just not executing them in the order at which they are written.  Is there a way to specify a sequence of operations?

Thanks,
Chris
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeThread Not functining In App

junoyoon
Administrator
The methods will be executing as you write. However if you're running multiple threads per a process, the log from multiple threads will be mixed up(all threads in a process share a single log file) and it will look like that they are not executing as you expected. However, it's not wrong.

I highly recommend you to put grinder.threadNumber in ahead of the log message. it will make log  more clear to find out the real problem.