Groovy script not executing sequentially with multiple threads in SOAPUI loadtest - multithreading

I need to generate a new sequence number in SOAPUI request as a parameter while executing load test. I wrote a groovy script for that and added it as a test step.
But problem arises when I set number of Threads more than one. In that case, a new sequence number doesn't get generated for every request since multiple threads are executing and same sequence number gets repeated in multiple request.
Can somebody suggest any solution or workaround to deal with this situation.
P.S. I do not have SOAPUI PRO so that I can use DataGen.

If you just want a unique number in SOAP request parameter, everytime it runs, use this directly inside parameter.
${=((long) Math.floor(Math.random() * 90000000L) + 10000000L)}

Related

Handling Multithreading in XML files for running testcases in parallel

I'm new with multithreading, here is my problem statement,
I have an xml file (TestCase.xml) where each tag resembles a test case something like below,
TestCase.xml
In turn, each main tag has a child-tag that links to another xml(TestStep.xml) which dictates the steps of the test case, it’s TS in the above example.
TestStep.xml
The execution always starts from the TestCase.xml based on the id provided. With this overview, I have 100 test cases in my suite & I want to execute them in parallel, i.e. execute at least 5-6 test cases at the same time. I’m not able to use external plug-ins like Testng, Junit, BDD or mavensurefire etc. After a lot of R&D we have ended up with Multithreading. I would need assistance on how to implement the same.

Execute SoapUI test on multi-threads

I have a SoapUI test which uses an input file to read lines as input of requests. So there is a loop which reads data and execute request and write output to file. Response times are too long, so processing of this file should be done asynchronously, but I am not sure, how SoapUI can handle this. There is file attachment in SOAP requests, which is not handled by current version of JMeter.
As per the SoapUI's documentation below, both test cases or test suites can be executed in Parallel mode.
In the case of TestSuites and TestCases these can be executed either in sequence or parallell, as configured with the corresponding toolbar buttons.
In the above image, first one in the marked image stands for sequential execution and the second one (with multiple parallel arrows) stands for Parallel execution mode.
User can select either of the one before executing the tests.
Hope this helps.
Note that SOAPUI does not allows test steps to be executed in parallel. If you need any custom execution i.e., same test case and steps to be executed in Parallel, here is sample project done for that. It can be used as reference and apply it to your case.
I understood this question as requiring the ability to call a service asynchronously due to the time it takes to process. So, by this, I mean SoapUI makes a request to a web service and instead of waiting for it, it carries on. At some point later, SoapUI receives the response.
SoapUI can handle this, I haven't tried it myself, but when reading some guides recently, I noticed it can be done.
See....
Blog Guide
SoapUI Forum
In short, it involves setting up a mock service to receive the response, which can then be validated.

Properties don't take effect until second execution

I'm running scripts that require a different thread for each user account I pull from a database. So the script starts by running a JDBC processor to get all the accounts and store them (using the "Variable Names" field) in "accounts". Then I run a BeanShell PreProcessor to convert the variable "accounts_#" to a property:
props.put("p_accounts_#",vars.get("accounts_#"));
Then, I have a thread group start. Under "Number of Threads (users)", I have
${__P(p_accounts_#)}
The FIRST time I run this script (after launching jMeter), I only get a SINGLE thread. Every subsequent time I run it, it runs for all accounts.
It seems like for some reason, the property is not being saved until the end of the first execution. This is a very big problem as when jMeter is launched without the UI, it only does a single thread every time.
Am I setting the property incorrectly? I also tried it with a Beanshell Assertion with the same result.
Just as a test, I created a new test with the bare minimum I needed to reproduce this. Here's the script (images): http://imgur.com/a/WB5J2
It's a Beanshell PreProcessor with "props.put("accounts","12");"
Then a Thread group using "${__P(accounts)}" as the Number of Threads
Then inside that thread group is a Debug Sampler outputting the JMeter properties.
At the end is a View Results Tree.
When I run it the first time, there's only one output: "Thread 1 Running".
When I run it again, there's 12 outputs, "Tread 1 Running", "Thread 2 running", etc.
I can see that for both Debug Samplers (for the first run and second run), the "Accounts" property is set to 12. But the Thread Group needed to execute TWICE before it would work.
Any ideas?
This can be solved by adding another ThreadGroup called a 'setUp ThreadGroup' to contain the setup portion. If you put all of your staging steps into this type of threadgroup, it will run prior to any other threadgroups. You can then have your preprocessor, or move the logic to a beanshell sampler if you'd like, and set the property from there.

JMeter Testcases work only if they run in a single thread

I am currently trying to set up JMeter-load-tests for a JSF application. Everything is fine and I get the correct result if I use the standard "1 thread 1 repeat" - configuration. It also works with as many repetitions as I want, as long as it's a single thread.
As soon as I change the number of threads, for example using 4 threads at the same time, I get ViewExpiredException's and stuff like that. Feels like the viewstate gets lost somewhere, but I am unable to work out what it is since it works fine in a single thread. This does not happen with every request, some seem to work fine.
Scenario #1: A single thread and a any amount of repetitions - It works fine
Scenario #2: More than a single thread and any amount of repetitions - The server throws a ViewExpiredException on some (no pattern visible) requests.
Any tips? Google couldn't help. Thanks in advance.
Edit: I forgot to add: The viewstate seems to get sent as expected. There is never the default viewstate.
JSF applications are easy to load test if you have understood the basics of dynamic parameter correlations. Have you properly correlated the following dynamic parameters:
javax.faces.ViewState
I suggest to use the following possible regular expressions: ($1$ template)
\sname\s*?=\s*?"javax\.faces\.ViewState"[^^]*?\svalue\s*?=\s*?"(.*?)"[^^]*?>
And:
<update id="javax\.faces\.ViewState"><!\[CDATA\[(.*?)\]\]>
You should extract those values from the responses, and reinject them into subsequent requests. There parameters are dynamically generated on each request.
With JMeter, it really hurts to perform correlation because they have to be done manually each time you record again you script. We managed to make this task a lot easier by implementing Auto Correlation Rules on top of JMeter.

How to run parallel fork as single thread in perl?

I was trying to check response messages written in perl which takes requests through Amazon API and returns responses..How to run parallel fork as single thread in perl?. I'm using LWP::UserAgent module and I want to debug HTTP requests.
As a word of warning - threads and forks are different things in perl. Very different.
However the long and short of it is - you can't, at least not trivially - a fork is a separate process. It actually happens when you run -any- external command in perl, it's just by default perl sits and waits for that command to finish and return output.
However if you've got access to the code, you can amend it to run single threaded - sometimes that's as simple as reducing the paralleism with a config parameter. (In fact quite often - debugging parallel code is a much more complicated task than sequential, so getting it working before running parallel is really important).
You might be able to embed a waitpid into your primary code so you've only got one thing running at once. Without a code example though, it's impossible to say for sure.

Resources