Just curious where to start for load testing Thrift servers or just non http servers. Any pointers?
Thanks,
Andy
Just curious where to start for load testing Thrift servers or just non http servers. Any pointers?
Thanks,
Andy
Hi Andrew,
We have no support yet for non-HTTP protocols.
Although, we provide developers with a protocol API documented here : https://github.com/excilys/gatling/wiki/Protocol-support
It is not fully documented yet, but you’ll have the minimum required information to implement your own protocol.
If you need more information, don’t hesitate : ask here, it will allow us to improve the documentation according to your needs.
Cheers,
Romain
Word. Thanks.
-Andy
I suddenly remember that James Gregory did some good analysis of Gatling internals:
https://github.com/jagregory/gatling/blob/master/GatlingProtocolBreakdown.md
Cheers,
Stéphane
2012/7/14 Andrew Headrick <andrew.headrick@gmail.com>
I’m interested too into testing Thrift server, did you suceeded and how ?
Thanks
Hi,
I would like to know how to implement my protocol.
I do this :
class MySimulation extends Simulation {
val mine = new ActionBuilder {
def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new MyAction(next)))
}
val scn = scenario(“My own protocol”)
.repeat(2) {
exec(mine)
}
setUp(scn.inject(ramp(3 users) over (10 seconds)))
}
class MyAction(val next: ActorRef) extends Chainable {
def execute(session: Session) {
println(“whatever protocol”)
next ! session
}
}
But I have an exception :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won’t be generated
at io.gatling.charts.report.ReportsGenerator$.generateFor(ReportsGenerator.scala:41)
at io.gatling.app.Gatling.generateReports$1(Gatling.scala:155)
at io.gatling.app.Gatling.start(Gatling.scala:207)
at io.gatling.app.Gatling$.fromMap(Gatling.scala:58)
at io.gatling.app.Gatling$.runGatling(Gatling.scala:78)
at io.gatling.app.Gatling$.main(Gatling.scala:53)
at io.gatling.app.Gatling.main(Gatling.scala)
… 6 more
I have no “logrequest” as specified to documentation. My fault is probably here.
But method logrequest don’t exist in io.gatling.core.result.writer.DataWriter.
And i don’t see which method used…
Anybody knows ?
Regards,
Hi Cyril,
We have a wiki page that provides some tips for implementing your own protocol, but it targets Gatling 1: https://github.com/excilys/gatling/wiki/Protocol-support
I advise you go with Gatling 2, even if it’s not 100% stable yet, as one of the goals is to clean up our inner APIs so people can easily write their own protocols. Sadly, you’ll have to dig into the code, or just go on asking here (we’ll help for sure).
In your case, you indeed have to log some data, so that the report engine does have something to eat.
The entry point is io.gatling.core.result.writer.DataWriter.tell that re-dispatch to all registered DataWriters (Console, File, etc).
Here’s what’s being sent for HTTP: https://github.com/excilys/gatling/blob/master/gatling-http/src/main/scala/io/gatling/http/ahc/AsyncHandlerActor.scala#L153
Cheers,
Stéphane
Thanks Stéphane,
your reply is helpful.
Finally, I make this :
class OwnProtocolTest extends Simulation {
val mine = new ActionBuilder {
def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new MyAction(next)))
}
val scn = scenario(“My own protocol test”)
.repeat(2) {
exec(mine)
}
setUp(scn.inject(ramp(3 users) over (10 seconds)))
}
class MyAction(val next: ActorRef) extends Chainable {
def execute(session: Session) {
var start = nowMillis
println(“test”)
var end = nowMillis
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, “test”,
start, end, start, end,
OK, None, Nil))
next ! session
}
}
And it works
Easy!
Beware that the second Nil you’re passing disable groups.
Yep, I’m aware that I’ve disabled groups, but ‘groupStack’ of ‘session’ is private and so I can’t access it.
Except if I put my action in package io.gatling.core.action…
Do you see an another way ?
Thanks again
It no longer is in master
Great ! I hadn’t seen the 2.0.0-M2
Which gatling version does this code snippet works.
Do you have gist or git location for this code example.
class MyAction extends Chainable {
def execute(session: Session) {
var start: Long
var end: Long
var status: Status = OK
var errorMessage: Option[String] = None
try {
start = nowMillis
foo()
end = nowMillis} catch {
case e: Exception =>
errorMessage = Some(e.getMessage)
logger.error(“FOO FAILED”, e)
status = KO
} finally {
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, session.groupStack, name,
start, start, end, end,
status, errorMessage, Nil))
next ! session
}
}
}
It works with version 2.0.0-M3a
end will be 0L in case of an Exception and in case of an Exception, the session is not flagged as failed
@Cyril and Stéphane,
Thanks for your help. There were few changes to the original code, I guess they are new changes as part of 2.0.0-M3a
I have a working example in git for all to reference and contribute…
I have referenced your names in the Readme, please let me know if you have objections to it. I will remove them if you don’t want to…
https://github.com/softmentor/gatling-examples
Specific code changes, please lookup here:
https://github.com/softmentor/gatling-examples/blob/master/gatling-custom-protocol-demo/src/test/scala/custom/protocol/test/TestCustomProtocolSimulation.scala
This also demonstrates calling some Java code (apis etc).
Good idea.
Ping me when we’ll release 2M4 if you want me to update it.