首页 > 学院 > 开发设计 > 正文

gatling模拟线上实际压力

2019-11-08 20:17:15
字体:
来源:转载
供稿:网友

gatling压力脚本

import io.gatling.core.PRedef._import io.gatling.http.Predef._import scala.concurrent.duration._class testapi extends Simulation {  val httpConf = http    .baseURL("http://test111.com") // Here is the root for all relative URLs    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers    .doNotTrackHeader("1")    .acceptLanguageHeader("en-US,en;q=0.5")    .acceptEncodingHeader("gzip, deflate")    .userAgentHeader("Mozilla/5.0 (linux; Android 4.4.4; en-us; Nexus 5 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2307.2 Mobile Safari/537.36")    val actions = csv("test.csv").random    val scn = scenario("testapi")        .feed(actions)        .exec(http("setting")            .get("${url}&ip=${ip}")            .check(status.is(200)))setUp(scn.inject(constantUsersPerSec(800) during(10 minutes)).protocols(httpConf))}test.csv是线上日志生成csv文件,放在user-files/data目录下,

格式为csv格式:

ip,url10.83.157.217,/api/xx?id=12310.83.157.217,/api/xx?id=45610.83.157.217,/api/xx?id=789第一行为文件每列的名称,在.get("${url}&ip=${ip}")使用。

以后的文件为url参数。


上一篇:05 单片机串口

下一篇:Add Digits

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表