Skip to content

Instantly share code, notes, and snippets.

@robzienert
Last active December 29, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robzienert/b84c8f9bb35f71f11e32 to your computer and use it in GitHub Desktop.
Save robzienert/b84c8f9bb35f71f11e32 to your computer and use it in GitHub Desktop.
class GatlingRunnerProxy(test: Test) {
def run(): Int = {
Gatling.fromMap(getGatlingProperties)
}
def getGatlingProperties(): mutable.Map[String, Any] = {
val cwd: String = System.getProperty("user.dir")
// val isLocal: Boolean = Files.exists(Paths.get("${cwd}/build.gradle"))
val isLocal: Boolean = true
val simulation = configuration.core.baseSimulationPackage + "." + test.simulationName
val dataDir = if (isLocal) "${cwd}/src/main/resources/data" else "${cwd}/user-files/data"
val reqBodiesDir = if (isLocal) "${cwd}/src/main/resources/request-bodies" else "${cwd}/user-files/request-bodies"
val simulationsDir = if (isLocal) "${cwd}/src/main/scala/com/bloomhealthco/simulations" else "${cwd}/user-files/simulations"
mutable.Map[String, Any](
CONF_CORE_DIRECTORY_DATA -> dataDir,
CONF_CORE_DIRECTORY_REQUEST_BODIES -> reqBodiesDir,
// TODO Put this into the core configuration:
CONF_CORE_DIRECTORY_SIMULATIONS -> simulationsDir,
CONF_CORE_DIRECTORY_RESULTS -> "${cwd}/reports/gatling",
CONF_CORE_SIMULATION_CLASS -> simulation
)
}
}
class Runner(test: Test) extends Logging {
def run: Test = {
val eventPublisher = new EventPublisher()
eventPublisher.subscribe(new IPerfSubscriber())
test.eventSubscribers.foreach(s => eventPublisher.subscribe(s))
eventPublisher.send(PreTest(test))
logger.info(s"Test ${test.name} started...")
test.validate
test.listTiers(configuration.test.skipToTierSize).takeWhile(_ => test.failed == false).foreach { tier =>
logger.info(s"Running ${tier}")
test.tierUp
eventPublisher.send(PreTier(test, tier))
new GatlingRunnerProxy(test).run
eventPublisher.send(PostTier(test, tier))
}
eventPublisher.send(PostTest(test))
test
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment