tsung: an open-source multi-protocol distributed load testing tool
ROPERTIES:
:type: KnowledgeBase_Cloud
:END:
- 开源、多协议、分布式的压力测试工具
Item | Summary |
---|---|
tsung-recorder start | 通过proxy来录音http的测试脚本 |
tsung start | 启动tsung测试 |
/usr/local/lib/tsung/bin/tsung_stats.pl | 针对测试后的log, 生成报表 |
/usr/lib/tsung/bin/tsung_stats.pl | 针对测试后的log, 生成报表 |
ls /usr/lib/erlang/lib/tsung-1.4.1/src | tsung sourcecode location after installation |
插件实现 –> get_message | builds the actual data to be transmitted to the server. |
插件实现 –> parse | deals with server responses |
插件实现 –> ts_mon | 维护各类计数器 |
Table Of Content
- 1 basic use
- 2 tsung的工作原理
- 3 Main features
- 4 useful link
- 5 重要网页
- 6 Tsung programming model
- 7 # –8<————————– §separator§ ————————>8–
- 8 Trouble shooting
- 9 tsung report
- 10 tsung给出更多信息: dumptraffic=”true”
- 11 tsung自定义tsung.xml的位置: tsung -f … start
- 12 # –8<————————– §separator§ ————————>8–
- 13 Tsung设置测试的最大时间
- 14 Tsung对mysql测试中的变量替换问题
- 15 Tsung session中的request进行模块化的处理, 用以提高测试的复用性
- 16 如何替换Tsung中某个erlang的代码实现, 从而方便调试
- 17 Tsung中支持变量
- 18 Tsung的mysql测试
- 19 User agent连接的浏览器类型, 需要本地包含的吗: 只是模拟, 将该fake信息告诉给远端服务器而已
- 20 tsung在做load test的同时验证测试结果: 从插件的实现来看, 部分结果可以验证
- 21 Tsung的thrift接口: 通过thrift php构造成http请求即可
- 22 Tsung的测试不能并发的问题: 给erlang vm不同的node name
- 23 tsung get unique id: ts_user_server:get_unique_id, random
- 24 服务器监控(CPU, 内存, 网络流量), 支持SNMP, Erlang, MUnin方式
- 25 http测试时bypass, 用户名和密码的认证: 通过regexp来获取http返回的sessionid, 然后通过tsung的add_cookie强制设置cookie
- 26 check server response: match
- 27 mac install tsung
- 27.1 brew install tsung
- 27.2 brew install graphviz
- 27.3 mkdir ~/.tsung/
- 27.4 cp usr/local/Cellar/tsung/1.4.2/share/doc/tsung/examples/http_simple.xml ~.tsung/tsung.xml
- 27.5 tsung start -f ~/.tsung/tsung.xml
- 27.6 /usr/local/lib/tsung/bin/tsung_stats.pl
- 27.7 web page: tsung生成压力测试报告时报错Can’t locate Template.pm解决 | IT动物园
- 28 tsung random
- 29 tsung.xml A dynamic variable can be generated by dynamic evaluation of erlang code
1 basic use
tsung 采用了巧妙的 proxy 方式来“录制”测试脚本。具体来说,就是建立一个本机的 http proxy 默认 使用 8090 端口,在配好 firefox 使用 localhost 8090 作为代理之后,所有“流经”这个 proxy 的 http 动作都会被记录下来,测试时可以“回放”这些步骤来产生请求。
2 tsung的工作原理
- Tsung的每一个虚拟用户就是一个erlang的轻量进程。这点和loadrunner有很大的区别。
- 虚拟用户完成session后就消失。
- 大量的虚拟用户(erlang轻量进程)建立在erlangVM上
- 一台测试机可以启多个erlangVM,目前按照1个cpu启动1个erlangVM
- 每个虚拟机下有很多用户,每个用户可以产生很多session,一个session由很多request组成
- 分布式部署Tsung在运行时,会产生ssl_esock、beam、beam.smp3种进程
ssl-esock是erlangVM用的port程序, 协助完成ssh功能;beam是单处理器版本的erlangVM;beam.smp就是control程序,负责协调系统的运作。
3 Main features
- High Performance: the load can be distributed on a cluster of client machines
- Multi-protocols using a plugin system: HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and XMPP/Jabber are currently supported. SSL is also supported.
- Several IP addresses can be used on a single machine using the underlying OS IP Aliasing
- OS monitoring (CPU, memory and network traffic) using SNMP, Munin or Erlang agents on remote servers.
- XML configuration system; several sessions can be used to simulate different type of users. Dynamic sessions can be easily described in XML (this can be used to retrieve at runtime an ID from the server output and use it later in the session).
- In order to generate a realistic traffic, user think-times and the arrival rate can be randomize using a probability distribution
- HTML reports can be generated during the load to view response times measurement, server CPU, etc.
4 useful link
5 重要网页
5.1 web page: tsung安装与使用 » Taobao QA Team
http://qa.taobao.com/?p=8122\\
5.2 web page: Tsung, open source Load Testing
http://loadstorm.com/2008/tsung-open-source-load-testing\\
5.3 web page: Writing a Tsung plugin | Process-one
http://www.process-one.net/en/wiki/Writing_a_Tsung_plugin/\\
6 Tsung programming model
6.1 maxusers参数: 决定一个节点能够支持的最多虚拟用户数。
超过该数后, 会自动开启更多的节点。
6.2 IP别名技术, 模拟多个机器
- 方便服务器作为loadbalance
- 解决单个IP的端口65535问题
6.3 Weight参数: 决定了每个节点上面用户的比例
6.4 DONE Tsung Transaction
CLOSED: 2011-12-20 17:07
http://tsung.erlang-projects.org/user\_manual.html#htoc37
A transaction is just a way to have customized statistics. Say if you want to know the response time of the login page of your website, you just have to put all the requests of this page (HTML + embedded pictures) within a transaction. In the example above, the transaction called index_request will gives you in the statistics/reports the mean response time to get index.en.html + header.gif. Be warn that If you have a thinktime inside the transaction, the thinktime will be part of the response time.
7 # –8<————————– §separator§ ————————>8–
8 Trouble shooting
8.1 DONE tsung client中host应该是可达的hostname, 否则会出现Can’t start newbeam
CLOSED: 2011-12-20 15:35
http://tsung.erlang-projects.org/user\_manual.html#htoc80
<clients> <client host="ecae-test-denny" cpu="2" weight="2" maxusers="100"> <ip scan="true" value="eth0"/> </client> </clients>
9 tsung report
报告中的几个相似概念: request:类似用php函数file_get_contents请求一个url地址的相应时间 page:一组没有间隔的request请求的时间总和,相当于打开一个页面,除了加载页面的html外,还要加载img、css、js等 session:一个用户从第一个请求开始到最后一个请求结束的时间总和
10 DONE tsung给出更多信息: dumptraffic=”true” IMPORTANT
CLOSED: 2011-12-21 21:02
<?xml version="1.0"?> <!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd"> <tsung loglevel="debug" dumptraffic="true" version="1.0"> <clients> <client host="ecae-test-denny" cpu="2" weight="2" maxusers="1000"> <ip scan="true" value="eth0"/> </client> </clients> ...
11 DONE tsung自定义tsung.xml的位置: tsung -f … start
CLOSED: 2011-12-22 17:22
12 # –8<————————– §separator§ ————————>8–
13 DONE Tsung设置测试的最大时间
CLOSED: 2011-12-20 15:53
http://tsung.erlang-projects.org/user\_manual.html#htoc37
<load duration="1" unit="hour"> <arrivalphase phase="1" duration="10" unit="minute"> <users interarrival="2" unit="second"></users> </arrivalphase> </load>
14 DONE Tsung对mysql测试中的变量替换问题
CLOSED: 2011-12-22 17:22
authenticate类型中的变量无法进行替换; 而sql类型中的变量可以进行替换 如果将下面tsung.xml的line 55换成line 54, 那么从生成tsung.dump可以看出%%_db_name%%,没有被替 换, 从而导致认证失败。
14.1 tsung.xml
01 <?xml version="1.0"?> 02 <!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd"> 03 <tsung loglevel="debug" dumptraffic="true" version="1.0"> 04 <clients> 05 <client host="ecae-test-denny" cpu="2" weight="2" maxusers="1000"> 06 <ip scan="true" value="eth0"/> 07 </client> 08 </clients> 09 10 <servers> 11 <server host="ecae-test-denny" port="3306" type="tcp"/> 12 </servers> 13 14 <monitoring> 15 <monitor host="ecae-test-denny" type="erlang"/> 16 </monitoring> 17 18 <load duration="15" unit="second"> 19 <arrivalphase phase="0" duration="1" unit="minute"> 20 <users arrivalrate="200" unit="second"/> 21 </arrivalphase> 22 <arrivalphase phase="1" duration="1" unit="minute"> 23 <users arrivalrate="350" unit="second"/> 24 </arrivalphase> 25 <arrivalphase phase="2" duration="1" unit="minute"> 26 <users arrivalrate="1000" unit="second"/> 27 </arrivalphase> 28 <arrivalphase phase="3" duration="1" unit="minute"> 29 <users arrivalrate="800" unit="second"/> 30 </arrivalphase> 31 <arrivalphase phase="4" duration="1" unit="minute"> 32 <users arrivalrate="2000" unit="second"/> 33 </arrivalphase> 34 </load> 35 36 <options> 37 <option name="file_server" id="rdc_test_account" value="/root/.tsung/testcase/rdc/rdc_test_account.csv"/> 38 </options> 39 40 <sessions> 41 <session probability="100" name="mysql-example" type="ts_mysql"> 42 <request> 43 <mysql type="connect" /> 44 </request> 45 <setdynvars sourcetype="file" fileid="rdc_test_account" delimiter=";" order="random"> 46 <var name="db_name" /> 47 <var name="user_name" /> 48 <var name="user_password" /> 49 </setdynvars> 50 <setdynvars sourcetype="random_number" start="3" end="32"> 51 <var name="rndint" /> 52 </setdynvars> 53 <request subst="true"> 54 <!-- <mysql type="authenticate" database="%%_db_name%%" username="admin" password="" /> --> 55 <mysql type="authenticate" database="test" username="admin" password="" /> 56 </request> 57 <setdynvars sourcetype="random_string" length="13"> 58 <var name="rndstring1" /> 59 </setdynvars> 60 <request subst="true"> 61 <mysql type="sql">select "%%_rndstring1%%" </mysql> 62 </request> 63 <request> 64 <mysql type="close"></mysql> 65 </request> 66 </session> 67 </sessions> 68 </tsung>
14.2 rdc_test_account.csv
test;u_2102;5i04bg2kc9n1
15 DONE Tsung session中的request进行模块化的处理, 用以提高测试的复用性
CLOSED: 2011-12-20 17:19
Sample:
<?xml version="1.0"?> <!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd" [ <!ENTITY user_load SYSTEM "/root/.tsung/user_load.xml"> <!ENTITY ecstore_session SYSTEM "/root/.tsung/testcase/ecstore/tsung_recorder_ecstore-simple.xml"> ]> <tsung loglevel="notice" version="1.0"> <clients> <client host="ecae-test-denny" cpu="2" weight="2" maxusers="1000"> <ip scan="true" value="eth0"/> </client> </clients> <servers> <server host="ecstore-test.ecae.local" port="8000" type="tcp"/> </servers> &user_load; <options> <option type="ts_http" name="user_agent"> <user_agent probability="80">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21</user_agent> <user_agent probability="20">Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4</user_agent> </option> <option name="file_server" id="ecstore_search" value="/root/.tsung/testcase/ecstore/list_search.csv"/> </options> &ecstore_session; </tsung>
16 DONE 如何替换Tsung中某个erlang的代码实现, 从而方便调试 IMPORTANT
CLOSED: 2011-12-21 21:02
在源代码处
make /bin/cp -rf ./ebin/ts_config_mysql.beam /usr/lib/erlang/lib/tsung_controller-1.4.1/ebin/ts_config_mysql.beam /bin/cp -rf ./ebin/ts_config.beam /usr/lib/erlang/lib/tsung_controller-1.4.1/ebin/ts_config.beam
17 DONE Tsung中支持变量
CLOSED: 2011-12-21 13:42
http://tsung.erlang-projects.org/user\_manual.html#htoc62
Tsung User’s manual
http://tiandiou.blog.163.com/blog/static/2355668220115392725727/
压力测试工具tsung用法简介 – 老鳖的日志 – 网易博客
添加请求的变量,在压力测试的过程中,可能需要手机号,用户ID、股票代码之类的变量,tsung支持文件随机读取,可以将这些参数按照一定的规则写入文件,在配置文件中定义读取的规则,就能在请求时拿到文件的内容。定义一个文件服务: <options> <option name="file_server" id="file1" value="/tmp/x.txt"/> </options> 读取,在session段中加入 <setdynvars sourcetype="file" fileid="file1" delimiter=";" order="random"> <var name="username" /> </setdynvars> <request> <http url="/b.php?username=%%_username%%" method="GET" version="1.1"></http> </request> 除了从文件读取,也可以随机产生 <setdynvars sourcetype="random_string" length="13"> <var name="rndstring1" /> </setdynvars> <setdynvars sourcetype="random_number" start="3" end="32"> <var name="rndint" /> </setdynvars>
18 DONE Tsung的mysql测试
CLOSED: 2011-12-20 18:01
http://tsung.erlang-projects.org/user\_manual.html#htoc59
For MySQL, 4 types of requests are available (same as PostgreSQL): 1. connect (to a given database with a given username 2. authenticate (with password or not) 3. sql 4. close This example shows most of the features of a MySQL session: <session probability="100" name="mysql-example" type="ts_mysql"> <request> <mysql type="connect" /> </request> <request> <mysql type="authenticate" database="test" username="test" password="test" /> </request> <request> <mysql type="sql">SHOW TABLES</mysql> </request> <request> <mysql type="sql">SELECT * FROM mytable</mysql> </request> <request> <mysql type="close" /> </request> </session>
19 DONE User agent连接的浏览器类型, 需要本地包含的吗: 只是模拟, 将该fake信息告诉给远端服务器而已
CLOSED: 2011-12-25 21:45
20 CANCELED tsung在做load test的同时验证测试结果: 从插件的实现来看, 部分结果可以验证
CLOSED: 2011-12-25 21:45
21 CANCELED Tsung的thrift接口: 通过thrift php构造成http请求即可 IMPORTANT Misc
CLOSED: 2011-12-26 11:27
22 DONE Tsung的测试不能并发的问题: 给erlang vm不同的node name
CLOSED: 2011-12-26 15:14
use the -i <id> option to set a unique id for each instance
tsung -f examples/file1.xml -i 1234 start
tsung -f examples/file2.xml -i 1235 start
22.1 useful link
http://lists.process-one.net/pipermail/tsung-users/2009-October/001328.html
[Tsung] Tsung 1.3.1. Instances in parallel?
http://lists.process-one.net/pipermail/tsung-users/2009-April/001236.html
[Tsung] Can’t run multiple tsung controllers in parallel
23 DONE tsung get unique id: ts_user_server:get_unique_id, random
CLOSED: 2011-12-28 16:26
,----------- ts_user_server:get_unique_id | <setdynvars sourcetype="erlang" callback="ts_user_server:get_unique_id"> | <var name="ran_num" /> | </setdynvars> `----------- ,----------- random_number | <setdynvars sourcetype="random_number" start="1" end="100000"> | <var name="ran_num"/> | </setdynvars> `-----------
24 DONE 服务器监控(CPU, 内存, 网络流量), 支持SNMP, Erlang, MUnin方式
CLOSED: 2011-12-27 18:57
25 DONE http测试时bypass, 用户名和密码的认证: 通过regexp来获取http返回的sessionid, 然后通过tsung的add_cookie强制设置cookie
CLOSED: 2012-02-06 15:31
- sample: tsung-1.4.1/examples/http_setdynvars.xml
- link: http://tsung.erlang-projects.org/user\_manual.html#htoc66
26 check server response: match
http://tsung.erlang-projects.org/user\_manual.html
6.7.4 Checking the server’s response With the tag match in a request tag, you can check the server’s response against a given string, and do some actions depending on the result. In any case, if it matches, this will increment the match counter, if it does not match, the nomatch counter will be incremented. For example, let’s say you want to test a login page. If the login is ok, the server will respond with Welcome ! in the HTML body, otherwise not. To check that: <request> <match do="continue" when="match">Welcome !</match> <http url='/login.php' version='1.0' method='POST' contents='username=nic&user_password=sesame' content_type='application/x-www-form-urlencoded' > </request> You can use a regexp instead of a simple string. The list of available actions to do is: * continue: do nothing, continue (only update match or nomatch counters) * log: log the request id, userid, sessionid in a file (in match.log) * abort : abort the session * restart: restart the session. The maximum number of restarts is 3 by default. * loop: repeat the request, after 5 seconds. The maximum number of loops is 20 by default. * dump: dump the content of the response in a file. The filename is match-<userid>-<sessionid>- <requestid>-<dumpid>.dump You can mixed several match tag in a single request: <request> <match do="loop" sleep_loop="5" max_loop="10" when="match">Retry</match> <match do="abort" when="match">Error</match> <http url='/index.php' method=GET'> </request> You can also do the action on "nomatch" instead of "match". If you want to skip the HTTP headers, and match only on the body, you can use skip_headers=’http’. Also, you can apply a function to the content before matching; for example the following example use both features to compute the md5sum on the body of a HTTP response, and compares it to a given value: <match do='log' when='nomatch' skip_headers='http' apply_to_content='ts_digest:md5hex'>01441debe3d7cc65ba843eee1acff89d</match> <http url="/" method="GET" version="1.1"/> You can also use dynamic variables, using the subst attribute: <match do='log' when='nomatch' subst='true' >%%_myvar%%</match> <http url="/" method="GET"/>
27 DONE mac install tsung
CLOSED: 2013-04-30 00:23
27.1 brew install tsung
bash-3.2$ brew install tsung Warning: It appears you have MacPorts or Fink installed. Software installed with other package managers causes known problems for Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again. ==> Downloading http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz ##################################################################################################################################### 100.0% ==> ./configure --prefix=/usr/local/Cellar/tsung/1.4.2 ==> make ==> make install
tsung: an open-source multi-protocol distributed load testing tool的更多相关文章
- Difference Between Performance Testing, Load Testing and Stress Testing
http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...
- Jmeter Distributed (Remote) Testing: Master Slave Configuration
What is Distributed Testing? DistributedTestingis a kind of testing which use multiple systems to pe ...
- [Windows Azure] Load Testing in Windows Azure
The primary goal of a load test is to simulate many users accessing a web application at the same ti ...
- Load Testing Socket.IO Web Applications and Infrastructure
转自:https://medium.com/better-programming/load-testing-socket-io-web-applications-and-infrastructure- ...
- Codeforces 847H - Load Testing
847H - Load Testing 思路:dp. 代码: #include<bits/stdc++.h> using namespace std; #define ll long lo ...
- Locust - A modern load testing framework https://locust.io/
Locust - A modern load testing frameworkhttps://locust.io/
- Google Code Jam 2010 Round 1C Problem B. Load Testing
https://code.google.com/codejam/contest/619102/dashboard#s=p1&a=1 Problem Now that you have won ...
- Apache JMeter - load test tool
What is it? ->>>> http://jmeter.apache.org/index.html (Please read!) Where to get it? - ...
- 九款Web服务器性能压力测试工具
一.http_load 程序非常小,解压后也不到100Khttp_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载.但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会 ...
随机推荐
- python密码强口令检测
主要就是输入判断检测,以及一些正则的学习.刚开始玩python项目,代码写的不好.我以前玩C的!! 代码的价值与其是否能够实现功能等价! #密码输入检测 密码长度不少于8个字符,而且必须包含大写/小写 ...
- 为Array 添加indexOf
为array赋予属性 if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (elt /*, from*/) { var ...
- Linux常用操作
1. Latex参考文献格式 http://blog.163.com/sunkun_hust/blog/static/204454119201482524222283/
- event 实现观察者模式
看了一些其他人写的,一下就晕了,还是自己写一个给自己看吧. 用event语法糖实现的观察者,与普通的实现,最大的区别在于,Subject的操作中不会直接触发Observer的Update,而是通过ev ...
- JAVA 并发编程关键点
上下文切换 死锁 volatile synchronized 原子操作 happens-before as-if serial 锁的内存 final 线程:daemon start suspend r ...
- js数组、对象、正则
1.根据给定的条件在原有的数组上,得到所需要的新数组var a = [-1, -1, 1, 2, -2, -2, -3, -3, 3, -3];function f(s, e) { var re ...
- ubuntu下百度云安装
1.安装 在github上下载 .deb 安装包 下载地址 https://github.com/LiuLang/bcloud-packages 下载完成双击安装文件安装成功 2.解决验证码问题 (1 ...
- 整体认识flume:Flume介绍、分布式安装、常见问题及解决方案
问题导读 1.什么是flume? 2.flume包含哪些组件? 3.Flume在读取utf-8格式的文件时会出现解析不了时间戳,该如何解决? Flume是一个分布式.可靠.和高可用的海量日志采集.聚合 ...
- Node.js:EventEmitter
概要:本篇博客主要介绍EventEmitter Node.js所有的异步I/O操作在完成时都会发送一个事件到事件队列.事件由EventEmitter对象提供.下面通过一个例子来说明EventEmitt ...
- 微信支付错误两个问题的解决:curl出错,错误码:60
如下是运行微信支付测试代码时出错代码: Warning: curl_setopt() expects parameter 2 to be long, string given in D:\wwwroo ...