Contributions
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: A transaction is submitted to the MockService The MockOperation script for the given transaction type calls an external groovy script with a methodgetResponse() this script determines the content of the ACK, which is subsequently returned synchronously Once the ACK has been returned,getResponse() calls a groovy test step within the MockService Project This groovy test step extracts some information out of the request (passed in as an XmlHolder variable bygetResponse()) in order to determine the location of another, transaction-specific groovy script with methodsendCallBack() 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 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 usingtestCase.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? Thanks766Views0likes0CommentsMockservice concurrent requests failing
Hi, When sending concurrent test requests to a SOAP mock service I am having issues with tests randomly failing or passing and was hoping for some help. In my MockResponse for this transaction within the MockOperation of the mock service, I have a variable context.content which contains the body of the response. The content of this context.content is XML pulled from my local file system, determined by a function, getResponse() which takes into account a couple of key fields in the request to determine which file contents to put into context.content (and therefore what the MockResponse looks like). It looks like when sending in concurrent transactions, because all transactions are using there own instance of getResponse() to edit context.content, the mock service gets confused and sends back incorrect responses with duplicate contents. I can see in the script log in SOAPUI that for each transaction that processing for getResponse() is happening and complete, but I suspect context.content is not getting updated before the mock service returns its MockResponse. I have tried synchronising getResponse() as per this thread:https://community.smartbear.com/t5/SoapUI-Open-Source/Multi-threading-in-SoapUI-Mock-Service/td-p/10415 but haven't had any success. context.lock = new Object() def getResponse() { synchronized(context.lock) { // do stuff ..... return response } } It is probably also worth menitoning thatgetResponse() sits in a seperate Groovy script which is called from the MockResponse script. However I have also tried synchronising the call to this script (as well as inlcuding all the logic ofgetResponse()) in the MockResponse script and this still does not work. context.lock = new Object() synchronized(context.lock) { …. instance = externalScript.newInstance() instance.getResponse() } I have also recreated a simple MockService which has much simplier processing in choosing the response to be returned and have noticed that this confusion in what is returned is still there. Is there a way of using a context based variable in a multi-threaded way, allowing for a mock service to accept multiple concurrent requests with processing to update that variable? Thanks1.3KViews0likes2Comments