- 浏览: 982398 次
- 性别:
- 来自: 广州
最新评论
-
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 2677以下是这次发布的亮点,没有太大的性能改进, 主要是修理了很多B ... -
R14A实现了EEP31,添加了binary模块
2010-05-21 15:15 3030Erlang的binary数据结构非常强大,而且偏向底层,在作 ... -
如何查看节点的可用句柄数目和已用句柄数
2010-04-08 03:31 4814很多同学在使用erlang的过程中, 碰到了很奇怪的问题, 后 ... -
获取Erlang系统信息的代码片段
2010-04-06 21:49 3475从lib/megaco/src/tcp/megaco_tcp_ ... -
iolist跟list有什么区别?
2010-04-06 20:30 6529看到erlang-china.org上有个 ... -
erlang:send_after和erlang:start_timer的使用解释
2010-04-06 18:31 8386前段时间arksea 同学提出这个问题, 因为文档里面写的很不 ... -
Latest news from the Erlang/OTP team at Ericsson 2010
2010-04-05 19:23 2013参考Talk http://www.erlang-factor ... -
对try 异常 运行的疑问,为什么出现两种结果
2010-04-05 19:22 2842郎咸武<langxianzhe@163.com> ... -
Erlang ERTS Async基础设施
2010-03-19 00:03 2517其实Erts的Async做的很不错的, 相当的完备, 性能又高 ... -
CloudI 0.0.9 Released, A Cloud as an Interface
2010-03-09 22:32 2476基于Erlang的云平台 看了下代码 质量还是不错的 完成了不 ... -
Memory matters - even in Erlang (再次说明了了解内存如何工作的必要性)
2010-03-09 20:26 3439原文地址:http://www.lshift.net/blog ... -
Some simple examples of using Erlang’s XPath implementation
2010-03-08 23:30 2050原文地址 http://www.lshift.net/blog ... -
lcnt 环境搭建
2010-02-26 16:19 2614抄书:otp_doc_html_R13B04/lib/tool ... -
Erlang强大的代码重构工具 tidier
2010-02-25 16:22 2486Jan 29, 2010 We are very happy ... -
[Feb 24 2010] Erlang/OTP R13B04 has been released
2010-02-25 00:31 1387Erlang/OTP R13B04 has been rele ... -
R13B04 Installation
2010-01-28 10:28 1390R13B04后erlang的源码编译为了考虑移植性,就改变了编 ... -
Running tests
2010-01-19 14:51 1486R13B03以后 OTP的模块加入了大量的测试模块,这些模块都 ... -
R13B04在细化Binary heap
2010-01-14 15:11 1508从github otp的更新日志可以清楚的看到otp R13B ... -
R13B03 binary vheap有助减少binary内存压力
2009-11-29 16:07 1668R13B03 binary vheap有助减少binary内存 ... -
erl_nif 扩展erlang的另外一种方法
2009-11-26 01:02 3218我们知道扩展erl有2种方法, driver和port. 这2 ...
相关推荐
本文将详细讲解在Ubuntu系统上安装Tsung 1.4.1,并针对Openfire服务端进行压力和性能测试的过程。 ## 1. Tsung安装 ### 1.1 Tsung运行环境安装 在开始安装Tsung之前,确保系统已经安装了Erlang环境。Erlang是...
1. **安装Tsung**:首先确保系统已经安装了Tsung,如果没有,可以从官方仓库或通过包管理器进行安装。 2. **配置`websocket.xml`**:根据实际的WebSocket服务和测试需求,编辑配置文件。 3. **运行测试**:使用Tsung...
**Tsung 1.6.0 - 开源多协议分布式负载测试工具** Tsung是一个功能强大的、基于Erlang编程语言开发的开源负载测试工具。它设计用于模拟大量用户并发访问,以测试网络服务和系统的性能及稳定性。Tsung不仅支持HTTP、...
MQTT压力测试之Tsung的使用 MQTT压力测试之Tsung的使用
**Tsung + Erlang 包详解** Tsung 是一个开源的多协议负载和性能测试工具,它可以模拟大量用户并发访问服务器,从而评估系统的负载能力和稳定性。Tsung 的设计目标是提供一个灵活、可扩展的解决方案,能够测试各种...
tsung的测试脚本,包含发送单人消息,群组消息,获取花名册等
Openfire 3.9.3 Load Test Tsung配置xml,10万用户下集群测试的Tsung压力测试工具的jabber_cluster.xml,session 5分钟
### TSUNG测试总结 #### 一、TSUNG概述 TSUNG是一款开源的负载与压力测试工具,主要用于评估系统的性能及稳定性。它支持多种协议,包括但不限于XMPP、HTTP、MySQL等,并且具备支持集群和高效运行的特点。由于其...
tsung是用erlang开发的一款简单易用的压力测试工具,目前仅支持linux各版本系统安装,有tar.gz和deb两种安装文件, 目前我们测试用的是CentOS或RedHat两种操作系统,因此选择tar.gz安装文件,总的来说tsung工具有...
Tsung是一款开源的压力测试工具,能够模拟多个用户对各种服务器应用进行压力测试。它使用Erlang语言编写,支持多种协议,如HTTP、WebDAV、SOAP、PostgreSQL、MySQL、LDAP和Jabber/XMPP。在实际使用中,Tsung可以模拟...
### Tsung负载测试Tigase知识点详解 #### Tsung概述 Tsung是一款高效的压力测试工具,采用Erlang语言开发,能够支持多种网络协议,包括XMPP、HTTP、MySQL等。其独特的分布式特性使得它能够在单机环境下模拟大量...
关于tsung工具的安装步骤以及使用过程中会遇到的常见问题解答
### Tsung 安装与使用详解 #### 一、Tsung 概述 Tsung 是一款基于 Erlang 开发的高性能压力测试工具,主要用于评估系统的并发处理能力。它支持多种协议,包括 HTTP、WebDAV、Jabber/XMPP、PostgreSQL、LDAP 和 ...
tsung高并发测试工具搭建(自己亲测,详细的一逼),改文档是自己一步一步摸索出来的,主要是安装tsung整个过程很详细,搭过的人,知道tsung的搭建依赖很恶心,不是一时半会能搞出来的
### Tsung用户指南知识点概述 #### 一、引言 ##### 1.1 Tsung是什么? Tsung是一款开源的压力测试工具,它能够模拟大量用户并发访问应用系统,并收集详细的性能数据,帮助用户评估系统的可扩展性和性能瓶颈。...
**Tsung 1.3.3:Linux环境下的强大压力测试工具** Tsung是一个高度可扩展、分布式的多协议负载和性能测试工具,专为模拟大量用户并发访问系统而设计。它支持多种网络协议,包括HTTP、HTTPS、FTP、TCP、UDP、jabber/...
—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 —...
【tsung-1.5.1.tar.gz】是一款开源的压力测试工具,专为评估系统在高负载下的性能和稳定性而设计。它具有广泛的应用场景,特别是在测试分布式系统,如即时通讯服务器Openfire时表现尤为出色。这个压缩包包含了Tsung...
包括tigase的安装运行,tsung的安装运行,压测结果的信息解析等;