使用Gradle插件运行多个模拟的Gatling

使用Gradle插件运行多个模拟的Gatling,gradle,gatling,Gradle,Gatling,Gradle插件(,v2.1)声称能够为每个Gradle项目配置多个模拟 给定以下渐变文件: apply plugin: 'scala' group '****' version '1.0-SNAPSHOT' buildscript { repositories { jcenter() } dependencies { classpath 'com.commercehub:gatling-gradle-plugin:2.1'

Gradle插件(,v2.1)声称能够为每个Gradle项目配置多个模拟

给定以下渐变文件:

apply plugin: 'scala'

group '****'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.commercehub:gatling-gradle-plugin:2.1'
    }

}

repositories {
    jcenter()
}

ext {
    SCALA_VERSION = "2.11.7"
    GATLING_VERSION = "2.2.3"
}

dependencies {
    compile "org.scala-lang:scala-library:${SCALA_VERSION}"

    testCompile 'com.typesafe:config:1.3.1'
    testCompile "io.gatling.highcharts:gatling-charts-highcharts:${GATLING_VERSION}"
    testCompile "io.gatling:gatling-test-framework:${GATLING_VERSION}"
}


apply plugin: 'gatling'

import com.commercehub.gradle.plugin.GatlingTask
task loadTest(type: GatlingTask, dependsOn: ['testClasses']) {
    gatlingSimulation = 'HealthSimulation,PlaceAttributesSimulation'
    jvmOptions {
        jvmArgs = [
            "-Dlogback.configurationFile=${logbackGatlingConfig()}",
            "-Denv=${System.getProperty('env', 'stg')}",
        ]
        minHeapSize = "1024m"
        maxHeapSize = "1024m"
    }
}

def logbackGatlingConfig() {
    return sourceSets.test.resources.find { it.name == 'logback-gatling.xml' }
}
特别是行
gatlingSimulation='healthmulation,placeattributesimulation'
,我希望两个模拟都能运行。为什么?因为查看Gradle插件,
gatlingSimulation
随后被传递给Gatling
-s
标志

长话短说,Gatling
-s
不再支持多个模拟(请参阅以了解详细信息),因此我认为我在用于启用多个模拟的gradle插件中缺少了一点

单独运行时,两个模拟都运行良好,但如果我尝试将它们一起运行,Gatling stucks会询问执行哪一个。有没有建议如何在同一个gradle项目中实现多个模拟(顺序)的运行

编辑:我目前的难看解决方案(欢迎您提出建议,让它变得不那么难看,但仍然是imo的解决方案)是使用以下内容修改Gradle构建文件:

task loadTests;
fileTree(dir: 'src/test').include("**/*Simulation.scala").each {target ->

    ext {
        filename = target.toString()
        filename = filename.substring(filename.indexOf("scala") + "scala".length() + 1)
        filename = filename.substring(0, filename.indexOf(".")).replaceAll("/", ".")
    }

    task("loadTest${filename}", type: GatlingTask, dependsOn: 'testClasses', description : "Load test ${filename}s") {
        gatlingSimulation = filename
        jvmOptions {
            jvmArgs = [
                "-Dlogback.configurationFile=${logbackGatlingConfig()}",
                "-Denv=${System.getProperty('env', 'stg')}",
            ]
            minHeapSize = "1024m"
            maxHeapSize = "1024m"
        }
    }
    loadTests.dependsOn("loadTest${filename}")
}

def logbackGatlingConfig() {
    return sourceSets.test.resources.find { it.name == 'logback-gatling.xml' }
}

基本上,我为每个
*模拟.scala
文件(命名约定)创建一个
GatlingTask
,然后创建一个批量
loadTests
任务,该任务取决于所有人。

这是一个已解决的问题还是仍未解决?我想说未解决。在过去的2年中,我没有编写任何性能测试,我描述的是我在这个被遗忘的原型中最终得到的解决方案使用gradle插件,正如这里所解释的,可以是一个解决方案,它可以运行多个模拟