2016-03-01 9 views
0

Я создал файл build.gradle, и в нем у меня есть этот dep. компиляции 'io.gatling.highcharts: Гатлинга-чарты-Highcharts: 2.1.7'Запуск gatlingtest от gradle

Я также создал имитацию

package simulations 

import io.gatling.core.Predef._ 
import io.gatling.http.Predef._ 
import scala.concurrent.duration._ 


class LukeSimulation extends Simulation { 

    val httpConf = http 
    .baseURL("http://--------:8295/") // Here is the root for all relative URLs 
    .doNotTrackHeader("1") 
    .acceptLanguageHeader("en-US,en;q=0.5") 
    .acceptEncodingHeader("gzip, deflate") 
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0") 

    val headers_10 = Map("Content-Type" -> "application/x-www-form-urlencoded") // Note the headers specific to a given request 

    val scn = scenario("TotalUsage") // A scenario is a chain of requests and pauses 
    .exec(http("Usage") 
     .get("/api/v1/account/10186413349/totalusage")) 

    setUp(scn.inject(atOnceUsers(700), 
        rampUsers(100000) over(30 minutes), 
        constantUsersPerSec(200) during(10 minutes), 
        rampUsersPerSec(200) to(1000) during(10 minutes) 
        ).protocols(httpConf)) 
    //setUp(scn.inject(rampUsers(500) over(30 seconds)).protocols(httpConf)) 
    //assertThat(global.failedRequests.count.is(0)) 

} 

Как я выполнить его с Gradle?

ответ

0

Создать задачу, как это -

task gatling() << { 
    javaexec { 
     main = 'io.gatling.app.Gatling' 
     classpath = sourceSets.test.runtimeClasspath 
     args('--simulation', 
       "simulations.LukeSimulation", 
       '--results-folder', 
       file('build/reports/gatling').absolutePath, 
       '--mute') 
     environment(['appUrl': appUrl]) 
     systemProperties(['gatling.core.directory.binaries': sourceSets.test.output.classesDir]) 
    } 
} 

Если вы хотите передать параметр в ваш Гатлинг вы можете сделать этот путь.

def getAppUrl() { 
    def appUrl = System.getProperty('appUrl') 
    appUrl ?: 'http://localhost:8295' 
} 

Команда будет gradle gatling -DappUrl=http://localhost:8000

Если вы не сдали appUrl тогда он будет по умолчанию, что написано в методе getAppUrl.

Чтобы использовать свойство в коде Гатлинга это сделать

val appUrl = getenv("appUrl") 
Смежные вопросы