Created
March 14, 2012 21:57
-
-
Save andypetrella/2039848 to your computer and use it in GitHub Desktop.
Gatling Within Play 2.0
This file contains hidden or 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
import sbt._ | |
import Keys._ | |
import PlayProject._ | |
object ApplicationBuild extends Build { | |
val appName = "gatling-play2-plugin" | |
val appVersion = "1.0" | |
/* OFFICIAL GATLING REPO */ | |
val gatlingReleasesRepo = "Gatling Releases Repo" at "http://repository.excilys.com/content/repositories/releases" | |
val gatling3PartyRepo = "Gatling Third-Party Repo" at "http://repository.excilys.com/content/repositories/thirdparty" | |
/* LOCAL MAVEN REPO for My Forked Gatling */ | |
val mavenLocal = "Local Maven Repository" at "file://"+ Path.userHome+"/.m2/repository" // NOTE :: It seems that on WINDOWS you'll have to use file:/// => 3 slashes | |
/* GATLING DEPS */ | |
val gatlingVersionNumber = "1.1" //FUTURE version that should have Akka 2.0 support ! | |
val gatlingSnapshotVersionNumber = "1.1.0-SNAPSHOT" //My version of the 1.1.0-SNAPSHOT that has rough Akka 2.0 support | |
val gatlingApp = "com.excilys.ebi.gatling" % "gatling-app" % gatlingSnapshotVersionNumber | |
val gatlingRecorder = "com.excilys.ebi.gatling" % "gatling-recorder" % gatlingSnapshotVersionNumber | |
val gatlingCharts = "com.excilys.ebi.gatling" % "gatling-charts" % gatlingSnapshotVersionNumber | |
val gatlingHighcharts = "com.excilys.ebi.gatling.highcharts" % "gatling-charts-highcharts" % gatlingSnapshotVersionNumber | |
val appDependencies = Seq( | |
gatlingApp, | |
gatlingRecorder, | |
gatlingCharts, | |
gatlingHighcharts | |
) | |
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings( | |
resolvers ++= Seq( | |
gatlingReleasesRepo, | |
gatling3PartyRepo, | |
mavenLocal | |
) | |
) | |
} |
This file contains hidden or 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
//... | |
def gatling(s:Simulation) { | |
val runInfo = new RunRecord(now, "run-test", "test") | |
new Runner(runInfo, s()).run | |
generateReports(runInfo.runUuid) | |
} | |
//... | |
private def generateReports(runUuid: String) { | |
println("Generating reports...") | |
val start = System.currentTimeMillis | |
if (ReportsGenerator.generateFor(runUuid)) { | |
println("Reports generated in " + (System.currentTimeMillis - start) / 1000 + "s.") | |
println("Please open the following file : " + activeSessionsFile(runUuid)) | |
} else { | |
println("Reports weren't generated") | |
} | |
} | |
//... |
This file contains hidden or 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
class TestStress extends Specification { | |
//define a stress test suite | |
"stress test the server" in { | |
val baseUrl = "http://localhost:3333" | |
//we'll need a server for that... FakeServer in action. And an FakeApplication that starts our additional test plugins (here Gatling) | |
running(TestServer(3333, FakeApplication(additionalPlugins = Seq("gatling.Gatling")))) { | |
//stress tests | |
SampleSimulations.simulations(baseUrl) foreach gatling | |
} | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment