Tsung is an open-source multi-protocol distributed load testing tool@H_403_12@,It can be used to stress http,WebDAV,SOAP,Postgresql,MysqL,LDAP and Jabber/XMPP servers. Tsung is a free software released under the GPLv2 license.
The purpose of Tsung is to simulate users in order to test the scalability and performance of IP based clIEnt/server applications. You can use it to do load and stress testing of your servers. Many protocols have been implemented and tested,and it can be easily extended.
It can be distributed on several clIEnt machines and is able to simulate hundreds of thousands of virtual users concurrently (or even millions if you have enough harDWare ...).
Tsung is developed in Erlang,an open-source language made by EriCSSon for building robust fault-tolerant distributed applications.
Tsung Home: http://tsung.erlang-projects.org/
Installation
Install tsung in CentOS,before installation,please make sure below tools are installed:
yum install gcc -y yum install perl -y yum install unixODBC yum install unixODBC-devel 1. Install erlangdownload erlang from http://www.erlang.org/download.html,and select R14B04 version
@H_250_403@@H_540_404@# wget http://www.erlang.org/download/otp_src_R14B04.tar.gz@H_250_403@@H_540_404@# tar -zxvf otp_src_R14B04.tar.gz@H_250_403@@H_540_404@# cd otp_src_R14B04@H_250_403@@H_540_404@# ./configure --prefix=/usr/local/erlang@H_250_403@@H_540_404@# make@H_250_403@@H_540_404@# make install
If raise "configure: error: No curses library functions found" in configure step,please install ncurses-devel and re-try configure:
# yum install@H_403_12@ -y ncurses-devel
2. Install Tsung
download tsung from http://tsung.erlang-projects.org/dist/.
@H_540_404@# wget http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz@H_250_403@@H_540_404@# tar -zxvf tsung-1.4.2.tar.gz@H_250_403@@H_540_404@# cd tsung-1.4.2@H_250_403@@H_540_404@# ./configure --prefix=/usr/local/tsung --with-erlang=/usr/local/erlang@H_250_403@@H_540_404@# make install
3. Install perl Template
Template used for Tsung reports generated. Template-Toolkit downlaod link:http://www.template-toolkit.org/download/index.html
@H_540_404@# wget http://cpan.org/modules/by-module/Template/Template-Toolkit-2.24.tar.gz@H_250_403@@H_540_404@# tar -zxvf Template-Toolkit-2.24.tar.gz@H_250_403@@H_540_404@# cd Template-Toolkit-2.24@H_250_403@@H_540_404@# perl Makefile.PL@H_250_403@@H_540_404@# make test@H_250_403@@H_540_404@# make install
4. Install gnuplot
gnuplot is the chat generator.
-y gnuplot gd libpng zlib
Note: use "gnuplot" command to check the tools installed like:
# gnuplot> set terminal
Tsung usage
@H_403_12@
1 Create Tsung workdir:
$ mkdir@H_403_12@ ~/.tsung
2. Configure file,use http test as a sample:
cp@H_403_12@ /usr/local/tsung/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml
Modify the tsung.xml,more usage you can get from: http://tsung.erlang-projects.org/user_manual.html#htoc1
3. Run Tsung for your test
$ tsung start
4. Test report After the tsung test finished,go to the folder which naming as create time and run the perl script:
$ cd@H_403_12@ ~/.tsung/log/xxxxx$ /usr/local/tsung/lib/tsung/bin/tsung_stats.pl
5. display the test results from firefox or IE If the server installed python,you can start a http server like:
cd@H_403_12@ ~/.tsung/log/xxxxx$ python -m SimplehttpServer
Then you can get reports from: http://serverip:8000
tsung-recorder
Tsung use tsung-recorder to record your test actions and auto generate the
To start it,run tsung-recorder -p <PLUGIN> start,where PLUGIN can be http,webdav or pgsql for Postgresql. The default plugin is http. The proxy is Listening to port 8090. You can change the port with -L portnumber. To stop it,use tsung-recorder stop. The recorded session is created as ~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml; if it doesn’t work,take a look at ~/.tsung/log/tsung.log-tsung_recorder@hostname During the recording,you can add custom tag in the XML file,this can be useful to set transactions or comments: tsung-recorder record_tag "<transaction name=’login’>’’ Once a session has been created,you can insert it in your main configuration file,either by editing by hand the file,or by using an ENTITY declaration,like:<!DOCTYPE tsung SYstem "/usr/share/tsung/tsung-1.0.dtd" [ <!ENTITY mysession1 SYstem "/home/nniclausse/.tsung/tsung_recorder20051217-13:11.xml"> ]> ...<sessions>@H_403_12@ &mysession1;</sessions>@H_403_12@
Notes:
One Tsung cases sample
1. Server and ClIEnt configure in tsung.xml file like:
@H_540_404@<!-- ClIEnt sIDe setup --> <clIEnts>@H_403_12@ <clIEnt@H_403_12@ host="server1" use_controller_vm="true" maxusers="10000" />@H_403_12@ </clIEnts>@H_403_12@ @H_540_404@<!-- Server sIDe setup --> <servers>@H_403_12@ <server@H_403_12@ "172.11.10.1" port="80" type="tcp">@H_403_12@</server>@H_403_12@ </servers>@H_403_12@
2. Phases setting in tsung.xml file like:
<load>@H_403_12@ @H_540_404@<!--@H_540_404@ several arrival phases can be set: for each phase,you can set the@H_540_404@ mean inter-arrival time between new clIEnts and the phase duration@H_540_404@ --> <arrivAlphase@H_403_12@ phase="1" duration=unit="minute">@H_403_12@ <users@H_403_12@ maxnumber=interarrival="second"</users>@H_403_12@ </arrivAlphase>@H_403_12@ </load>@H_403_12@
3. Add session cases file in tsung.xml file like:
<!DOCTYPE tsung SYstem "/usr/local/tsung/share/tsung/tsung-1.0.dtd" [ <!ENTITY mysession1 SYstem "/root/.tsung/cases_List/tsung_recorder20120828-1339.xml">]>...</sessions>@H_403_12@
Make sure /usr/local/tsung/share/tsung/tsung-1.0.dtd existed.
Sample of /root/.tsung/cases_List/tsung_recorder20120828-1339.xml:
<session@H_403_12@ name='rec20120828-1339' probability='100' 'ts_http'>@H_403_12@ @H_540_404@<!--Mock encoded BoxID--> <setdynvars@H_403_12@ sourcetype="random_string" length="20">@H_403_12@ <var@H_403_12@ "userIDend" />@H_403_12@ </setdynvars>@H_403_12@ @H_540_404@<!-- Use 3des_test.PHP to mock the 3DES'ed BoxID for the auth request --> <request@H_403_12@ subst="true"<dyn_variable@H_403_12@ "BoxID" re="urlencode:(.*)"/>@H_403_12@ <http@H_403_12@ url='/app/test/test.PHP?type=encode&string=010004%%_userIDend%%' version='1.1' method='GET'</http>@H_403_12@ </request>@H_403_12@ "auth" "<auth relpy="(.*)"/>""entoken" "<token value="(.*)"/>"'/app/test/index.PHP?version=1.1&action=auth&userID=%%_userID%%' <if@H_403_12@ var=eq="success">@H_403_12@ @H_540_404@<!-- decode the token --> >@H_403_12@ "token" "Decode:(.*)"/>@H_403_12@ url='/app /test/test.PHP?type=decode&string=%%_entoken%%' </http>@H_403_12@ </request>@H_403_12@ @H_540_404@<!-- sleep time to mock PAD clIEnt operation,if thinktime more than 2 sec,upgrade request will be Failed --> <thinktime@H_403_12@ random='true' value='1'/>@H_403_12@ @H_540_404@<!-- upgrade request --> "upgraderesult" "<upgrade result="([^"]*)">""upgradever" "<swinfo version="([^"]*)""'/app/test/index.PHP?version=1.1&action=update&hw_version=10.0.0&swversion=3&token=%%_token%%' </request>@H_403_12@ "0">@H_403_12@ @H_540_404@<!-- download request --> >@H_403_12@ '/app/test/download.PHP?token=%%_token%%' </http>@H_403_12@ </request>@H_403_12@ @H_540_404@<!-- confirm request --> '/app/test/index.PHP?action=confirm&result=0&oldversion=3&curversion=%%_upgradever%%&token=%%_token%%&version=1.1' </request>@H_403_12@ </if>@H_403_12@ </if>@H_403_12@ </session>@H_403_12@
Descriptions:
random_string:>@H_403_12@ />@H_403_12@ </setdynvars>@H_403_12@
Means a dynamic variable can be a random string "userIDend",its lenght 20. BTW,a dynamic variable can be a random number by random_number@H_403_12@
<dyn_variable name="userID" re="urlencode:(.*)"/>@H_403_12@: means get BoxID values using regular Expression to filter from http response. Using a variable like %%_userID%%@H_403_12@ When you want to use dynamic variables,please using the subst@H_403_12@ attribut in request element 总结以上是内存溢出为你收集整理的压力测试工具Tsung安装和使用全部内容,希望文章能够帮你解决压力测试工具Tsung安装和使用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)