Hi,
I’m new to scala and gatling but I am trying to load test an existing neo4j dB with gatling by doing the following:
- Create a node with a UUID
- Create another node with a UUID
- Create a relationship between the two nodes by matching on the UUID
repeat…
I tried to do this using the following method:
package neo_test
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import akka.util.duration._
import bootstrap._
import util.parsing.json.JSONObject
class testSession1 extends Simulation{
val httpConf = httpConfig
.baseURL(“http://localhost:7474”)
.acceptHeader(“application/json”)
.requestInfoExtractor(request => {
println(request.getStringData)
Nil
})
// Create node1 UUID.
val createNode1UUID = exec((session) => {
session.setAttribute(“node1_uuid”, java.util.UUID.randomUUID.toString)
})
// Create node2 UUID.
val createNode2UUID = exec((session) => {
session.setAttribute(“node2_uuid”, java.util.UUID.randomUUID.toString)
})
// Create node1’s
val createNode1s = exec(createNode1UUID)
.exec((session) => {
session.setAttribute(
“node1_params”, JSONObject(
Map(
“UUID” → session.getAttribute(“node1_uuid”),
“nodeType” → “Node1”,
“other” → “null”
)
))
})
// Create node2’s
val createNode2s = exec(createNode2UUID)
.exec((session) => {
session.setAttribute(
“node2_params”, JSONObject(
Map(
“UUID” → session.getAttribute(“node2_uuid”),
“nodeType” → “Node2”,
“other” → “null”
)
))
})
val node1 = “{“params”: %s}”.format("${node1_params}")
val node2 = “{“params”: %s}”.format("${node2_params}")
val relationship = “{“uuidA”: “%s”,“uuidB”: “%s”,“relationship”: “knows”}”.format("${node1_uuid}", “${node2_uuid}”)
val scn = scenario(“Create Stuff”)
.during(1) {
exec(createNode1s)
.exec(
http(“create node1s”)
.post("/example/specialservice/createnode")
.header(“X-Stream”, “true”)
.body(node1)
.asJSON
.check(status.is(201))
)
.pause(0 milliseconds, 10 milliseconds)
.exec(createNode2s)
.exec(
http(“create node2s”)
.post("/example/specialservice/createnode")
.header(“X-Stream”, “true”)
.body(node2)
.asJSON
.check(status.is(201)))
.pause(0 milliseconds, 10 milliseconds)
.exec(createNode1UUID, createNode2UUID)
.exec(
http(“create relationships”)
.post("/example/specialservice/createrelationship")
.header(“X-Stream”, “true”)
.body(relationship)
.asJSON
.check(status.is(204)))
.pause(0 milliseconds, 10 milliseconds)
}
setUp(
scn.users(1).ramp(1).protocolConfig(httpConf)
)
}
However the relationship creation fails because the UUID’s have changed from the ones used to create the nodes. Am I completely barking up the wrong tree or is there any way of doing this?
Thanks for your help,
Ian