Я выполняю тесты perf, используя приведенную ниже команду maven,
mvn gatling: test -Dgatling.simulationClass = simulations.Stageabcsite
Теперь мне нужно, чтобы я хотел используйте Java лямбда-функцию вместо mvn, потому что у меня есть требование запустить этот код gatling на AWS лямбда
Вот мой pom. xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
2001/.
XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/.
xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sre</groupId>
<artifactId>SRE</artifactId>
<version>3.3.1</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling.version>${project.version}</gatling.version>
<gatling-plugin.version>3.0.3</gatling-plugin.version>
<scala-maven-plugin.version>4.2.0</scala-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<jvmArgs>
<jvmArg>-Xss100M</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:postfixOps</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
</project>
Вот код Гатлинга, который Java лямбда-функция должна вызывать
package simulations
import baseConfig.BaseSimulation
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class Stageabcsite extends BaseSimulation {
val headers_0 = Map(
"accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"cache-control" -> "max-age=0",
"content-type" -> "multipart/form-data; boundary=----WebKitFormBoundarygecOpCycXAuBFkiL",
"origin" -> "https://admin-stage.abc.xyz.com",
"sec-fetch-mode" -> "navigate",
"sec-fetch-site" -> "same-origin",
"sec-fetch-user" -> "?1",
"upgrade-insecure-requests" -> "1")
val headers_currentrevision = Map(
"accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"cache-control" -> "max-age=0",
"referer" -> "https://admin-stage.abc.xyz.com/en/node/add/big-page",
"sec-fetch-mode" -> "navigate",
"sec-fetch-site" -> "same-origin",
"sec-fetch-user" -> "?1",
"upgrade-insecure-requests" -> "1")
val headers_Bigcontent = Map(
"accept" -> "*/*",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"referer" -> "https://admin-stage.abc.xyz.com/en/content/test-drupal-content-0",
"sec-fetch-mode" -> "no-cors",
"sec-fetch-site" -> "cross-site")
val headers_testDrupalContentAfterSaving = Map(
"accept" -> "*/*",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"if-modified-since" -> "Tue, 18 Feb 2020 18:00:00 GMT",
"referer" -> "https://admin-stage.abc.xyz.com/en/content/test-drupal-content-0",
"sec-fetch-mode" -> "no-cors",
"sec-fetch-site" -> "cross-site")
val scn = scenario("Stage abc Site Baseline")
.exec(http("Log In")
.post("/en/fiveprime3primewbc")
.headers(headers_fiveprime)
.formParam("name", "ab_aryan")
.formParam("pass", "dragon3")
.formParam("form_build_id", "form-KU0StakJoFB8ijbpmBm8Jfsc11lzVrZPJ4LBlJ233QI")
.formParam("form_id", "user_login")
.formParam("op", "Log in")
.check(status.is(302))
.check(bodyString.saveAs("Login_Response")))
.exec(http("Add Big Page Save Content")
.post("/en/node/add/big-page")
.headers(headers_0)
.body(RawFileBody("/Users/dast/Downloads/abcwebsitetests-CQ-1159-Self-Service-Perf-To-Use-Maven/src/test/resources/data/0000_request.dat"))
)
.exec(http("Current Revision")
.get("/en/node/1496326/current-revision")
.headers(headers_currentrevision)
.check(status.is(302)))
.pause(1)
.exec(http("After Saving View Youtube Iframe")
.get(uri2 + "/iframe_api")
.headers(headers_Bigcontent))
.exec(http("After Saving View Draft Content ")
.get(uri5 + "?id=DC-9597311")
.headers(headers_testDrupalContentAfterSaving))
setUp(
scn.inject(
constantConcurrentUsers(800) during(60))
.protocols(httpProtocol))
.maxDuration(60)
}