Skip to content

Commit

Permalink
Re-create gatling project
Browse files Browse the repository at this point in the history
- Project create form maven archetype
- Added scenarios for article rest service
  • Loading branch information
fgakk committed Mar 5, 2020
1 parent a4e9091 commit f1fe951
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 160 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# akka-kamon-maven-gatling
Gatling Test Project for akka-kamon-maven to produce some load for metrics
# gatling-example
Gatling Test Project running against a rest service. The example source code for service is [here](spring-kotlin-example)

### How to run

Expand Down
119 changes: 0 additions & 119 deletions pom.xml

This file was deleted.

39 changes: 0 additions & 39 deletions src/test/scala/com/fgakk/samples/akka/CreateNote.scala

This file was deleted.

56 changes: 56 additions & 0 deletions src/test/scala/simulation/AdvancedSimulation.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package simulation

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.http.protocol.HttpProtocolBuilder
import scala.concurrent.duration._

class AdvancedSimulation extends Simulation {

val httpProtocol: HttpProtocolBuilder = http
.baseUrl("http://localhost:8080/api") // Here is the root for all relative URLs
.acceptEncodingHeader("gzip, deflate")

val users = scenario("Users").exec(ShowDetail.showDetail, Repeat.repeatedExecution, AddComment.addComment)

setUp(
users.inject(rampUsers(2000) during (10 seconds))
).protocols(httpProtocol)

object ShowDetail {
val showDetail = exec(http("List Articles")
.get("/articles/")
.check(jsonPath("$[0].headlineSlug").saveAs("headline")))
.pause(2)
.exec(http("Select one Article")
.get("/articles/${headline}"))
.pause(3)
}

object Repeat {
val repeatedExecution = repeat(10, "n") {
exec(http("Repeat action")
.get("/articles/"))
.pause(1)
}
}

object AddComment {

val feeder = jsonFile("comments.json").circular
val addComment =
exec(http("List Article")
.get("/articles/")
.check(jsonPath("$[0].id").saveAs("id")))
.feed(feeder)
.pause(1)
.exec(http("Post")
.post("/articles/${id}/comment")
.body(StringBody("""{"author": "${author}", "text":"${text}"}""")).asJson
.check(status.is(session => 200)))
}
}




25 changes: 25 additions & 0 deletions src/test/scala/simulation/BasicSimulation.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package simulation

import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.http.Predef._
import io.gatling.http.protocol.HttpProtocolBuilder

class BasicSimulation extends Simulation {

val httpProtocol: HttpProtocolBuilder = http
.baseUrl("http://localhost:8080/api") // Here is the root for all relative URLs
.acceptEncodingHeader("gzip, deflate")

val scn: ScenarioBuilder = scenario("ArticleRestServiceSimulation")
.exec(http("articles")
.get("/articles/")
)
.pause(1)

setUp(
scn.inject(atOnceUsers(100))
.protocols(httpProtocol)
)

}

0 comments on commit f1fe951

Please sign in to comment.