加特工具中的相关性

时间:2014-11-17 13:01:46

标签: scala automated-tests performance-testing gatling

我正在使用Gatling工具录制脚本。 我完成了录音部分。 但保存该脚本后,我无法共同处理动态值。 因为我无法找到任何编码,我可以在哪里找到左右边界并继续进行.... 所以请帮帮我 代码: -

import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._

class web_tour_2 extends Simulation {

    val httpProtocol = http
        .baseURL("http://127.0.0.1:1080")
        .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
        .acceptEncodingHeader("gzip, deflate")
        .acceptLanguageHeader("en-US,en;q=0.5")
        .connection("keep-alive")
        .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0")

    val headers_3 = Map("""Content-Type""" -> """application/x-www-form-urlencoded""")

    val scn = scenario("Scenario Name")
        //home
        .exec(http("request_1")
            .get("""/cgi-bin/welcome.pl?signOff=true"""))
        .pause(100 milliseconds)
        .exec(http("request_2")
            .get("""/cgi-bin/nav.pl?in=home"""))
        .pause(20)
        //login
        .feed(csv("login.csv"))
        .exec(http("request_3")
            .post("""/cgi-bin/login.pl""")
            .headers(headers_3)
            .param("""userSession""", """114718.724260834fQAAittpDHQVzzzHDftAfpAzzcHf""")
            .param("""username""", """${username}""")
            .param("""password""", """${password}"""))
            .param("""login.x""", """0""")
            .param("""login.y""", """0""")
            .param("""JSFormSubmit""", """off"""))
        .pause(120 milliseconds)
        .exec(http("request_4")
            .get("""/cgi-bin/nav.pl?page=menu&in=home"""))
        .pause(20 milliseconds)
        .exec(http("request_5")
            .get("""/cgi-bin/login.pl?intro=true"""))
        .pause(7)
        //flight
        .exec(http("request_6")
            .get("""/cgi-bin/welcome.pl?page=search"""))
        .pause(90 milliseconds)
        .exec(http("request_7")
            .get("""/cgi-bin/nav.pl?page=menu&in=flights"""))
        .pause(90 milliseconds)
        .exec(http("request_8")
            .get("""/cgi-bin/reservations.pl?page=welcome"""))
        .pause(17)
        //continue
        .exec(http("request_9")
            .post("""/cgi-bin/reservations.pl""")
            .headers(headers_3)
            .param("""advanceDiscount""", """0""")
            .param("""depart""", """Denver""")
            .param("""departDate""", """11/18/2014""")
            .param("""arrive""", """London""")
            .param("""returnDate""", """11/19/2014""")
            .param("""numPassengers""", """1""")
            .param("""seatPref""", """Aisle""")
            .param("""seatType""", """Business""")
            .param("""findFlights.x""", """36""")
            .param("""findFlights.y""", """16""")
            .param(""".cgifields""", """roundtrip""")
            .param(""".cgifields""", """seatType""")
            .param(""".cgifields""", """seatPref"""))
        .pause(13)
        //continue2
        .exec(http("request_10")
            .post("""/cgi-bin/reservations.pl""")
            .headers(headers_3)
            .param("""outboundFlight""", """021;437;11/18/2014""")
            .param("""numPassengers""", """1""")
            .param("""advanceDiscount""", """0""")
            .param("""seatType""", """Business""")
            .param("""seatPref""", """Aisle""")
            .param("""reserveFlights.x""", """23""")
            .param("""reserveFlights.y""", """10"""))
        .pause(13)
        //continue3
        .exec(http("request_11")
            .post("""/cgi-bin/reservations.pl""")
            .headers(headers_3)
            .param("""firstName""", """${username}""")
            .param("""lastName""", """${password}""")
            .param("""address1""", """hdfgh""")
            .param("""address2""", """5765675""")
            .param("""pass1""", """${username} ${password}""")
            .param("""creditCard""", """23gf567""")
            .param("""expDate""", """12/15""")
            .param("""saveCC""", """on""")
            .param("""oldCCOption""", """on""")
            .param("""numPassengers""", """1""")
            .param("""seatType""", """Business""")
            .param("""seatPref""", """Aisle""")
            .param("""outboundFlight""", """021;437;11/18/2014""")
            .param("""advanceDiscount""", """0""")
            .param("""returnFlight""", """""")
            .param("""JSFormSubmit""", """off""")
            .param("""buyFlights.x""", """51""")
            .param("""buyFlights.y""", """8""")
            .param(""".cgifields""", """saveCC"""))
        .pause(14)
        //logout
        .exec(http("request_12")
            .get("""/cgi-bin/welcome.pl?signOff=1"""))
        .pause(70 milliseconds)
        .exec(http("request_13")
            .get("""/cgi-bin/nav.pl?in=home"""))

    setUp(scn.inject(atOnce(1 user))).protocols(httpProtocol)
}

0 个答案:

没有答案