Forum Discussion

nouchm123's avatar
nouchm123
New Contributor
5 years ago

Asynchronous MockService Concurrency Test Issues

Hi,

 

I have a MockService which is being used to simulator asynchronous transactions. In its current configuration, I can succesfully simulate asynchronous transactions, whereby a single request will recieve an Acknowledgement (ACK) response and subsequently a callback containing the payload of the response. A summary of the current workflow is as follows:

 

  1. A transaction is submitted to the MockService
  2. The MockOperation script for the given transaction type calls an external groovy script with a method getResponse()
    • this script determines the content of the ACK, which is subsequently returned synchronously
  3. Once the ACK has been returned, getResponse() calls a groovy test step within the MockService Project
  4. This groovy test step extracts some information out of the request (passed in as an XmlHolder variable by getResponse()) in order to determine the location of another, transaction-specific groovy script with method sendCallBack()
  5. sendCallBack() applies some business logic to determine the content of the callback, but ultimately grabs the content of the callback from a stored set of files 
  6. Once it has the content of the callback, sendCallBack() calls a test case, again within the MockService project, which fires a request to a configured endpoint (simulating the asynchronous transaction workflow) with the callback content stored in the test case level property ${#TestCase#callbackContent}
    • this is set by grabbing the test case by name (getTestCaseByName()) and using testCase.setPropertyValue("callbackContent", responseContent)

Whilst this workflow works for individual, sequential requests, when several requests are run concurrently, the results randomly fail or pass because they all use ${#TestCase#callbackContent}. Is there a way to make this property thread safe so that there is no overlap of content? 

 

I have tried setting up an individual TestRunContext for the test step which sends the callback and setting callbackContent as below:

 

def testStep = testcase.getTestStepAt(0)
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testcase, null)
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep)

testStepContext.callbackContent = responseContent

but this does not seem to work either.

 

Any ideas?

 

Thanks

No RepliesBe the first to reply