Tsung load testing for MongooseIM (websockets)

1.8k views Asked by At

My question is about configuring my tsung.xml file to load-test chat application.

So, we have our MongooseIM server on the server side, jsjac.js library for our web-based client. We use xmpp and websockets to communicate.

httpbase for jsjac is looks like ws://hostname:5288/ws-xmpp/ and this part works fine for me. Tsung is supports websockets "from the box" and everybody says that the best way to test websockets - is to use tsung. But there is not so much information about how to do that.

Here is my tsung.xml:

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
  <clients>
    <client host="localhost" use_controller_vm="true" maxusers="10" />
  </clients>

  <servers>
    <server host="hostname" port="5288" type="tcp" />
  </servers>

  <load>
    <arrivalphase phase="1" duration="10" unit="second">
      <users maxnumber="1" arrivalrate="1" unit="second" />
    </arrivalphase>
  </load>

  <sessions>
    <session name="websocket" probability="100" type="ts_websocket">
        <request subst="true">
             <websocket type="connect" path="/ws-xmpp"></websocket>
        </request>

        <request>
            <dyn_variable name="uid" jsonpath="uid"/>
            <websocket type="message">{"user":"bob", "password":"bob"}</websocket>
        </request>  

        <request subst="true">
            <match do="log" when="nomatch">ok</match>
            <websocket type="message">{"uid":"%%_uid%%", "data":"data"}</websocket>
        </request>

        <request>
        <websocket type ="message">{"key":"value"}</websocket>      
        </request>

        <request>
            <websocket type="close"></websocket>
        </request>
    </session>
  </sessions>
</tsung>

and after test passed the result is:

connected: 0
finish_users_count: 1
users: 1
users count: 1
websocket_succ: 1

user "bob" is really exist in server's db and works fine via client application.

Can anybody tell me what i'm doing wrong?
Or maybe someone could provide a link to some article or working xml file?
Thanks.

2

There are 2 answers

0
WcN On

There was a couple of things to do... so,first of all, BIG THANKS to Piotr! his response (+ jabber scenario example) has helped to solve my problem

here is my working tsung.xml

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
  <clients>
    <client host="localhost" use_controller_vm="true"></client>
  </clients>
  <!-- Server side setup -->
 <servers>
  <server host="servernameOrIp" port="5288" type="websocket"></server>
 </servers>
  <load>
   <arrivalphase phase="1" duration="20" unit="second">
    <users interarrival="1" unit="second"></users>
   </arrivalphase>
  </load>
  <!-- JABBER parameters -->
 <options>
  <option type="ts_jabber" name="global_number" value="20"></option>
  <option type="ts_jabber" name="userid_max" value="20"></option>
  <option type="ts_jabber" name="domain" value="servernameOrIp"></option>
  <option type="ts_jabber" name="username" value="user00"></option>
  <option type="ts_jabber" name="passwd" value="user00"></option>
  <option name="websocket_path" value="/ws-xmpp"/>
 </options>

  <sessions>
   <session probability="100" name="jabber-example" type="ts_jabber">
    <request> <jabber type="connect" ack="no_ack"></jabber> </request>
    <thinktime value="2"></thinktime>
    <transaction name="authenticate">
    <request><jabber type="auth_sasl" ack="local" /></request>
    <request><jabber type="connect" ack="local" /></request>
    <request><jabber type="auth_sasl_bind" ack="local" /></request>
    <request><jabber type="auth_sasl_session" ack="local" /></request>
    </transaction>
    <request> <jabber type="presence:initial" ack="no_ack"/> </request>
    <thinktime value="10"></thinktime>
    <transaction name="roster">
      <request> <jabber type="iq:roster:get" ack="local"></jabber></request>
    </transaction>
    <thinktime value="10"></thinktime>
    <transaction name="online">
    <request> <jabber type="chat" ack="no_ack" size="16" destination="online"></jabber> </request>
    </transaction>
    <thinktime value="10"></thinktime>
    <transaction name="offline">
      <request> <jabber type="chat" ack="no_ack" size="56" destination="offline"></jabber> </request>
    </transaction>
    <thinktime value="2"></thinktime>
    <transaction name="close">
      <request> <jabber type="close" ack="no_ack"></jabber> </request>
    </transaction>
  </session>
 </sessions>
</tsung>

with this tsung is generates 20 users (user001 - user0020) and i can see them all in my "bob's" roster. I use a Spark IM client to monitor this.

1
Piotr Nosek On

Best way to test XMPP over Websockets is to use standard Jabber scenario with specific server configuration:

<servers>
  <server host="localhost" port="5288" type="websocket"></server>
</servers>

<options>
  (...)
  <option name="websocket_path" value="/ws-xmpp"/>
</options>

Sample Jabber scenario can be found e.g. in "examples" directory in Tsung repo. I think plaintext login is used there so if you'll still have problem connecting users, replace transaction "authenticate" with:

<transaction name="authenticate">
  <request><jabber type="auth_sasl" ack="local" /></request>
  <request><jabber type="connect" ack="local" /></request>
  <request><jabber type="auth_sasl_bind" ack="local" /></request>
  <request><jabber type="auth_sasl_session" ack="local" /></request>
</transaction>