我们可以限制空手道每秒的请求命中数吗 [英] Can we limit the number of request hits per second in karate
问题描述
我正在使用空手道0.9.0.由于网关的阈值限制,我需要将测试套件中的请求命中次数限制为每秒5次.空手道有可能吗?如果是,怎么办?
I am using karate 0.9.0. I need to limit the request hits to 5 per second in my test suite due to threshold limit at gateway. is it possible in karate or not? If yes, how?
推荐答案
这里是建议- configure headers
作为JavaScript函数.在函数体内-使用Java单例(和静态方法)跟踪已发送了多少个请求,以及需要添加多少个睡眠"以维持所需的限制/阈值.
Here is the suggestion - configure headers
as a JavaScript function. Within the function body - use a Java singleton (and a static method) to track how many requests have been sent and how much "sleep" needs to be added to maintain the required throttling / threshold.
您将需要一定的Java技能来做到这一点.该文档详细介绍了如何调用Java代码.
You will need some Java skills to do this, all the best. The documentation has details on how to call Java code.
这篇关于我们可以限制空手道每秒的请求命中数吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!