Increase the user load on runtime in jmeter - java

Is it possible to increase the user load on runtime.For example below is the setup
No of request = 3
No of thread = 5
Ramp-up period = 1
Loop Count = 1
Constant timer in request 2 & 3 of 3000 ms
Q1. is is possible to increase the user load 5-10 while running request 2 after wait?
Please let me know is it possible or not.
Thanks

There are 2 options of "increasing" the load during the test run:
Using Constant Throughput Timer. Despite the word "Constant" it its name the target throughput doesn't have to be constant given you define it using __P() function. Once done you will be able to amend the desired throughput using i.e. __setProperty() function while your test is running. You can even do it outside the test via i.e. Beanshell Server, check out How to Adjust the RPS in Your JMeter Test via the Command Line guide for detailed instructions
In JMeter 3.2 and higher you have possibility to add more threads to the Thread Groups during the runtime using the same "JMeter Properties" approach. Alternative option is using JSR223 Test Elements and the code like:
ctx.getThreadGroup().addNewThread(0, ctx.getEngine())
where ctx stands for JMeterContext class instance, see JavaDoc for referenced methods description.

Related

How to loop Samplers with different intervals in same loop using JMeter

Idea is to loop requests independently, the thread will run for 20 minutes. One Sample will sample every 5 seconds. Other Samples in Simple controller will loop one by one with 10 second delay.
I don't think you will be able to run Samplers with different throughput within the bounds of one Thread Group because JMeter will always wait for the previous Sampler to complete before starting the next one.
The options are in:
Either move /api-common/rest/rmslistterms to a separate Thread Group
Or add the If Controller as a parent for the /api-common/rest/rmslistterms and configure it to run every 2nd iteration, example __jexl3() function you can use would be something like:
${__jexl3(${__jm__Loop Controller__idx} % 2 == 0,)}

redirecting thread group in every x sec in jmeter

I have a requirement where I need to check in If controller of Jmeter whether the elapsed time is greater than x seconds. For that, I created a timer from this post using System.CurrentTimeMillis and put it in a preProcessor
boolean x=true;
long starttime=System.currentTimeMillis();
while(x){
TimeUnit.SECONDS.sleep(1);
long timepassed=System.currentTimeMillis()-starttime;
long secondspassed=timepassed/1000;
if(secondspassed==3)
{
secondspassed=0;
starttime=System.currentTimeMillis();
System.out.println(displayMinutes+"::"+secondspassed);
}
}
But when I am running jmeter test plan, it is looping within timer and logging every 3 secs but not proceeding further with other steps in thread group
I tried to utilize jmeter constant timer but it is pausing the whole thread group for x seconds.
What I would like is that thread group continues with steps inside it and while thread group is making requests , at every x secs thread should set a jmeter property that is checked in If controller ,which will redirect it to a different thread group for token generation and then back again to this thread.
I was trying to create a timer so I can get handle of every x secs and then use that logic to set a property flag .
How can I achieve this in jmeter ?
The easiest is doing this in a separate Thread Group like you did when you "tried to utilize jmeter constant timer"
This Thread Group would consist of:
Constant Timer configured to pause for 3000 milliseconds
JSR223 Sampler with the following code:
SampleResult.setIgnore()
props.put('your-property-name', 'your-property-value')
This way the second Thread Group will set a property each 3 seconds which seems to be exactly what you're looking for.
Under your If Controller you can reset or remove the property so the If Controller would stop firing:
props.remove('your-property-name') // removes the property
props.put('your-property-name', 'some-other-value') // overwrites previous value
In the above code snippets props stands for the instance of Properties class, see Top 8 JMeter Java Classes You Should Be Using with Groovy article to learn more about this and other JMeter API shortcuts, in this props object JMeter keeps all its properties including user-defined ones and properties are global for all Thread Groups (and in fact to the whole JVM)
The above approach didn't work somehow for me. What worked was , in a JSR223 preprocessor , I put this and choose groovy as language
def st = new Date()
use(groovy.time.TimeCategory){
if (props.getProperty("myProp").equals("")){
def et = st+ 10.seconds
props.put("myProp", et.getTime() as String)
}
}
and below in same thread in a IF controller
${_groovy(Long.valueOf(props.get("myProp"))-(new Date().getTime())<=0,)}
and inside IF controller in JSR223 sampler put this
props.put("myProp","")
Then in a Module controller , under IF, you can redirect where you like .
I redirected to an IF controller in a different thread and used Flow Control Action (start next thread loop option)within this IF to redirect back to original thread
and at the start of the test plan mark property as blank like props.put("myProp","")

Is it required to use jp#gc - Throughput Shaping Timer when you are using bzm - Concurrency Thread Group in JMeter?

Good day!
I'm using JMeter to do load testing. It's my first time to use this tool.
I'm confused with some aspect of JMeter.
I will be using bzm - Concurrency Thread Group to simulate traffic to the server. Based on documentation, it must be required to used it along with jp#gc - Throughput Shaping Timer.
However, I'm thinking not to use it. Will there be any problem in my during my test?
bzm - Concurrency Thread Group
Not necessarily.
Concurrency thread group is responsible for starting/stopping threads (you can think of them as of virtual users), like "I want to have 100 concurrent users for 10 minutes"
Throughput shaping timer is responsible for producing throughput, the load in terms of requests per second, like "I want to have 100 requests per second for 10 minutes"
So:
When you operate with "users" you cannot guarantee the number of requests per second which will be generated (see What is the Relationship Between Users and Hits Per Second? for more details if needed)
When you operate with "throughput" you cannot guarantee that the number of users will be sufficient for conducting the required load.
So you don't have to use the Throughput Shaping Timer, you can if you want to reach/maintain the load certain number of requests per second and want to make sure that the number of threads is sufficient as they can be connected via Feedback Function so JMeter will be able to kick off some new threads if the current amount is not sufficient for conducing the required load

JMeter: Stop test if the fail count rate is higher than success

In JMeter,
I'm creating a test plan
In which I need to set a condition
(if the fail count rate is high than success, then I want my test to stop)
Tried :
Auto-stop listener but its useful if we specify error rate %
Tried bean shell post-processor but unsuccessful.
if (!prev.isSuccessful()) {
prev.setStopThread(true);
}
Any ideas much appreciated.! thanks in advance.!
By calling setStopThread you are "asking" JMeter to attempt to stop current thread only, the correct method would be prev.setStopTest(true). Again, if you call this method JMeter will "ask" threads to stop, if you want JMeter terminate in less graceful manner you can go for prev.setStopTestNow(true) method (you can get more failures this way as samplers will be abnormally terminated)
And finally you can call System.exit(1) method which will immediately terminate the whole JVM.
Be aware that since JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for scripting consider migrating from Beanshell to Groovy on next available opportunity.
I think that you can use a test-action sampler, combined with an if-controller and an action stop:
Create an 'If Controller' and set your condition.
Create a 'Test Action' inside where your action is 'stop'.

Enforcing Order of Excution in CloudSim

In cloudSim how can I enforce that cloudlet_2 should start after cloudlet_1 (Speaking of their execution time) ?
I try to do it some thing like this:
cloudlet_2.setExecStartTime(cloudlet_1.getFinishTime());
But this has no effect at run time, both of the cloudlets start at 0.0sec.
Is there any mechanism to enforce cloudlet_2 to not start execution (or even not submitted to the data-center) before cloudlet_1 finish executing ?
this can be by setting start time or by imposing some boolean condition on cloudlet_2, or other trick ... ???
The above requirement comes from the fact that I need some pipeline computation pattern of cloudlets that should execute one after the other (not at once.)
thanks.
Which cloudlet gets executed when is totally depends on your scheduling policy. Here what you need is something like FCFS policy. Actually Cloudsim's default scheduling policy is FCFS.
But as per your requirement "cloudlet_2 should start after cloudlet_1",you need to change the vm/cloudlet scheduling policy. I think what you need is SpaceSharedPolicy for both vm/cloudlet scheduler.Butt not sure.
There are 4 cases for applying different scheduling policy, you can refer Figure No 4 of this.
And about how to change these schedulers in code, you can refer examples which is already there in Cloudsim package.
For instance, if you want to change VM scheduler ,you can change parameter [VmSchedulerTimeShared or VmSchedulerSpaceShared] at line no 188 of above example and for changing cloudlet scheduler you can change parameter [CloudletSchedulerTimeShared() or CloudletSchedulerSpaceShared() ] at line no 104 of above example.

Categories

Resources