tsungテストopenfire時にCSVファイルからuser情報を読み込む

8256 ワード

csvファイルからユーザー名とパスワードを取得
Configure the CSV file:
<options>
<option name="file_server" id=’userdb’ value="/home/foo/.tsung/users.csv"/>
</options>

And then you have to defined two variables of type file, and the first jabber request (connect) must
include a xmpp_authenticate tag:
<session probability="100" name="jabber-example" type="ts_jabber">
    <setdynvars sourcetype="file" fileid="userdb" delimiter=";" order="iter">
        <var name="username" />
        <var name="password" />
    </setdynvars>
        <request subst='true'>
            <jabber type="connect" ack="no_ack">
                <xmpp_authenticate username="%%_username%%" passwd="%%_password%%"/>
            </jabber>
        </request>
    <thinktime value="2"></thinktime>
    <transaction name="authenticate">
        <request>
            <jabber type="auth_get" ack="local"> </jabber>
        </request>
        <request>
            <jabber type="auth_set_plain" ack="local"></jabber>
        </request>
    </transaction>
    ...
</session>
テストスクリプト
<?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="192.168.1.1" port="5222" type="tcp"></server>
 </servers>
    
  <load>
   <arrivalphase phase="1" duration="1" unit="minute">
    <users interarrival="2" unit="second"></users>
   </arrivalphase>
  </load>
    
  <!-- JABBER parameters -->
  <!-- to synchronise users,  use a global acknoledgement -->
 <options>
  <option type="ts_jabber" name="global_number" value="100"></option>
  <option type="ts_jabber" name="userid_max" value="10000"></option>
  <option type="ts_jabber" name="domain" value="mydomain.org"></option>
  <option type="ts_jabber" name="username" value="user"></option>
  <option type="ts_jabber" name="passwd" value="pass"></option>
  <option name="file_server" id='userdb' value="/home/succers/.tsung/userdb.csv"/>
 </options>
    
  <sessions>
   <session probability="50" name="jabber-example" type="ts_jabber">
    <setdynvars sourcetype="file" fileid="userdb" delimiter=";" order="iter">
      <var name="username"/>
      <var name="password"/>
    </setdynvars>
    <request subst='true'> 
    <jabber type="connect" ack="no_ack">
     <xmpp_authenticate user="%%_username%%" pass="%%_password%%"/>
    </jabber> </request>
    <thinktime value="2"></thinktime>
    <transaction name="authenticate">
      <request> <jabber type="auth_get" ack="local"></jabber> </request>
      <request> <jabber type="auth_set_plain" ack="local"></jabber> </request>
    </transaction>
    
    <request> <jabber type="presence:initial" ack="no_ack"/> </request>
    <thinktime value="2"></thinktime>
    
    <transaction name="roster">
      <request> <jabber type="iq:roster:get" ack="local"></jabber></request>
    </transaction>
    
    <thinktime value="30"></thinktime>
    
    <transaction name="online">
    <request> <jabber type="chat" ack="no_ack" size="16" destination="online"></jabber> </request>
    </transaction>
    
    <thinktime value="30"></thinktime>
    
    <transaction name="offline">
      <request> <jabber type="chat" ack="no_ack" size="56" destination="offline"></jabber> </request>
    </transaction>
    
    <thinktime value="30"></thinktime>
    
    <transaction name="close">
      <request> <jabber type="close" ack="no_ack"></jabber> </request>
    </transaction>
    
  </session>
    
  <session probability="20" name="jabber-plain" type="ts_jabber">
    
    <request> <jabber type="connect" ack="no_ack"></jabber> </request>
    
    <thinktime value="2"></thinktime> 
    
    <transaction name="auth_plain">
      <request> <jabber type="auth_get" ack="local"></jabber> </request>
      <request> <jabber type="auth_set_plain" ack="local"></jabber> </request>
    </transaction>
    
    <thinktime value="30"></thinktime>
    
    <transaction name="close">
      <request> <jabber type="close" ack="no_ack"></jabber> </request>
    </transaction>
    
  </session>
    
        
    
  <session probability="20" name="jabber-digest" type="ts_jabber">
    
    <!-- regexp captures stream ID returned by server -->
    <request>
      <dyn_variable name="sid" re="&lt;stream:stream id=&quot;(.*)&quot; xmlns:stream"/>
      <jabber type="connect" ack="local"></jabber>
    </request>
    
    <thinktime value="2"></thinktime>
    
    <transaction name="auth_digest">
      <request> <jabber type="auth_get" ack="local"></jabber> </request>
      <request subst='true'> <jabber type="auth_set_digest" ack="local"></jabber> </request>
    </transaction>
    <thinktime value="30"></thinktime>
    
    <transaction name="close">
      <request> <jabber type="close" ack="no_ack"></jabber> </request>
    </transaction>
  </session>
    
        
        
    
  <session probability="10" name="jabber-sipdigest" type="ts_jabber">
    
    <request> <jabber type="connect" ack="no_ack"></jabber> </request>
    
    <thinktime value="2"></thinktime>
    
    <transaction name="auth_sipdigest">
      <!-- regexp captures nonce value returned by server -->
      <request>
        <dyn_variable name="nonce" re="&lt;Nonce encoding=&quot;hex&quot;&gt;(.*)&lt;\/Nonce&gt;"/>
        <jabber type="auth_get" ack="local"></jabber>
      </request>
      <request subst='true'> <jabber type="auth_set_sip" ack="local"></jabber> </request>
    </transaction>
    <thinktime value="30"></thinktime>
    
    <transaction name="close">
      <request> <jabber type="close" ack="no_ack"></jabber> </request>
    </transaction>
  </session>
    
        
    
    
 </sessions>
</tsung>