Karate 空手道格特林中如何每秒加载更多请求
我正在尝试重用空手道脚本,并使用gatling执行负载测试。定义的场景是每秒加载50个用户,持续10秒。(加载测试500个用户)但是,gatling报告中每秒的请求数不超过20个。如果我做错了什么,请告诉我。 执行空手道脚本的ExampleTest.java代码Karate 空手道格特林中如何每秒加载更多请求,karate,Karate,我正在尝试重用空手道脚本,并使用gatling执行负载测试。定义的场景是每秒加载50个用户,持续10秒。(加载测试500个用户)但是,gatling报告中每秒的请求数不超过20个。如果我做错了什么,请告诉我。 执行空手道脚本的ExampleTest.java代码 //package examples; import com.intuit.karate.Results; import com.intuit.karate.Runner; import static org.junit.jupite
//package examples;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
class ExamplesTest {
@Test
void testParallel() {
//System.setProperty("karate.env", "demo"); // ensure reset if other tests (e.g. mock) had set env in CI
Results results = Runner.path("classpath:examples").tags("~@ignore").parallel(10);
generateReport(results.getReportDir());
assertEquals(0, results.getFailCount(), results.getErrorMessages());
}
public static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList<String>(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}
我们更新了文档(在develope
分支中),提供了如何在需要时增加线程池大小的提示:
将名为gatling akka.conf
的文件添加到类路径的根目录中(通常是src/test/resources
)。以下是一个例子:
由于我们最近进行了一些修复,请尝试从源代码进行构建。如果上述内容不适用于0.9.6.RC4,则很容易,以下是说明:
如果这不起作用,请务必遵循此过程,以便我们可以复制:我们更新了文档(在开发
分支中),并提供了有关如何在需要时增加线程池大小的提示:
将名为gatling akka.conf
的文件添加到类路径的根目录中(通常是src/test/resources
)。以下是一个例子:
由于我们最近进行了一些修复,请尝试从源代码进行构建。如果上述内容不适用于0.9.6.RC4,则很容易,以下是说明:
如果这不起作用,请务必遵循此过程,以便我们可以复制:谢谢,Peter,将尝试并更新结果。我的功能文件中有此功能,用于从feeder文件中获取数据
和头授权='Bearer'+karate.get(''uu gatling.accessToken')
,现在添加.conf文件后,似乎没有按照上面scala代码中的指定从userFeeder加载访问令牌。。get请求具有以下值Authorization:Bearernull
@VijayReddy,这没有意义。很抱歉是时候遵循这个过程了:注释中指定的问题通过使用正确的依赖项更新pom文件得到解决,并且每秒成功发送100个请求。多谢各位@PeterThomas@vdrulerz这里的问题是,当负载为100多个用户时,应该会发送100个请求,但在添加peter建议的代码并对POM进行了一些小的更改之后,这并没有发生。使用最新版本的空手道,我不确定pom依赖项是否需要任何更改。谢谢Peter,我将尝试并更新结果。我的功能文件中有这个,以从feeder文件获取数据和头授权='Bearer'+karate.get(''uu gatling.accessToken')
,现在添加.conf文件后,似乎没有按照上面scala代码中的指定从userFeeder加载访问令牌。。get请求具有以下值Authorization:Bearernull
@VijayReddy,这没有意义。很抱歉是时候遵循这个过程了:注释中指定的问题通过使用正确的依赖项更新pom文件得到解决,并且每秒成功发送100个请求。多谢各位@PeterThomas@vdrulerz这里的问题是,当负载为100多个用户时,应该会发送100个请求,但在添加peter建议的代码并对POM进行了一些小的更改之后,这并没有发生。使用最新版本的空手道,不确定pom依赖项是否需要任何更改。
package perf
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.concurrent.duration._
class KarateSimulate extends Simulation {
val protocol = karateProtocol(
"/v2/" -> Nil,
"/v2/" -> pauseFor("get" -> 0, "post" -> 25)
)
val userfeeder = csv("data/Token.csv").circular
val getScores = scenario("Get Scores for Students").feed(userfeeder).exec(karateFeature("classpath:examples/scores/student.feature"))
setUp(
getScores.inject(constantUsersPerSec(50) during (10 seconds)).protocols(protocol)
)
}
akka {
actor {
default-dispatcher {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 100
}
throughput = 1
}
}
}