这是我在scala中用于gatling的示例测试用例
val baseurl = s"http://$server:$port/$cPath"
val wsurl = s"ws://$server:$port/$cPath"
val httpProtocol = http
.baseURL(baseurl)
.inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
.acceptHeader("""*/*""")
.acceptEncodingHeader("""gzip,deflate,sdch""")
.acceptLanguageHeader("""en-US,en;q=0.8,fi;q=0.6""")
.contentTypeHeader("""application/json; charset=UTF-8""")
.userAgentHeader("""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36""")
.wsBaseURL(wsurl)
val scn = scenario("wsloadtest").group("Create Process"){exec(ws("connect")
.open(wsurl))
.exec(
ws("Suggest answer 3")
.sendText("""{"messageType":"loginMessage","channel":"3","userId":"10","timestamp":"1458459904939"}""")).pause(21474800)
};
//val sample = scenario("socket").exec()
setUp(scn.inject(
//heavisideUsers(40000) over(500)
constantUsersPerSec(50) during(400)
)).protocols(httpProtocol)
通过上面的测试,我能够在json中发送相同的userId是否有可能模拟不同用户的登录(UserId是一个很长的值,它应该是动态的..如果是的话,怎么办呢...抱歉如果问题的框架不明确..