gatling

How to dynamically generate JSon in Gatling?

我怕爱的太早我们不能终老 提交于 2019-12-02 05:13:56
问题 I have the following two methods: def randomStartMethod() : Long = { var range = 1000L var r = ThreadLocalRandom.current().nextLong(10L*range) var randomStart = 1396024675000L + r return randomStart } def randomStopMethod() : Long = { var range = 1000L val r = ThreadLocalRandom.current().nextLong(10L*range) val randomStop = 1396024675000L + r*2L return randomStop } Then I add it to the request body like this: val activity = repeat(10, "i") { exec(http("POST activity post") .post("/activity/")

性能测试之Gatling

孤街醉人 提交于 2019-12-01 23:07:28
在应用程序上线之前,有多少人做过性能测试? 估计大部分开发者更多地关注功能测试,并且会提供一些单元测试和集成测试的用例。然而,有时候性能漏洞导致的影响比未发现的业务漏洞更严重,因为性能漏洞影响的是整个系统,而不仅仅是一个业务进程。 可能你们很多人听过 JMeter ,但是今天将介绍有竞争力的解决方案 —— Gatling 。它能生成丰富多彩的报告,包含测试案例中收集的所有指标。该功能似乎比 JMeter 更好。 在讨论 Gatling 之前,先了解下理论知识,性能测试的两种类型,负载测试和压力测试: 负载测试(Load Testing):负载测试是一种主要为了测试软件系统是否达到需求文档设计的目标,譬如软件在一定时期内,最大支持多少并发用户数,软件请求出错率等,测试的主要是软件系统的性能。 压力测试(Stress Testing):压力测试主要是为了测试硬件系统是否达到需求文档设计的性能目标,譬如在一定时期内,系统的cpu利用率,内存使用率,磁盘I/O吞吐率,网络吞吐量等,压力测试和负载测试最大的差别在于测试目的不同。 Gatling 简介 Gatling 是一个功能强大的负载测试工具。它是为易用性、可维护性和高性能而设计的。 开箱即用,Gatling 带有对 HTTP 协议的出色支持,使其成为负载测试任何 HTTP 服务器的首选工具。由于核心引擎实际上是协议不可知的

Gatling - dynamic feed selection

南笙酒味 提交于 2019-12-01 19:01:46
Here is what I NEED to do: .feed("users.csv") // includes username, password, groupid // login... .duration(x) { feed( csv("${groupid}.csv").random ) // interact with the application using the data in the second .csv file } But of course, the csv() function takes a string, not an EL expression. I need to be able to compose that string at the appropriate moment in the scenario execution. I am able to build the string, like so: .exec( session => { feed( csv( session.getAttribute("groupid") + ".csv" ).random ) session }) But unfortunately, the following execs don't see the data. It looks like

超实用!性能测试之压力工具

陌路散爱 提交于 2019-11-30 14:07:03
超实用!性能测试之压力工具 发表于:2017-7-12 14:19 作者:一片菜地 来源:博客 字体: 大 中 小 | 上一篇 | 下一篇 | 打印 | 我要投稿 | 推荐标签: 性能测试工具 软件测试工具   想要做 性能测试 ,那必须得先从工具入手,针对目前市场上几款主流的压力工具,介绍一下。    商业工具:    HP LoadRunner : 这个工具放在第一个说,是因为早些年做性能测试的时候,基本市场上都是使用这个工具。LR工具功能齐全,对于复杂场景的处理能力和对结果数据的分析能力比较不错。但是呢,这个工具安装包就差不多1GB。光安装就要很久,在老的电脑上运行起来还不堪重负。因为是商业软件,是通过不同的协议的license 来购买,但除了一些银行,大型企业买,其余一些基本都是使用65536全协议的破解版本了。    开源工具:    Jmeter : 随着互联网+的飞速发展,这个开源工具是 互联网 性能测试的最常用工具。基本上取代了loadrunner的地位,随着对JMeter使用的不断深入,我个人越来越倾向于在自己的 工作 中使用JMeter工具,并且也会不遗余力的向我认识的测试工程师推荐它。   1、它是开源的,安装及其简单,只需要提前安装JDK,把jmeter文件包解压就可使用。   2、可以通过各种逻辑控制器的组合来实现比较复杂的测试场景

Gatling - execute scenarios sequentialy

柔情痞子 提交于 2019-11-29 14:31:42
When I run code like: setUp( scenario1.inject(constantUsersPerSec(1) during (1 second)), scenario2.inject(constantUsersPerSec(1) during (1 second)) ).protocol() Both scenarios are started at once. What need to be changed to run it one by one? You could start the second scenario with a "nothingFor" injection step setUp( scenario1.inject(constantUsersPerSec(1) during (1 second)), scenario2.inject(nothingFor(1 second) , constantUsersPerSec(1) during (1 second)) ).protocol() If you want to have a guaranteed sequential execution, you have to put the chains of both scenarios into a new scenario. var

Jenkins job failure when running a freestyle maven-gatling project

半城伤御伤魂 提交于 2019-11-28 11:49:23
问题 I have created a gatling maven based application; wrote some actions, scenario and able to successfully run them locally in IDE using $mvn gatling:test to build project and view the gatling reports. Now I'm trying to have a jenkins job configured to automate this however using the same command in bash script is failing with : Build step 'Execute shell' marked build as failure Archiving Gatling reports... Could not find a Gatling report in results folder. My pom.xml is same as :https://github

Gatling初次体验

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 22:57:14
主要步骤: 1. 利用springboot编写了一个简单的服务jdktest 2.将jdktest利用docker在虚拟机中启动 3.创建一个scala工程,利用gatling提供的DSL编写性能脚本 4.执行并查看报告 1.编写jdktest服务 接口名称:/common/check 1 参数:一个User对象 2 3 格式: json 4 5 响应: 7 年龄小于等于30,结果:{"code":200,"msg":"success","data":{"name":"hello","age":18}} 8 年龄大于30,结果:{"code":400,"msg":"年龄大于30","data":{"name":"hello","age":50}} 2.部署服务 将jdktest打成jar包,并上传到服务器(我这里是虚拟机,并且已经安装了docker)上,在jar同级目录下创建Dockerfile FROM primetoninc/jdk:1.8 MAINTAINER 3404924705@qq.com ADD jdktest-0.0.2-SNAPSHOT.jar /usr/local/jdktest/ RUN mkdir /usr/local/jdktest/log RUN chmod -R 755 /usr/local/jdktest WORKDIR /usr/local