-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Project create form maven archetype - Added scenarios for article rest service
- Loading branch information
Showing
5 changed files
with
83 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
|
||
} |