Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for service request creation API simulation #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,24 @@ Scripts for provisioning and benchmarking clamp core performance

* brew install [email protected]

## Running Clamp
Clamp and its dependencies can be run with the following Docker Compose command

```bash
$ docker-compose -d up
```

## Running Tests

```bash
$ 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

**Example**
```bash
$ mvn gatling:test -DgatlingSimulationClass=clampcore.CreateServiceRequestSimulation -DmaxRPS=500 -DdurationSeconds=120 -DmaxDurationSeconds=300
```
2 changes: 1 addition & 1 deletion benchmarking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<jvmArg>-DdurationMaxMinutes=${durationMaxSeconds}</jvmArg>
<jvmArg>-Xmx5g</jvmArg>
</jvmArgs>
<simulationClass>clampcore.InitiateWorkflowSimulation</simulationClass>
<simulationClass>${gatlingSimulationClass}</simulationClass>
<propagateSystemProperties>true</propagateSystemProperties>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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")
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 = ""

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)
.andThen(
createPollServiceRequestScenario.inject(
rampUsersPerSec(1).to(MAX_RPS).during(DURATION_SECONDS seconds)
)
.protocols(baseHttp)
)
)
)
.maxDuration(MAX_DURATION_SECONDS seconds)
}