feat: use gatling to have a presure test for remote framework

This commit is contained in:
tjq 2023-01-08 21:41:15 +08:00
parent 2afb20df0b
commit cd7a743097
2 changed files with 16 additions and 7 deletions

View File

@ -4,6 +4,9 @@ import java.nio.file.Paths;
import static java.util.Objects.requireNonNull;
/**
* @author <a href="https://github.com/gatling/gatling-maven-plugin-demo-java">gatling-maven-plugin-demo-java</a>
*/
public class IDEPathHelper {
static final Path mavenSourcesDirectory;

View File

@ -6,9 +6,7 @@ import static io.gatling.javaapi.http.HttpDsl.*;
import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;
/**
* HTTP 压测模拟
*
*
* HTTP 为入口压测
*
* @author tjq
* @since 2023/1/8
@ -24,11 +22,17 @@ public class HttpSimulation extends Simulation {
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0");
ScenarioBuilder scn = scenario("HttpSimulation") // 7
.exec(http("request_http") // 请求名称用于压测报表展示
.get("/pressure/ask?protocol=HTTP&debug=true&responseSize=1024")) // 9
ScenarioBuilder httpAsk = scenario("HttpSimulation") // 7
.exec(http("PowerJob-Remote-Http") // 请求名称用于压测报表展示
.get("/pressure/ask?protocol=HTTP&debug=false&responseSize=1024")) // 9
.pause(5); // 10
ScenarioBuilder akkaAsk = scenario("AkkaSimulation") // 7
.exec(http("PowerJob-Remote-AKKA") // 请求名称用于压测报表展示
.get("/pressure/ask?protocol=AKKA&debug=false&responseSize=1024")) // 9
.pause(5); // 10
/*
atOnceUsers(10) 一次模拟的用户数量(10)
nothingFor(4 seconds) 在指定的时间段(4 seconds)内什么都不干
@ -39,7 +43,9 @@ public class HttpSimulation extends Simulation {
{
setUp( // 11
scn.injectOpen(incrementUsersPerSec(10.0).times(2).eachLevelLasting(10)) // 12
httpAsk.injectOpen(incrementUsersPerSec(10.0).times(2).eachLevelLasting(10)).andThen(
akkaAsk.injectOpen(incrementUsersPerSec(10.0).times(2).eachLevelLasting(10))
) // 12
).protocols(httpProtocol); // 13
}
}