Reputation: 1237
I have a complex scenario that I want to build in Jmeter test plan. I have a test plan with some tests that I want to start run in the same time. I created 3 thread groups, the issue is that I want thread group 2 + 3 will hold in step 2 until thread group 1 (external processes) is finished. (the external process is to run jenkins job that uses data that created in steps 1 + 2 in my system.If the jenkins not finished, all the next steps 3 - 100 will fail) the complexity is that I want all of the threads will start running together, thread groups (= tests) 2 + 3 will be in hold after step 2, and wait that the external process of thread group 1 is finished and than continue the run. Is this scenario can be done in Jmeter? without using delay in thread 2 + 3? See the attached pic of what I want to create
** steps 1 + 2 in test2 + 3 must run before the external process and step 3 must run after the external process
[][test plan]
[][full test plan - step 3 in test 2+3 must run after external precess]
Upvotes: 1
Views: 1501
Reputation: 1237
After struggling the solution I found with sunny help is using while loop + system properties.
I created in first thread group flag and started it with 0.
flag is system variable so I use props.put("flag",flag) command.
In the second thread group I used while loop with ${__javaScript(props.get("_flag") == 0)}
as condition.
I used Test Action sampler, and put it inside the while loop, with action Pause and duration 5000 milliseconds - that the loop will check the flag every 5 seconds.
after the jobs done I put in the system variable flag = 1. and the loop is stooped
Upvotes: 0
Reputation: 1999
Please check the below plan and i think it should work:-
Thread Group 1:- Having test action for 5 sec wait before executing external process(Just for simulation). Then Regular expression to fetch a value from the response. In my sample it is "5" in the dummy sampler (External Process) response. Then I have use JSR223 post process to set it as a property.
Thread Group2 & 3:- Used While Controller to validate the property set in thread group 1 and if not then put a wait for 1 sec. You can use some other sampler like JSSR223 for logging or dummy if you dont want "Test Action" for wait below while controller.
In this way, thread group will pause at while and continue once get the property value.
Below attempt for a flag approach:-
Pre-processor to reset value to something else for while loop controlling.
Based on the last sample result, set a property using JSR223.
This is what is used in while loop.
Upvotes: 1