Skip to content

Commit

Permalink
Change tests to use UUIDs to avoid any conflicting inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Bräunlich committed Mar 12, 2019
1 parent 65949c9 commit 8d881bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.code_n_roll.gatling.jdbc.simulation

import java.util.UUID

import dev.code_n_roll.gatling.jdbc.Predef._
import dev.code_n_roll.gatling.jdbc.builder.column.ColumnHelper._
import io.gatling.core.Predef._
Expand All @@ -21,7 +23,7 @@ class InsertMySqlSimulation extends Simulation {

val tableIdentFeeder = for (x <- 0 until 10) yield Map("tableId" -> x)

val uniqueNumberFeeder = for (x <- 0 until 100) yield Map("unique" -> x)
val uniqueValuesFeeder = Iterator.continually(Map("unique" -> UUID.randomUUID()))

after {
mySql.stop()
Expand All @@ -34,18 +36,18 @@ class InsertMySqlSimulation extends Simulation {
.columns(
column(
name("abc"),
dataType("INTEGER"),
dataType("VARCHAR(39)"),
constraint("PRIMARY KEY")
)
)
)

val fillTables = feed(uniqueNumberFeeder).repeat(100, "n") {
val fillTables = feed(uniqueValuesFeeder).repeat(100, "n") {
feed(tableIdentFeeder.iterator.toArray.random).
exec(jdbc("insertion")
.insert()
.into("bar${tableId}")
.values("${unique}${n}")
.values("'${unique}${n}'")
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.code_n_roll.gatling.jdbc.simulation

import java.util.UUID

import dev.code_n_roll.gatling.jdbc.Predef._
import dev.code_n_roll.gatling.jdbc.builder.column.ColumnHelper._
import io.gatling.core.Predef._
Expand All @@ -21,7 +23,7 @@ class InsertPostgresSimulation extends Simulation {

val tableIdentFeeder = for (x <- 0 until 10) yield Map("tableId" -> x)

val uniqueNumberFeeder = for (x <- 0 until 100) yield Map("unique" -> x)
val uniqueValuesFeeder = Iterator.continually(Map("unique" -> UUID.randomUUID()))

after {
postgres.stop()
Expand All @@ -34,18 +36,18 @@ class InsertPostgresSimulation extends Simulation {
.columns(
column(
name("abc"),
dataType("INTEGER"),
dataType("VARCHAR(39)"),
constraint("PRIMARY KEY")
)
)
)

val fillTables = feed(uniqueNumberFeeder).repeat(100, "n") {
val fillTables = feed(uniqueValuesFeeder).repeat(100, "n") {
feed(tableIdentFeeder.iterator.toArray.random).
exec(jdbc("insertion")
.insert()
.into("bar${tableId}")
.values("${unique}${n}")
.values("'${unique}${n}'")
)
}

Expand Down

0 comments on commit 8d881bf

Please sign in to comment.