Zong. variable_from content_from_file

I have a problem using tsung:

I have several files in one directory that I have to send to the server. I create a file with a list of these files (full path) and add the tsung configuration parameter:

<option name="file_server" id="xml_files" value="/home/ubuntu/.tsung/files"></option> 

My goal is to select a random file path from this file and send the server. For this, I wrote this config part:

  <setdynvars sourcetype="file" fileid="xml_files" delimiter=";" order="random"> <var name="file_name" /> </setdynvars> <request subst="true"> <http url="/" version="1.1" method="POST" contents_from_file="%%_file_name%%"></http> </request> 

But that does not work. When I set attr contents_from_file as a constant everything works fine. Is there a way to do this with a variable?

+7
source share
1 answer

I have a similar job, I am using tsung 1.5.0. you can try:

 <request subst="true"> <http url="/" version="1.1" method="POST" contents="%%readafile:readrnd%%"></http> </request> 

where readfafile is your own module that exports the readrnd function. readrnd should return the contents of a random file. Note: the file name will be binary when reading from the file source, you may need to serialize.

instead:

 <request subst="true"> <http url="/" version="1.1" method="POST" contents_from_file="%%_file_name%%"></http> </request> 
+2
source

All Articles