-
Notifications
You must be signed in to change notification settings - Fork 2
/
ExampleSimulation.scala
56 lines (49 loc) · 1.73 KB
/
ExampleSimulation.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package simulation
import dev.joss.gatling.sfn.Predef._
import dev.joss.gatling.sfn.protocol.{SfnProtocol, SfnProtocolBuilder}
import io.gatling.core.Predef._
import io.gatling.core.scenario.Simulation
import io.gatling.core.structure.{PopulationBuilder, ScenarioBuilder}
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.auth.credentials.{
AwsSessionCredentials,
StaticCredentialsProvider
}
import software.amazon.awssdk.http.apache.ApacheHttpClient
import software.amazon.awssdk.services.sfn.SfnClient
import software.amazon.awssdk.services.sfn.model.HistoryEventType.WAIT_STATE_EXITED
import java.net.URI
import scala.concurrent.duration.DurationInt
import scala.language.postfixOps
class ExampleSimulation extends Simulation {
var sfnClient: SfnClient = SfnClient
.builder()
.endpointOverride(URI.create("http://localhost:4566"))
.region(Region.EU_WEST_1)
.credentialsProvider(
StaticCredentialsProvider.create(
AwsSessionCredentials.create("definitely", "real", "credentials")
)
)
.httpClient(ApacheHttpClient.create())
.build()
var sfnProtocol: SfnProtocolBuilder = sfn.client(sfnClient)
var sfnArn =
"arn:aws:states:eu-west-1:000000000000:stateMachine:hello-world-sfn"
val scn: ScenarioBuilder = scenario("SFN DSL test")
.exec(
sfn("Start Hello World Execution").startExecution
.arn(sfnArn)
.payload("{\"IsHelloWorldExample\": true}")
)
.pause(5 seconds)
.exec(
sfn("Check the response").checkStateSucceeded
.stateName("Wait2")
.stateType(WAIT_STATE_EXITED)
)
val requests: PopulationBuilder = scn.inject {
constantUsersPerSec(1) during (5 seconds)
}
setUp(requests).protocols(sfnProtocol)
}