My environment: JMeter v2.11, Oracle 12, JDK 7
System: 8000 XML submissions / hour, writes to the database, then after some internal processing, status value in DB is updated (indicating the submission/application has been approved). I have some beanshell samplers setup to source values from a csv file to emulate the XML submission and I have JDBC Request to check when the database status attribute has been updated.
The JDBC request is contained within a While Controller at the end of my thread so that my JDBC request executes until the application.status column is updated.
My test runs fine for a single instance (1 loop) but for subsequent loops, the JDBC request is NOT executed. That is, if the loop count is greater than 1, for each subsequent loop, the JDBC request is NOT executed.
My current setup:
Thread Group: No. of Users-->1, Loop Count -->3
-CSV Data Config: Recycle on EOF = TRUE, STOP THREAD ON EOF = FALSE
-Beanshell Samplers: (to create and submit the XML, using csv data)
--While Controller: (${__javaScript("${status_1}" != "6")})
---JDBC Request: select status from application where applicationID = (select max(applicationID) from application); VariableName: status
As I stated above - the thread runs fine for Loop=1, but if Loop>1 is set, then subsequent loops do NOT execute the JDBC request because of it's relationship to the While Controller.
I've tried adding a parent Simple Controller to the While Controller, I've tried using multiple Loop Controllers and setting a parent Loop Controller to the While Controller but nothing I do works, and I just don't know how to proceed.
I have spent 3 days (really! 3 days!) searching the web for a way to get the While Controller included in subsequent loops - I've found only 3 instances of this question ever being asked on forums going back to 2006, but each question was never actually answered.
It even crossed my mind to create 8000 Thread Groups with a loop of 1!!. It would be a nightmare but would in fact get done what I need - but obviously I'd be here til next year setting that up and I suspect JMeter would run out of resource trying to execute all those thread groups.
Can anyone advise as to some alternatives to my approach. I'm starting to believe the While Controller not being included in subsequent loops is expected/standard JMeter functionality.
Perhaps I can use some other controllers to do what I need?
As always, any help, advice, hints, tips are gratefully appreciated.
This is how your test goes:
First loop: status_1 variable is blank, While Controller is being executed
Second loop: status_1 variable value is 6, While Controller is NOT executed as condition is false.
Add a Debug Sampler before your While Controller to see it yourself
The solution is as simple as just adding the next line to one of your Beanshell Samplers:
vars.remove("status_1");
ResponseMessage="variablescleared";
ResponseCode=200;
This line will clear "status_1" value of "6" and your While Controller will be executed on next iteration.
Related
I have the following test plan i Jmeter:
Thread group
User params
Csv DataSource
While controller
Once only controler
http sampler
http sampler
RegEx extractor (Finds the variable that is the condition in the while loop)
If controller
Http sampler
Save response to file
BeanShell Post Processor (Cleans up used variables)
Now, my issue is, when the If controller's condition is met, after the thread is done, it loops as expected.
But, when the If controller's condition is not met, after the thread is done, the run stops, and no loop occurs.
In the thread group settings i have "Loop = 50" and "Action on Error: Start next thread loops"
In the system's log, there are no errors at all.
Any ideas?
If the condition is not met the If Controller's children will not be executed and you will not see them in the jtl results file.
If you add i.e. a Dummy Sampler after the If Controller you will see that the Dummy Sampler will be executed 50x times per each virtual user.
Some more recommendations:
Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting
According to JMeter Scoping Rules your BeanShell Post Processor will be executed after each sampler, I don't know what exactly it is doing but currently it's being executed after each Sampler so might be the case it's cleaning the variable you're using in While or If Controller.
I have a SSIS package with lots of containers and logic. I am running an additional task (which I want to run independently) let's say it acts as an Event Listener. When this separate task is errored, I want to error out the entire package. I thought, it should work by default but to my surprise, it's not:-
I have tried setting both FailPackageOnFailure & FailParentOnFailure properties on both the parent container & the child container but it's not working.
I was about to ask exactly the content of your last comment.
Failure of one piece of a package won't make another, unconnected piece stop executing. Once the executing piece is done, the package will fail, but Sequence Container 3 has no way to know what's happening in Sequence Container 2.
Which, honestly, is what we want. If Sequence Container 3 is doing DML, you could leave your data in an unfortunate state if an unrelated failure elsewhere in the package suddenly made everything come to a screeching halt.
If you don't want Sequence Container 3 to run if Sequence Container 2 fails, then just run a precedence constraint from Sequence Container 2 to Sequence Container 3, #3 won't execute until #2 succeeds and the Execute SQL Task succeeds.
I completely agree with Eric's answer. Let me explain to you why raising a flag on error won't work.
I redesign the package so it includes the flag check.
Let's say we have a success flag as user variable which is by default False.
Now we set this variable as True at the end of sequence 2 execution marking the success of all the other tasks in that sequence.
The second part is put into a for loop which runs only once(if at all). It checks if the success variable is true and only then run the inner tasks. It looks like below:
The problem is, the success variable check at the start of the for loop will always have the inital value which is false(because it runs in parallel with seq 2 and doesn't wait till seq 2 ends). Hence the second part is never executed. Now change the initial value of success variable to true and run the package again. Play by disabling the error prone tasks and run the package. You will understand how it works.
In my anylogic Project, I want to terminate my execution and run the simulation for N times. in each of the simulation I store my output in an excel file which depends on the run count.
Instead of stopping and running by my click, I want to do it automatically. How can I do that?
I try to use an event and write by while loop (myparm<=N) and in loop I wrote getEngine().run, but it didn't work!
if it is possible please help me.
Thanks
Below is an overview of a methodology of how you can do it using the existing simulation framework used by AnyLogic
You need to make use of the simulation setup in order to run multiple runs of the model and save the output. My suggested setup will be the following:
Have a button on your Simulation Experiment page (The first page you see when running the model) that you will use to start off the multiple model runs. In here you set the engine to not run in real time mode by using
getEngine().setRealTimeMode(false);
you might also want to set the initial seed and some other model parameters that you might also want to change and perhaps save after model execution. When you have setup the model the way you want use run() to start running the model.
Now under the Simulation Experiment setup page under the 'Java actions' section you need to specify what the model must do after it finished running the model. In the 'After simulation run' section write some code to save the data from the model into your Excel files. To access variables and objects from the model use root, e.g.
saveSomeData(root.myDataset);
where saveSomeData is a function on the Simulation page to save my data set found on the model, called myDataset, to an Excel file. It would be great to also save the seed and the specific parameters, if you changed any, to the Excel file for future reference.
Once you have saved the data output from the model you can specify a new seed and perhaps change parameters again and then call the run() again to run the model for another iteration. When the model has finished running it will again call the 'After simulation run' code here, so do put a stop condition otherwise it will just continue running one iteration after the other. You can access the number of model runs by using
getEngine().getRunCount()
Also, your model needs to have some stop condition, otherwise once it starts running it will never stop. You can specify this in the Simulation Experiment page under the 'Model time' section or programatically in your model using
finishSimulation();
In order to run the model cyclically, please use the following code in the Action field of a timeout triggered event or On destroy field of the top-level agent:
new Thread(){
public void run(){
// stops the model
getExperiment().stop();
try {
// delay
this.sleep(1000);
} catch(Exception e) {};
// runs it again
((Simulation) getExperiment()).button.action();
}
}.start();
The model results should be written to the Excel file before executing this code.
As Jaco-Ben suggested, you can specify getEngine().getRunCount() as condition of restarting the Simulation experiment.
My current environment: JMeter v2.11, remote Oracle 12, JDK 7
I have a recorded script for 200 users to login to a web application within 1 thread group but I need to keep this going for several hours so I need to keep the 200 user's sessions live for several hours and if there is no interaction, the http sessions will expire, so I decided to use a Loop Controller to simply resubmit the same http request every 14.5minutes, once the user's session has been established by logging in.
Because I need to stop the script running after a certain duration I specified the Duration on the Thread Group, but I noticed that if the http requests were before the Loop Controller in the script occurred when the Duration value was reached, the script stopped, however - if the http requests that were being exercised when the 'Duration' was reached were in the Loop Controller - the Loop Controller overrode those Duration settings and the script ran until the number of loops had completed.
I found the following posts https://sqa.stackexchange.com/questions/8378/how-to-run-jmeter-test-plan-for-specified-amount-of-time and
https://sqa.stackexchange.com/questions/1660/how-to-stop-thread-in-jmeter
and followed the instructions to create a second separate Thread Group placing a Test Action with a Constant Timer child which will stop ALL Threads.
Again (as when specifying the 'Duration' via the Thread Group property value) the Stop Test Action works when stopping the script in the other Thread Group if the http requests being executed are not in the Loop Controller - If they are, the Stop Test Action does not work - i.e. the Loop Controller overrides the Stop Test Action's Constant Timer Duration value and runs until the Loop Count has completed.
My Workings below:
Thread Group 1 : No. of Threads-->200, Ramp Up-->1, Loop Count-->Forever, Duration-->900 seconds
-HTTP Request Defaults
-Recording Controller
--HTTP Request (GET) - Login Page Launched
--HTTP Request (POST) - Login Details submitted
--HTTP Request (POST) - Home Page displayed
---Loop Controller : Loop Count --> 2
----HTTP Request (POST) - Relaunch Home page
-----Constant Timer : Thread Delay --> 870000 ms
----HTTP Request (POST) - Select 'Yes' to View Home Page Again
Thread Group 2 : No. of Threads-->1, Ramp Up-->1, Loop Count-->Forever, Duration-->900 seconds
-Test Action: Stop, All Threads
--Constant Timer --> 900000 ms
note: I used 15minutes/900 seconds/900000 milliseconds to test my boundaries above.
Can anyone provide any insight into how I can stop the thread running after a certain duration despite the loop controller settings? That is - can anyone describe a way to override the loop controllers settings to stop the thread after a certain Duration, rather than it stopping once the Loop Count has been reached?
Many Thanks!
I have identified what was causing my problem. The Loop Controller value - it needs to be set 'Forever' so that it doesn't override the 'Duration' settings in either the parent Thread Group or the separate Stop Test Action (with child Constant Timer) Thread Group.
Once the Loop Controller is set 'Forever' it appears JMeter then runs up to the 'Duration' settings.
Thanks
Apologies if this request is similar to others - I am new to JMeter and have searched for other relevants posts but couldn't find anything - or maybe I just didn't understand them!
I'm performance testing a system with a web based application. The front end system will be processing records submitted into the system via MQ - the front end allows the user to pick up a record from the queue, validate some detail, make changes and submit the changes.
There will be 20 users using the front end to do this message validation, update and submission.
Each user is expected to need 30 seconds to pick a message from queue, make changes and resubmit - so we are expecting 1 user to process 120 records/hour, so 20 users will be expected to process 2400 records/hour
The picking up the record off the queue, changing it and submitting the changes will be done via 3 individual web pages.
SO - think time across the 3 pages has been defined as 24 seconds (leaving 6 of the 30 second limit for rendering, server responses, db calls etc.)
However I don't know how to specify this within JMeter. From my reading I can see that I can add a Timer in as a parent to a sampler and I assume I can add a Timer in as a parent of the Recording Controller? - but I need to be able to specify that the 24 second think time is spread across those 3 different pages.
I read a post elsewhere suggesting that if I record using the proxy after adding the Gaussian Random Timer in as a child of the Test Plan (parent to everything else) then the http proxy will record the think time as a ${T} variable in the Gaussian Random Timer - I tried this and this didn't work (also I don't want to rely on this - I'd like to be able to understand and make changes to think time properly rather than relying on JMETER to do it for me.)
To reiterate - 20 users, 30 seconds for 1 user to complete a transaction, TT defined as 24 seconds - I am struggling what Timer to use, where to put it so that the think-time is spread across the samplers that equate to the GETS associated with the 3 pages the user will navigate through.
Apologies for the lengthy post - I just wanted to be clear and concise.
Many thanks in advance,
As per JMeter Timers documentation
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Test Action Sampler.
Now regarding "what timer to use"
There are 2 scenarios:
Virtual-User-oriented scenario - when you try to simulate N users working together
Goal-Oriented-scenario - when you try to produce N hits per second load.
In case of scenario 1 even Constant Timer can be quite enough, besides it will provide repeatability of results. See above quote for information on where to put your timer(s)
In case of scenario 2 you'll need Constant Throughput Timer. If 20 users process 2400 records per hour and each record assumes 3 web page calls, it means that 7200 requests will be made in one hour which in its turn stands for 120 requests per minute (this is what you should enter into the timer's "throughput" area) or 2 requests per second.