在加特林

时间:2016-07-19 12:05:17

标签: gatling

我想通过gatling连接到Web套接字。但它没有用。套接字监听器没有任何消息。代码如下。任何人都可以提出问题吗? gatling中是否有websocket的录音选项。录音机只记录http请求。

 `val scn = scenario("RecordedSimulation")
    .exec(http("login")
               .post("/user/login")
               .formParam("email", "username")
               .formParam("password", "*******")
               .check(headerRegex("Set-Cookie", "localhost:1337.sid=(.*); Path=/").saveAs("cookie")))
    .pause(5)


    .exec(http("get sid")
        .get("/socket.io/?EIO=3&transport=polling&t=1468496890883-0")
        .headers(headers_3)
        .check(regex("\"sid\":\"(.*)\",").saveAs("sid"))
        )
    .pause(4)

    .exec(ws("Connect WebSocket").open("/socket.io/?EIO=3&transport=websocket&sid=${sid}")
         .headers(Map(
    "Accept-Encoding" -> "gzip, deflate, sdch",
    "Accept-Language" -> "en-US,en;q=0.8",
    "Pragma" -> "no-cache",
    "Host" -> "localhost:1337",
    "Cache-Control" -> "no-cache",
    "Connection" -> "Upgrade",
    "Origin" -> "http://localhost:1337",
    "Sec-WebSocket-Extensions" -> "permessage-deflate; client_max_window_bits",
    "Sec-WebSocket-Key" -> "sBWXugNrGCMSXmO3BEm4yw==",
    "Sec-WebSocket-Version" -> "13",
    "Upgrade" ->"websocket",
    "Cookie" -> "io=${sid}; __cfduid=d1cf62d5cf275e2c709080ad7610da8b61465800778; cf_clearance=42068d23995e3243b3ee748ac616389d5cc27d92-1468865525-1800; _gat=1; _ga=GA1.2.1134427855.1467369017; localhost:1337.sid=${cookie}"
    )))

    .pause(1)




    .exec(http("Run")
        .post("/posturl")
        .headers(headers_13)
        .body(RawFileBody("RecordedSimulation_0013_request.txt")))

    .exec(ws("Set Check for instance ID")
          .check(wsAwait.within(30).until(1).regex("\"intInstanceID\":\"(.*-.*-.*-.*-.*)\",").saveAs("instanceID")))
    .pause(1)

    .exec(ws("Say Hello WS")
        .sendText("""{"text": "Hello, I'm ${sid}"}"""))

    .exec( session =>{
        println(session("cookie").as[String])
        session
        })




setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

}`

1 个答案:

答案 0 :(得分:0)

您没有说明您的预期传入消息与其他操作有何关联,但要注意我们当前没有缓冲不匹配的传入消息。 因此,如果在您实际设置支票之前收到消息,则会丢失。

如果您对WebSocket负载测试的使用有一些反馈,请在我们的邮件列表中分享和讨论。有ongoing effort to redesign WebSocket support for Gatling 3