From e8aa318c6c624eb5ca399c5fc653e19f85fa8b18 Mon Sep 17 00:00:00 2001 From: Flook Peter Date: Wed, 22 Jan 2025 16:40:12 +0800 Subject: [PATCH] Add in sample validations for HTTP --- .../io/github/datacatering/plan/HttpJavaPlanRun.java | 9 ++++++++- .../scala/io/github/datacatering/plan/HttpPlanRun.scala | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/datacatering/plan/HttpJavaPlanRun.java b/src/main/java/io/github/datacatering/plan/HttpJavaPlanRun.java index 3e1dfbb..e586391 100644 --- a/src/main/java/io/github/datacatering/plan/HttpJavaPlanRun.java +++ b/src/main/java/io/github/datacatering/plan/HttpJavaPlanRun.java @@ -10,7 +10,7 @@ public class HttpJavaPlanRun extends PlanRun { { - var httpTask = http("my_http", Map.of(Constants.ROWS_PER_SECOND(), "1")) + var httpTask = http("my_http", Map.of(Constants.ROWS_PER_SECOND(), "1", Constants.VALIDATION_IDENTIFIER(), "POST/pets")) .fields( field().httpHeader("Content-Type").staticValue("application/json"), field().httpHeader("Content-Length"), @@ -33,6 +33,13 @@ public class HttpJavaPlanRun extends PlanRun { ) ) ) + .validations( + validation().field("request.method").isEqual("POST"), + validation().field("response.statusCode").isEqual(200), + validation().field("response.timeTaken").lessThan(100), + validation().field("response.headers.Content-Length").greaterThan(0), + validation().field("response.headers.Content-Type").isEqual("application/json") + ) .count(count().records(2)); var conf = configuration() diff --git a/src/main/scala/io/github/datacatering/plan/HttpPlanRun.scala b/src/main/scala/io/github/datacatering/plan/HttpPlanRun.scala index 09a1699..9a4c9cf 100644 --- a/src/main/scala/io/github/datacatering/plan/HttpPlanRun.scala +++ b/src/main/scala/io/github/datacatering/plan/HttpPlanRun.scala @@ -23,6 +23,7 @@ class HttpPlanRun extends PlanRun { validation.field("request.method").isEqual("POST"), validation.field("request.method").isEqualField("response.statusText"), validation.field("response.statusCode").isEqual(200), + validation.field("response.timeTaken").lessThan(100), validation.field("response.headers.Content-Length").greaterThan(0), validation.field("response.headers.Content-Type").isEqual("application/json"), )