Restarting a user thread conditionally in JMeter
up vote
0
down vote
favorite
I know that I can stop a thread conditionally in JMeter.
In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.
I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?
jmeter
add a comment |
up vote
0
down vote
favorite
I know that I can stop a thread conditionally in JMeter.
In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.
I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?
jmeter
1
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I know that I can stop a thread conditionally in JMeter.
In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.
I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?
jmeter
I know that I can stop a thread conditionally in JMeter.
In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.
I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?
jmeter
jmeter
asked 18 hours ago
ArturS
46110
46110
1
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago
add a comment |
1
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago
1
1
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Without scripting, you can add Flow Control Action (was: Test Action )
Choose Target: Current Thread
and Action: Start Next Thread Loop
It'll skip "damaged" thread and continue to the next thread
add a comment |
up vote
0
down vote
For further researchers:
The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)
if(statVar.equals("NOK")){ . //checking the condition
SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
}
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Without scripting, you can add Flow Control Action (was: Test Action )
Choose Target: Current Thread
and Action: Start Next Thread Loop
It'll skip "damaged" thread and continue to the next thread
add a comment |
up vote
1
down vote
Without scripting, you can add Flow Control Action (was: Test Action )
Choose Target: Current Thread
and Action: Start Next Thread Loop
It'll skip "damaged" thread and continue to the next thread
add a comment |
up vote
1
down vote
up vote
1
down vote
Without scripting, you can add Flow Control Action (was: Test Action )
Choose Target: Current Thread
and Action: Start Next Thread Loop
It'll skip "damaged" thread and continue to the next thread
Without scripting, you can add Flow Control Action (was: Test Action )
Choose Target: Current Thread
and Action: Start Next Thread Loop
It'll skip "damaged" thread and continue to the next thread
answered 13 hours ago
user7294900
17.9k93056
17.9k93056
add a comment |
add a comment |
up vote
0
down vote
For further researchers:
The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)
if(statVar.equals("NOK")){ . //checking the condition
SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
}
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
add a comment |
up vote
0
down vote
For further researchers:
The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)
if(statVar.equals("NOK")){ . //checking the condition
SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
}
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
For further researchers:
The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)
if(statVar.equals("NOK")){ . //checking the condition
SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
}
For further researchers:
The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)
if(statVar.equals("NOK")){ . //checking the condition
SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
}
edited 13 hours ago
answered 15 hours ago
ArturS
46110
46110
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
add a comment |
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
1
1
Next iteration isn't equal to restart
– user7294900
14 hours ago
Next iteration isn't equal to restart
– user7294900
14 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
You're right it's more like moving to another iteration in terms of skipping current thread.
– ArturS
13 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371798%2frestarting-a-user-thread-conditionally-in-jmeter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago
I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago