-
-
Save robzienert/b84c8f9bb35f71f11e32 to your computer and use it in GitHub Desktop.
This file contains 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 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 | |
) | |
} | |
} |
This file contains 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 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