From f7595bf833f8da854594a0ff895c770e8b245725 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Wed, 10 Mar 2021 17:58:08 +0530 Subject: [PATCH 1/6] Add simulation for service request creation --- benchmarking/pom.xml | 2 +- .../CreateServiceRequestSimulation.scala | 87 +++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala diff --git a/benchmarking/pom.xml b/benchmarking/pom.xml index 328ecc0..bb8f956 100644 --- a/benchmarking/pom.xml +++ b/benchmarking/pom.xml @@ -70,7 +70,7 @@ -DdurationMaxMinutes=${durationMaxSeconds} -Xmx5g - clampcore.InitiateWorkflowSimulation + ${gatlingSimulationClass} true diff --git a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala new file mode 100644 index 0000000..d5df859 --- /dev/null +++ b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala @@ -0,0 +1,87 @@ +package clampcore + +import io.gatling.core.Predef._ +import io.gatling.core.feeder.Feeder +import io.gatling.http.Predef._ +import org.slf4j.{Logger, LoggerFactory} + +import java.util.UUID +import scala.concurrent.duration._ +import scala.language.postfixOps + +class CreateServiceRequestSimulation extends Simulation { + + var logger: Logger = LoggerFactory.getLogger("SimulationLogger") + + var workflowName = "" + + val workflowDefinition = + """ + { + "name": "${workflow_name}", + "description": "a benchmarking flow with only http sync services", + "steps": [ + { + "name": "benchmarking step one", + "mode": "HTTP", + "val": { + "method": "GET", + "url": "http://api-server:8083/api/step1" + } + } + ] + } + """ + + val baseHttp = http + .baseUrl("http://localhost:8080") + .header("no-cache", "no-cache") + .contentTypeHeader("application/json") + .userAgentHeader("PostmanRuntime/7.26.8") + .acceptHeader("*/*") + .connectionHeader("keep-alive") + + val uuidfeeder: Feeder[String] = Iterator.continually(Map("workflow_name" -> UUID.randomUUID().toString)) + + def createWorkflow() = { + exec(http("create_workflow") + .post("/workflow") + .body(StringBody(workflowDefinition)).asJson + .check(jsonPath("$.name").saveAs("workflowName")) + ) + } + + def createServiceRequest() = { + http("execute_workflow") + .post("/serviceRequest/${workflow_name}") + .check(status.is(200)) + } + + var createWorkflowScenario = scenario("Create workflow scenario") + .feed(uuidfeeder) + .exec(createWorkflow()) + .exec(session => { + workflowName = session("workflowName").as[String] + session + }) + + var createPollServiceRequestScenario = scenario("Create service request scenario") + .exec(_.set("workflow_name", workflowName)) + .exec(createServiceRequest()) + + setUp( + List( + createWorkflowScenario.inject( + atOnceUsers(1) + ) + .protocols(baseHttp), + + createPollServiceRequestScenario.inject( + nothingFor(1 second), + rampUsersPerSec(1).to(500).during(1 minute) + ) + .protocols(baseHttp) + ) + ) + .maxDuration(5 minutes) +} From c0ca4270419c7dd5d91166f122327d455b09aed9 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Wed, 10 Mar 2021 18:06:43 +0530 Subject: [PATCH 2/6] Update README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 422df46..a2db010 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,13 @@ Scripts for provisioning and benchmarking clamp core performance * brew install scala@2.12 +## Running Tests + +```bash +$ cd benchmarking +$ mvn gatling:test -DgatlingSimulationClass=clampcore.{simulation-class-name} +``` + +**Simulation Classes** +- `InitiateWorkflowSimulation` - Tests workflow creation, service request creation and service status polling APIs +- `CreateServiceRequestSimulation` - Tests service request creation API \ No newline at end of file From b91baf2ffc3ef981537ba55c2af9bea8a25ecb64 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Thu, 11 Mar 2021 11:34:30 +0530 Subject: [PATCH 3/6] Externalise simulation parameters --- .../scala/clampcore/CreateServiceRequestSimulation.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala index d5df859..c50e123 100644 --- a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala +++ b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala @@ -12,6 +12,9 @@ import scala.language.postfixOps class CreateServiceRequestSimulation extends Simulation { var logger: Logger = LoggerFactory.getLogger("SimulationLogger") + val MAX_RPS = Integer.getInteger("maxRPS", 500).toDouble + val DURATION_SECONDS = Integer.getInteger("durationSeconds", 120).toInt + val MAX_DURATION_SECONDS = Integer.getInteger("maxDurationSeconds", 300).toInt var workflowName = "" @@ -77,11 +80,11 @@ class CreateServiceRequestSimulation extends Simulation { .protocols(baseHttp), createPollServiceRequestScenario.inject( - nothingFor(1 second), - rampUsersPerSec(1).to(500).during(1 minute) + nothingFor(1 second), // needed for Clamp complete workflow creation + rampUsersPerSec(1).to(MAX_RPS).during(DURATION_SECONDS seconds) ) .protocols(baseHttp) ) ) - .maxDuration(5 minutes) + .maxDuration(MAX_DURATION_SECONDS seconds) } From 9d966c34a27896987204640363a5f5abf5bf9959 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Thu, 11 Mar 2021 11:35:00 +0530 Subject: [PATCH 4/6] Update readme with info about docker compose and test parameters --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2db010..d0ab1c0 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,24 @@ Scripts for provisioning and benchmarking clamp core performance * brew install scala@2.12 +## Running Clamp +Clamp and its dependencies can be run with the following Docker Compose command + +```bash +$ docker-compose -d up +``` + ## Running Tests ```bash -$ cd benchmarking -$ mvn gatling:test -DgatlingSimulationClass=clampcore.{simulation-class-name} +$ mvn gatling:test -DgatlingSimulationClass=clampcore.{simulation-class-name} -D{arg-name}={arg-value} ``` **Simulation Classes** - `InitiateWorkflowSimulation` - Tests workflow creation, service request creation and service status polling APIs -- `CreateServiceRequestSimulation` - Tests service request creation API \ No newline at end of file +- `CreateServiceRequestSimulation` - Tests service request creation API + +**Example** +```bash +$ mvn gatling:test -DgatlingSimulationClass=clampcore.CreateServiceRequestSimulation -DmaxRPS=500 -DdurationSeconds=120 -DmaxDurationSeconds=300 +``` \ No newline at end of file From 3320fc1458fe2c67ed7bc1b58f6e50dbfd7a7f20 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Thu, 11 Mar 2021 11:36:59 +0530 Subject: [PATCH 5/6] Fix typo --- .../test/scala/clampcore/CreateServiceRequestSimulation.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala index c50e123..2d580d5 100644 --- a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala +++ b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala @@ -80,7 +80,7 @@ class CreateServiceRequestSimulation extends Simulation { .protocols(baseHttp), createPollServiceRequestScenario.inject( - nothingFor(1 second), // needed for Clamp complete workflow creation + nothingFor(1 second), // needed for Clamp to complete workflow creation rampUsersPerSec(1).to(MAX_RPS).during(DURATION_SECONDS seconds) ) .protocols(baseHttp) From 90524d74237039c37425eea040c8f1d6da9d7146 Mon Sep 17 00:00:00 2001 From: Sivachandran Paramasivam Date: Thu, 11 Mar 2021 14:51:53 +0530 Subject: [PATCH 6/6] Execute scenarios sequentially --- .../clampcore/CreateServiceRequestSimulation.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala index 2d580d5..e3e5f82 100644 --- a/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala +++ b/benchmarking/src/test/scala/clampcore/CreateServiceRequestSimulation.scala @@ -77,13 +77,13 @@ class CreateServiceRequestSimulation extends Simulation { createWorkflowScenario.inject( atOnceUsers(1) ) - .protocols(baseHttp), - - createPollServiceRequestScenario.inject( - nothingFor(1 second), // needed for Clamp to complete workflow creation - rampUsersPerSec(1).to(MAX_RPS).during(DURATION_SECONDS seconds) - ) .protocols(baseHttp) + .andThen( + createPollServiceRequestScenario.inject( + rampUsersPerSec(1).to(MAX_RPS).during(DURATION_SECONDS seconds) + ) + .protocols(baseHttp) + ) ) ) .maxDuration(MAX_DURATION_SECONDS seconds)