如何在加特林模拟中运行多个空手道特征文件?



如何在加特林模拟中运行多个空手道特征文件?

以下是我的加特林模拟的代码片段:

class TestGatlingScalaSimulation extends Simulation {
val log: Logger = LoggerFactory.getLogger(classOf[TestGatlingScalaSimulation])
/*val environmentVars = System.getenv().asScala
for ((k,v) <- environmentVars) println(s"key: $k, value: $v")*/
val properties: mutable.Map[String, String] = System.getProperties.asScala
//for ((k,v) <- properties) println(s"key: $k, value: $v")
val activeUsers: Int = properties.getOrElse("SIM_ACTIVE_USERS", "10").asInstanceOf[String].toInt
val rampUpPeriod: Int = properties.getOrElse("SIM_RAMP_UP_PERIOD", "10").asInstanceOf[String].toInt
val karateFeatureFile: String = properties.getOrElse("SIM_FEATURE", "karate/example.feature")
val protocol: KarateProtocol = karateProtocol()
protocol.nameResolver = (req, ctx) => req.getHeader("karate-name")
val create: ScenarioBuilder = scenario("create").exec(karateFeature(s"classpath:$karateFeatureFile"))
log.info("Running simulation of feature [{}] with [{}] users ramped up in [{}]", karateFeatureFile, activeUsers.toString, rampUpPeriod.toString)
setUp(
create.inject(rampUsers(activeUsers) during (rampUpPeriod seconds)).protocols(protocol)
)
}

我每次只能像这样运行一个功能文件:

./gradlew -Pgatling_simulation=performance.TestGatlingScalaSimulation -DSIM_ACTIVE_USERS=100 -DSIM_RAMP
_UP_PERIOD=10 -DSIM_FEATURE="karate/flight/myfeature.feature" gatlingRun

这在文档中有明确的描述: https://github.com/intuit/karate/tree/master/karate-gatling#usage

val create = scenario("create").exec(karateFeature("classpath:mock/cats-create.feature"))
val delete = scenario("delete").exec(karateFeature("classpath:mock/cats-delete.feature@name=delete"))
setUp(
create.inject(rampUsers(10) during (5 seconds)).protocols(protocol),
delete.inject(rampUsers(5) during (5 seconds)).protocols(protocol)
)

最新更新