Posts Tagged ‘tsung’

Testing your XMPP external component using Tsung and ejabberd part 2

August 1, 2010 5 comments

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
  • PubSub
  • Multiple vhost instances support

First thing first: install Tsung! Download the source from 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
    -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.

The Great Wave Of Kanagawa

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:

    <client host="client-ip" use_controller_vm="true"/>

    <server host="server-ip" port="80" type="tcp"></server>

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:

  <arrivalphase phase="1" duration="1" unit="hour">
    <users interarrival="6" unit="second"></users>

  <arrivalphase phase="2" duration="40" unit="minute">
    <users interarrival="1" unit="second"></users>

  <arrivalphase phase="3" duration="5" unit="minute">
    <users interarrival="0.1" unit="second"></users>

Above we specified 3 phases:

  1. duration 1 hour, 1 user each 6 seconds will start a session
  2. duration 40 minutes, 1 user every 1 second
  3. 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">

You can then edit the options as follows:

  <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>

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.

Categories: English, Erlang Tags: , ,

Testing your XMPP external component using Tsung and ejabberd part 1

July 21, 2010 Leave a comment

In many previous posts, I gave you some ideas on how to build an external component for XMPP servers; now it is time to test your work!

Tsung is a stress testing tool written in Erlang that you can use to test HTTP, WebDAV, LDAP, MySQL, PostgreSQL, SOAP and XMPP servers; it can simulate hundreds of simultaneous users on a single system in a single server or in a clustered environment therefore Tsung is the right tool to test our XMPP services.

First of all: when you use Tsung, you simulate few or many users….the problem is that you need to authenticate these users against the server, so you have two solutions: the first one is to create all the users…the second one (the smartest) is to enable anonymous authentication in your XMPP server.

Anonymous authentication is a standard login using classical login and password mechanisms, but where password is accepted or preconfigured for all anonymous users. This login is compliant with sasl authentication, password and digest non-sasl authentication. For more information see this.

On ejabberd, to provide anonymous authenticatio to users you have to tune your configuration file as follows:

1) set up two virtual hosts on the server, one public (any user can login) and one private (login only with valid credentials):

{hosts, ["private.yourdomain", "public.yourdomain"]}.

2) set the global authentication method that you will use. In our case we will  authenticate against ejabberd internal database, but alternative solutions can be MySQL, PostgreSQL, LDAP and so on:

{auth_method, internal}.

3) At the end override the host_config options to provide anonymous login to public host’s clients:

{host_config, "public.yourdomain", [{auth_method, anonymous},
                                     {anonymous_protocol, login_anon}]}.

Just start/restart your ejabberd from this point you can connect to the virtual host “public.yourdomain” with any pair (JID, pwd) but you will be able to authenticate against  “private.yourdomain” only with a valid pair.

Ok, now you have anonymous authentication enabled in you XMPP server!

This week I’m really busy 😦 , so I will teach you how to use Tsung and how to configure it for our purposes in the next post.