Parallel execution with multiple users in karate

我只是一个虾纸丫 提交于 2021-01-28 09:23:35

问题


My requirement is : I want to have parallel execution with say 5 thread. All thread would be creating an entity.I want to have more threads so that text execution time could be less.But I am facing issue as when threads are increasing ,I get error from db saying unable to lock the error as all threads are using same user to create an entity.Is it possible in karate that I can use multiple user credentials so that threads can pick users randomly and create an entity??


回答1:


Simple solution, write the logic in Java to do this and make it a singleton or static method. Then make a call to it from your script something like this:

* var MyCode = Java.type('com.myco.MyCode')
* var entity = MyCode.getEntity()

So you can keep track of entities created (maybe in a Set or Map) and re-use as per your wish.

Sorry Karate does not have built-in support for this kind of thing.



来源:https://stackoverflow.com/questions/54571702/parallel-execution-with-multiple-users-in-karate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!