Dynamic variable on Tsung XML config file

357 views Asked by At

I've set up TSUNG (v1.7) to test my application, but I'm facing some problem using a dynamic variable on my http request. To be more precise I need to retrieve some data from a CSV file and inserting it in my request.

Reading the documentation it seems that I don't really need to write any sort of functions, since I'm using a version above the 1.3, so to achieve that I just need to specify the file path on the 'option' tag and use the 'setdynvars', but unfortunately it doesn't seems works (the web server response says that the content is empty). Any idea why?

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/home/Desktop/tsung-1.7.0/tsung-1.0.dtd">
<tsung loglevel="warning">
    <clients>
        <client host="localhost" use_controller_vm="true"/>
    </clients>

    <servers>
        <server host="127.0.0.1" port="8000" type="tcp"/>
    </servers>

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

    <options>
        <option name="file_server" id="transactions" value="/home/Desktop/transactions.csv"/>  
    </options>

    <sessions>

        <session name="dummy" weight="1" type="ts_http">
            <setdynvars sourcetype="file" fileid="transactions" delimiter=";" order="iter">
                <var name="number_transaction"/>
            </setdynvars>

            <request>
                <http url="...path..." method="GET" version="1.1"></http>
            </request>

            <request subst="true"> 
                <http url='...path...' version='1.1' contents='transaction_id=%%_number_transaction%%' content_type='application/x-www-fomr-urlencoded' method='POST'></http>
            </request>
        </session>

    </sessions>
</tsung>
2

There are 2 answers

0
Fabio On BEST ANSWER

After some attempt I've figure out that by simply removing the attribute content_type from the request it will make the whole configuration works!

0
Artan M. On

There is a typo on the content_type but you should be able to do something like this.

<request subst="true">
       <http
           url='/path'
           method='POST'
           version='1.0'
           content_type='application/x-www-form-urlencoded'
           contents='transaction_id=%%_number_transaction%%'>

          <http_header name="Authorization" value="Bearer %%_token%%"/>
          <http_header name="Cache-Control" value="no-cache"/>

       </http>
    </request>

and if you need to set any HTTP headers, you can do so inside the