Testing your XMPP external component using Tsung and ejabberd part 2
In the previous post we discussed ow to enable anonymous authentication in ejabberd in order to use Tsung for our testing purposes.
Tsung (a.k.a. Tsunami) is a shell testing tool fairly easy to use when dealing with XMPP, it is mainly used to simulate thousands of users for testing the scalability and performances of IP based client/server applications.
For XMPP test purposes it allows:
- Authentication (plain-text, digest and sip-digest)
- presence and register messages
- Chat messages to online or offline users
- MUC: join room, send message in room, change nickname
- Roster set and get requests
- Global users
'synchronization set on specific actions
- raw XML messages
- Multiple vhost instances support
First thing first: install Tsung! Download the source from http://tsung.erlang-projects.org and just follow the common procedure configure, make, make install (you may need sudo).
You may check whether the installation was successful by typing:
paolo@blog $ tsung -h Usage: tsung start|stop|debug|status Options: -f set configuration file (default is ~/.tsung/tsung.xml) -l set log file (default is ~/.tsung/log/tsung.log) -i set controller id (default is empty) -r set remote connector (default is ssh) -F use long names (FQDN) for erlang nodes -v print version information and exit -h display this help and exit
When you start Tsung (we will see how) it executes a set of operation based on an xml file (tsung.xml) that you easily configure by using a text editor. This file is inside the directory ~/.tsung but sometimes it is not present so I suggest you to copy one of the examples you can find in the directory “examples” of the installation package, copy it there and rename it.
Let’s take a look at tsung.xml.
Scenarios start with clients (Tsung cluster) and server definitions, so for a non-distributed load, you can use a basic setup like:
<clients> <client host="client-ip" use_controller_vm="true"/> </clients> <servers> <server host="server-ip" port="80" type="tcp"></server> </servers>
You can put more than one client or one server in you tsung.xml, using either a string or an ip-addres to identificate them. In case of multiple servers, a round robin algorithm will be used to chose a server.
Let’s define now a load progression by specifing a set of arrival phases to the server:
<load> <arrivalphase phase="1" duration="1" unit="hour"> <users interarrival="6" unit="second"></users> </arrivalphase> <arrivalphase phase="2" duration="40" unit="minute"> <users interarrival="1" unit="second"></users> </arrivalphase> <arrivalphase phase="3" duration="5" unit="minute"> <users interarrival="0.1" unit="second"></users> </arrivalphase> </load>
Above we specified 3 phases:
- duration 1 hour, 1 user each 6 seconds will start a session
- duration 40 minutes, 1 user every 1 second
- duration 5 minutes, 1 user every 0.1 seconds
The phases will happen one after the other and the test will finish when all users have ended their session. Notice that duration of the test can be much longer than the duration of arrival phases, therefore if you want to stop the test after a threshold duration (even if phases are not finished or if some sessions are still active), you can do by setting a duration attribute to load:
<load duration="4" unit="hour"> ....... </load>
You can then edit the options as follows:
<options> <option type="ts_jabber" name="global_number" value="5"></option> <option type="ts_jabber" name="userid_max" value="1000"></option> <option type="ts_jabber" name="domain" value="yourdomain"></option> <option type="ts_jabber" name="username" value="yourusername"></option> <option type="ts_jabber" name="passwd" value="yourpwd"></option> </options>
In the next post (the final part of this tutorial on Tsung) we will see how to deal with sessions and how to run a test and evaluate its results.