Search code examples
erlangtsung

Tsung dynamic variables scope


I want to write a test case for a user hitting a websockets server with thousands of different packets generated by tsung, but I received only the same packet thousands of times.

What is the scope of Tsung's dyn variables?

....
<session name="websocket" probability="100" type="ts_websocket">
  <setdynvars sourcetype="random_number" start="9" end="16">
    <var name="randomNum" />
  </setdynvars>
  <for from="1" to="10" incr="1" var="counter">
    <request subst="true">
      <websocket frame="text" ack="no_ack" type="message">
        {"randomNumber":%%_randomNum%%}
      </websocket>
    </request>
  </for>
</session>
....

For each user I'll receive 10 messages all with the same "randomNumber", but I want the number to change between each of those 10 messages.


Solution

  • We can close the question I just need to put dyn_variable inside for each.