-
-
Save maxandersen/ee78e2ac5424ccdabfd874ee4272a4fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DEPS us.abstracta.jmeter:jmeter-java-dsl:1.27 | |
//DEPS org.assertj:assertj-core:3.21.0 | |
//DEPS org.junit.jupiter:junit-jupiter-engine:5.8.2 | |
import static org.assertj.core.api.Assertions.assertThat; | |
import static us.abstracta.jmeter.javadsl.JmeterDsl.httpSampler; | |
import static us.abstracta.jmeter.javadsl.JmeterDsl.jtlWriter; | |
import static us.abstracta.jmeter.javadsl.JmeterDsl.testPlan; | |
import static us.abstracta.jmeter.javadsl.JmeterDsl.threadGroup; | |
import java.io.IOException; | |
import java.time.Duration; | |
import org.apache.http.entity.ContentType; | |
import us.abstracta.jmeter.javadsl.core.TestPlanStats; | |
public class PerformanceTest { | |
public static void main(String[] args) throws IOException { | |
var url = args.length > 0 ? args[0] : "https://webhook.site/a43b0795-a83a-4dcf-8bd1-891b2a982a4c"; | |
var body = args.length > 1 ? args[1] : "{\"name\": \"test\"}"; | |
System.out.println("url: " + url); | |
TestPlanStats stats = testPlan( | |
threadGroup(2, 10, | |
httpSampler(url) | |
.post(body, ContentType.APPLICATION_JSON) | |
), | |
//this is just to log details of each request stats | |
jtlWriter("target/jtls") | |
).run(); | |
assertThat(stats.overall().sampleTimePercentile99()).isLessThan(Duration.ofSeconds(5)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment