空手道中与多个用户并行执行 [英] Parallel execution with multiple users in karate

查看:66
本文介绍了空手道中与多个用户并行执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是:我想与5个线程并行执行.所有线程都将创建一个实体.我想拥有更多线程,以减少文本执行时间.但是当线程正在增加时,我面临的问题是,我从db中收到错误消息,说所有线程都在使用时无法锁定错误同一位用户创建一个实体.空手道有可能使用多个用户凭据,以便线程可以随机选择用户并创建一个实体吗?

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??

推荐答案

简单的解决方案,用Java编写逻辑来做到这一点,并使之成为单例或静态方法.然后从脚本中调用它,如下所示:

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()

因此,您可以跟踪创建的实体(可能在SetMap中)并根据您的意愿重复使用.

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.

这篇关于空手道中与多个用户并行执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆