Skip to content

Commit

Permalink
gatling: do not publish to chn topics.
Browse files Browse the repository at this point in the history
  • Loading branch information
aforge committed Dec 16, 2020
1 parent f95e9b5 commit 9d83236
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions loadtest/loadtest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ class Loadtest extends Simulation {
}
}

val publish = exitBlockOnFail {
exec {
repeat(3, "i") {
exec {
ws("pub-topic").sendText(
"""{"pub":{"id":"${id}-pub-${sub}-${i}","topic":"${sub}","content":"This is a Tsung test ${i}"}}"""
)
.await(15 seconds)(
ws.checkTextMessage("pub-topic-ctrl")
.matching(jsonPath("$.ctrl").find.exists)
.check(jsonPath("$.ctrl.code").ofType[Int].in(200 to 299))
)
}
.pause(0, 3)
}
}
}

val getSubs = exitBlockOnFail {
exec {
ws("get-subs").sendText(
Expand Down Expand Up @@ -127,28 +145,18 @@ class Loadtest extends Simulation {
ws("sub-topic").sendText(
"""{"sub":{"id":"${id}-sub-${sub}","topic":"${sub}","get":{"what":"desc sub data del"}}}"""
)
.await(5 seconds)(
.await(15 seconds)(
ws.checkTextMessage("sub-topic-ctrl")
.matching(jsonPath("$.ctrl").find.exists)
.check(jsonPath("$.ctrl.code").ofType[Int].in(200 to 299))
)
}
.exitHereIfFailed
.pause(0, 2)
.repeat(3, "i") {
exec {
ws("pub-topic").sendText(
"""{"pub":{"id":"${id}-pub-${sub}-${i}","topic":"${sub}","content":"This is a Tsung test ${i}"}}"""
)
.await(5 seconds)(
ws.checkTextMessage("pub-topic-ctrl")
.matching(jsonPath("$.ctrl").find.exists)
.check(jsonPath("$.ctrl.code").ofType[Int].in(200 to 299))
)
}
.pause(0, 3)
}
.exitHereIfFailed
.doIfOrElse({session =>
val topic = session("sub").as[String]
!topic.startsWith("chn")
}) { publish } { pause(5) }
.exec {
ws("leave-topic").sendText(
"""{"leave":{"id":"${id}-leave-${sub}","topic":"${sub}"}}"""
Expand Down

0 comments on commit 9d83236

Please sign in to comment.