forked from codecentric/gatling-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify the log method in JdbcAction to also log group times. Because …
…this modifies the session the actions have to pass on the modified session again. Add simulation for group metrics. Closes #2
- Loading branch information
1 parent
e757507
commit d79496a
Showing
7 changed files
with
54 additions
and
13 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 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 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 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 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 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
46 changes: 46 additions & 0 deletions
46
src/test/scala/dev/code_n_roll/gatling/jdbc/simulation/GroupInsertSimulation.scala
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,46 @@ | ||
package dev.code_n_roll.gatling.jdbc.simulation | ||
|
||
import dev.code_n_roll.gatling.jdbc.Predef._ | ||
import dev.code_n_roll.gatling.jdbc.builder.column.ColumnHelper._ | ||
import io.gatling.core.Predef._ | ||
import io.gatling.core.scenario.Simulation | ||
import scalikejdbc.{GlobalSettings, LoggingSQLAndTimeSettings} | ||
|
||
import scala.concurrent.duration._ | ||
import scala.util.Random | ||
|
||
/** | ||
* Simulation to check that the reporting of times also works when using a group. | ||
* Therefore, the response time is set to be between 0 and 1000. When the group | ||
* time doesn't work the time will be just zero. | ||
*/ | ||
class GroupInsertSimulation extends Simulation { | ||
|
||
val jdbcConfig = jdbc.url("jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE").username("sa").password("sa").driver("org.h2.Driver") | ||
|
||
GlobalSettings.loggingSQLAndTime = LoggingSQLAndTimeSettings(singleLineMode = true, logLevel = 'warn) | ||
|
||
val scn = scenario("group create insert") | ||
.group("group") { | ||
exec(jdbc("bar table") | ||
.create() | ||
.table("bar") | ||
.columns( | ||
column( | ||
name("abc"), | ||
dataType("VARCHAR"), | ||
constraint("PRIMARY KEY") | ||
) | ||
) | ||
).pause(3.seconds) | ||
.exec(jdbc("insertion") | ||
.insert() | ||
.into("bar (abc)") | ||
.values("'1'")) | ||
} | ||
|
||
setUp( | ||
scn.inject(atOnceUsers(1)), | ||
).protocols(jdbcConfig) | ||
.assertions(details("group").responseTime.mean.between(0, 1000, inclusive = false)) | ||
} |