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 2 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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ Scripts for provisioning and benchmarking clamp core performance

* brew install [email protected]

## 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
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,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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently your ramp up user and rps values are hardcoded. Did you intend to externalize them?

Copy link
Author

@sivachandran sivachandran Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Externalized @priyaaank

nothingFor(1 second),
rampUsersPerSec(1).to(500).during(1 minute)
)
.protocols(baseHttp)
)
)
.maxDuration(5 minutes)
}