question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

improve async listen / signal flow with new interface

See original GitHub issue

Testing api with Karate: mocks and queue implementation: Error TestRunner.testParallel:15 Multi threaded access requested by thread Thread[pool-1-thread-1,3,main] but is not allowed for language(s) js. is produced when try to consume a queue with multiple messages. Flow: Call a messageMock.feature :

Background:
* def QueueUtils = Java.type('mocks.QueueUtils')
* configure cors = true
* configure responseHeaders = { 'Content-Type': 'application/json' }

Scenario: pathMatches('/message') && methodIs('post')
* def response = read('../../responses/message/message.json')
* def responseStatus = 200
* QueueUtils.send(response.data, JSON.stringify(read('test.json')), 25)
* QueueUtils.send(response.data, JSON.stringify(read('test1.json')), 25)
* QueueUtils.send(response.data, JSON.stringify(read('test2.json')), 25)

From feature:


Scenario: Send message
* def QueueConsumer = Java.type('mocks.QueueConsumer')
* def port = karate.start('messageMock.feature').port
* url baseUrl + port
Given path '/message';
And request read('req.json')
When method post
Then status 200
* def queue = new QueueConsumer(response.data)
* def handler = function(msg){ karate.signal(msg) }
* queue.listen(karate.toJava(handler))
* listen 2000
* json response = listenResult
* print '### received:', listenResult
And match response == read('test.json')
* listen 2000
* json response1 = listenResult
* print '### received1:', listenResult
And match response1 == read('test1.json')
* listen 2000
* json response2 = listenResult
* print '### received2:', listenResult
And match response2 == read('test2.json')

The error message is given on line:

* json response = listenResult I am creating an issue as instructed in https://stackoverflow.com/questions/68377437/karate-api-test-testrunner-testparallel15-multi-threaded-access-requested-by-t

Example project(minimal, complete and verificable): example.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:29 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
ChavdarEmilovPagoNxtcommented, Jul 21, 2021

@ptrthomas Happy to help even if is a little one. Hopefully will be able to contribute more in the future! Thank you once again for all your help and for creating this amazing tool! Testing would not be the same without it.

0reactions
ptrthomascommented, Aug 4, 2021

1.1.0 released

Read more comments on GitHub >

github_iconTop Results From Across the Web

improve async listen / signal flow with new interface #1681
currently listen and karate.signal() are designed for "one message at a time" which now seems limiting. does it make sense to introduce a...
Read more >
Configuring Asynchronous Lines and Interfaces - Cisco
Configuring a Typical Asynchronous Interface. To configure an asynchronous interface, use the following commands beginning in global configuration.
Read more >
Improve Asynchronous Programming Model
Coupling to Task and Task<T>. Code is now coupled to the Task and Task<T> objects. Interfaces and classes now have to change their...
Read more >
Dealing With Asynchronous Signals In Multi Threaded Program
The advantage of this approach is that asynchronously generated signals are received synchronously. As it accepts incoming signals, the ...
Read more >
Long Story Short: Async/Await Best Practices in .NET - Medium
In order to solve this common problem, . NET provides the IProgress<T> interface, which exposes a Report<T> method, which the async task ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found