- 浏览: 967543 次
- 性别:
- 来自: 广州
最新评论
-
qingchuwudi:
有用,非常感谢!
erlang进程的优先级 -
zfjdiamond:
你好 这条命令 在那里输入??
你们有yum 我有LuaRocks -
simsunny22:
这个是在linux下运行的吧,在window下怎么运行escr ...
escript的高级特性 -
mozhenghua:
http://www.erlang.org/doc/apps/ ...
mnesia 分布协调的几个细节 -
fxltsbl:
A new record of 108000 HTTP req ...
Haproxy 1.4-dev2: barrier of 100k HTTP req/s crossed
原文地址:http://www.process-one.net/en/wiki/Writing_a_Tsung_plugin/
Writing a Tsung plugin
This is a simple tutorial on writing a tsung plugin.
Since tsung is used to test servers lets define a simple server for testing. myserver.erl provides 3 operations: echo, add and subtract.
myserver.erl assumes the first byte to be a control instruction followed by 2 or more byte data. The echo operation merely returns the byte data while add and subtract performs these operations on the 2 byte data before returning the results. See the code of myserver.erl for details.
We assume the source files for tsung-1.2.1 are available. This example was compiled using Erlang OTP R11B-3.
Step 0. Download the source code for this tutorial
The source code for this tutorial is available: tutorial_tsung_1.tgz
Step 1. Create tsung configuration file
Based on the 3 operations we want to test we define the myclient.xml which
will take place of tsung.xml. You will notice myclient.xml looks very much
like any normal tsung configuration file. The main difference is in the
session definition. Here we use the ts_myclient type.
<session probability="100" name="myclient-example" type="ts_myclient">
This indicates which plugin tsung should call when creating a server request.
We choose to name this plugin ts_myclient.
The next difference is within the request element. Here we define a ‘myclient’
element indicates the operations to test followed by the relevant data.
Notice that myclient has 2 attributes: type and arith (optional).
Step 2. Update DTD
We now need to modify the tsung-1.0.dtd or validation would fail.
In the request element we add the myclient tag.
<!ELEMENT request ( match*, dyn_variable*, ( http | jabber | raw | pgsql | myclient ) )>
Next we create the myclient element.
<!ELEMENT myclient (#PCDATA) >
Followed by defining the attributes list for myclient.
<!ATTLIST myclient
arith (add | sub) #IMPLIED
type (echo | compute) #REQUIRED >
Next, we add the ts_myclient option into the element’s type attribute list.
type (ts_http | ts_jabber | ts_pgsql | ts_myclient ) #IMPLIED
We do the same to the session’s type attribute list.
type (ts_jabber | ts_http | ts_raw | ts_pgsql | ts_myclient ) #REQUIRED>
Step 3. Create include file
In PATH/include create the include file ts_myclient.hrl.
This include file should have a minimum of two records:
myclient_request: for storing request information parsed from tsung configuration. Will be use to generate server requests.
myclient_dyndata: for storing dynamic information. Not used in this case.
Step 4. Config reader
Create the ts_config_myclient.erl in PATH/src/tsung_controller to parse the XML file. This file must export parse_config/2.
ts_config_myclient:parse_config/2 is called from ts_config:parse/1.
However trying to run ts_config:parse/1 seperately seem to throw an undefined case error.
The important function definition is:
parse_config(Element = #xmlElement{name=myclient}, ...)
Within this pattern we gather the various attributes, echo, compute, add, sub,
and data creating a myclient_request record as needed. Notice for the case
of type compute we parse the data into a list of 2 integers. Ensure you keep
any data manipulation here consistant with calls in ts_myclient:get_message/1.
If your configuration file support several element types then you will need a parse_config function for each.
Step 5. ts_myclient
The final file to create is ts_myclient.erl in PATH/src/tsung.
The get_message/1 function builds the actual data to be transmitted to the server. The function returns a binary even if your protocol uses strings.
In ts_myclient:get_message/1, you can see how we create the message from the myclient_request record. Compare this with myserver:test/3 and myserver:test/1.
parse/2 deals with server responses. It is possible to parse the return data and update monitoring parameters. In the ts_myclient:parse/1 we count the number of single and multi bytes returned from the server. Obviously these must match echo and add / _sub calls.
The ts_mon:add/1 parameters are restricted to:
{count, Type} – increments a running counter
{sum, Type, Val} – adds Val to running counter
{sample_counter, Type, Value} – updates sample_counter
{sample, Type, Value} – updates counter
Step 6. Build and install
Return to PATH and type make followed by make install.
There is no need to update any make files.
Step 7. Running
Start myserver then call myserver:server() in the erlang shell to start listening to the socket.
sh> erl -s myserver start_link
1> myserver:server().
Run tsung, passing it myclient.xml:
sh> tsung -f myclient.xml
Authors
The first version of this tutorial has been written by tty.
Writing a Tsung plugin
This is a simple tutorial on writing a tsung plugin.
Since tsung is used to test servers lets define a simple server for testing. myserver.erl provides 3 operations: echo, add and subtract.
myserver.erl assumes the first byte to be a control instruction followed by 2 or more byte data. The echo operation merely returns the byte data while add and subtract performs these operations on the 2 byte data before returning the results. See the code of myserver.erl for details.
We assume the source files for tsung-1.2.1 are available. This example was compiled using Erlang OTP R11B-3.
Step 0. Download the source code for this tutorial
The source code for this tutorial is available: tutorial_tsung_1.tgz
Step 1. Create tsung configuration file
Based on the 3 operations we want to test we define the myclient.xml which
will take place of tsung.xml. You will notice myclient.xml looks very much
like any normal tsung configuration file. The main difference is in the
session definition. Here we use the ts_myclient type.
<session probability="100" name="myclient-example" type="ts_myclient">
This indicates which plugin tsung should call when creating a server request.
We choose to name this plugin ts_myclient.
The next difference is within the request element. Here we define a ‘myclient’
element indicates the operations to test followed by the relevant data.
Notice that myclient has 2 attributes: type and arith (optional).
Step 2. Update DTD
We now need to modify the tsung-1.0.dtd or validation would fail.
In the request element we add the myclient tag.
<!ELEMENT request ( match*, dyn_variable*, ( http | jabber | raw | pgsql | myclient ) )>
Next we create the myclient element.
<!ELEMENT myclient (#PCDATA) >
Followed by defining the attributes list for myclient.
<!ATTLIST myclient
arith (add | sub) #IMPLIED
type (echo | compute) #REQUIRED >
Next, we add the ts_myclient option into the element’s type attribute list.
type (ts_http | ts_jabber | ts_pgsql | ts_myclient ) #IMPLIED
We do the same to the session’s type attribute list.
type (ts_jabber | ts_http | ts_raw | ts_pgsql | ts_myclient ) #REQUIRED>
Step 3. Create include file
In PATH/include create the include file ts_myclient.hrl.
This include file should have a minimum of two records:
myclient_request: for storing request information parsed from tsung configuration. Will be use to generate server requests.
myclient_dyndata: for storing dynamic information. Not used in this case.
Step 4. Config reader
Create the ts_config_myclient.erl in PATH/src/tsung_controller to parse the XML file. This file must export parse_config/2.
ts_config_myclient:parse_config/2 is called from ts_config:parse/1.
However trying to run ts_config:parse/1 seperately seem to throw an undefined case error.
The important function definition is:
parse_config(Element = #xmlElement{name=myclient}, ...)
Within this pattern we gather the various attributes, echo, compute, add, sub,
and data creating a myclient_request record as needed. Notice for the case
of type compute we parse the data into a list of 2 integers. Ensure you keep
any data manipulation here consistant with calls in ts_myclient:get_message/1.
If your configuration file support several element types then you will need a parse_config function for each.
Step 5. ts_myclient
The final file to create is ts_myclient.erl in PATH/src/tsung.
The get_message/1 function builds the actual data to be transmitted to the server. The function returns a binary even if your protocol uses strings.
In ts_myclient:get_message/1, you can see how we create the message from the myclient_request record. Compare this with myserver:test/3 and myserver:test/1.
parse/2 deals with server responses. It is possible to parse the return data and update monitoring parameters. In the ts_myclient:parse/1 we count the number of single and multi bytes returned from the server. Obviously these must match echo and add / _sub calls.
The ts_mon:add/1 parameters are restricted to:
{count, Type} – increments a running counter
{sum, Type, Val} – adds Val to running counter
{sample_counter, Type, Value} – updates sample_counter
{sample, Type, Value} – updates counter
Step 6. Build and install
Return to PATH and type make followed by make install.
There is no need to update any make files.
Step 7. Running
Start myserver then call myserver:server() in the erlang shell to start listening to the socket.
sh> erl -s myserver start_link
1> myserver:server().
Run tsung, passing it myclient.xml:
sh> tsung -f myclient.xml
Authors
The first version of this tutorial has been written by tty.
发表评论
-
OTP R14A今天发布了
2010-06-17 14:36 2608以下是这次发布的亮点,没有太大的性能改进, 主要是修理了很多B ... -
R14A实现了EEP31,添加了binary模块
2010-05-21 15:15 2964Erlang的binary数据结构非常强大,而且偏向底层,在作 ... -
如何查看节点的可用句柄数目和已用句柄数
2010-04-08 03:31 4735很多同学在使用erlang的过程中, 碰到了很奇怪的问题, 后 ... -
获取Erlang系统信息的代码片段
2010-04-06 21:49 3385从lib/megaco/src/tcp/megaco_tcp_ ... -
iolist跟list有什么区别?
2010-04-06 20:30 6421看到erlang-china.org上有个 ... -
erlang:send_after和erlang:start_timer的使用解释
2010-04-06 18:31 8246前段时间arksea 同学提出这个问题, 因为文档里面写的很不 ... -
Latest news from the Erlang/OTP team at Ericsson 2010
2010-04-05 19:23 1927参考Talk http://www.erlang-factor ... -
对try 异常 运行的疑问,为什么出现两种结果
2010-04-05 19:22 2780郎咸武<langxianzhe@163.com> ... -
Erlang ERTS Async基础设施
2010-03-19 00:03 2434其实Erts的Async做的很不错的, 相当的完备, 性能又高 ... -
CloudI 0.0.9 Released, A Cloud as an Interface
2010-03-09 22:32 2417基于Erlang的云平台 看了下代码 质量还是不错的 完成了不 ... -
Memory matters - even in Erlang (再次说明了了解内存如何工作的必要性)
2010-03-09 20:26 3364原文地址:http://www.lshift.net/blog ... -
Some simple examples of using Erlang’s XPath implementation
2010-03-08 23:30 1992原文地址 http://www.lshift.net/blog ... -
lcnt 环境搭建
2010-02-26 16:19 2536抄书:otp_doc_html_R13B04/lib/tool ... -
Erlang强大的代码重构工具 tidier
2010-02-25 16:22 2426Jan 29, 2010 We are very happy ... -
[Feb 24 2010] Erlang/OTP R13B04 has been released
2010-02-25 00:31 1335Erlang/OTP R13B04 has been rele ... -
R13B04 Installation
2010-01-28 10:28 1339R13B04后erlang的源码编译为了考虑移植性,就改变了编 ... -
Running tests
2010-01-19 14:51 1393R13B03以后 OTP的模块加入了大量的测试模块,这些模块都 ... -
R13B04在细化Binary heap
2010-01-14 15:11 1449从github otp的更新日志可以清楚的看到otp R13B ... -
R13B03 binary vheap有助减少binary内存压力
2009-11-29 16:07 1593R13B03 binary vheap有助减少binary内存 ... -
erl_nif 扩展erlang的另外一种方法
2009-11-26 01:02 3131我们知道扩展erl有2种方法, driver和port. 这2 ...
相关推荐
压力测试 压力测试 tsung linux
tsung的测试脚本,包含发送单人消息,群组消息,获取花名册等
Openfire 3.9.3 Load Test Tsung配置xml,10万用户下集群测试的Tsung压力测试工具的jabber_cluster.xml,session 5分钟
tsung里面测试websocket的插件含 websocket.xml 等
Tsung安装使用的详细解说,主要针对xmpp的服务端(比如openfire的测试),编写测试场景的脚本配置详细说明。本人使用的是ubuntu操作系统、Tsung1.4.1
MQTT压力测试之Tsung的使用 MQTT压力测试之Tsung的使用
tsung+erlang测试工具,初学者应用必备,内部放置tsung源程序文件和erlang文件
tsung是用erlang开发的一款简单易用的压力测试工具,目前仅支持linux各版本系统安装,有tar.gz和deb两种安装文件, 目前我们测试用的是CentOS或RedHat两种操作系统,因此选择tar.gz安装文件,总的来说tsung工具有...
tsung 测试 java erlang
tsung为一个开源的多协议分布式负载测试工具,使用erlang语言开发的。具体安装使用可以参考URL:http://www.51ste.com/share/det-222.html
tsung是一个非常好用的压力测试软件,基于erlang语言,支持多种...在Ubuntu上装好tsung之后,首先要用ulimit修改系统支持的最大fd数量(ulimit-n 20480),否则tsung最多只能创建不到1024个连接,测试脚本是一个xml文件
关于tsung工具的安装步骤以及使用过程中会遇到的常见问题解答
tsung高并发测试工具搭建(自己亲测,详细的一逼),改文档是自己一步一步摸索出来的,主要是安装tsung整个过程很详细,搭过的人,知道tsung的搭建依赖很恶心,不是一时半会能搞出来的
tsung最新用户手册,包含HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP, and Jabber/XMPP servers压力测试模版,错误说明等。
tsung安装使用,参数说明,模拟openfire注册用户,模拟用户openfire登录、状态更改、发送消息,对openfire长时间压力测试
—tsung-1.5.0.tar.gz —libtemplate-perl_2.20.orig.tar.gz —gnuplot-4.4.0.tar.gz —otp_src_R15B.tar.gz —perl-HTML-Tagset-3.10-2.1.1.noarch.rpm —perl-HTML-Parser-3.55-1.fc6.x86_64.rpm —...
包括tigase的安装运行,tsung的安装运行,压测结果的信息解析等;
tsung-react-stats 从 json 报告中显示 tsung 统计信息
tsung安装包,linux下进行压力测试的工具
支持各种协议的压力测试工具,如HTTP/XMPP等