Random values
Use random numbers or strings for your step properties to generate them at runtime. For example, test an entire workflow where the exact values aren't crucial.
This topic describes the types of random values you can generate in your simulation.
Generate random text
To generate a random mix of numbers and letters, use the syntax {RANDOMTEXT[<length of random text>]} in the Insert step property.
Generate random number
You can create random numbers as a value for a message element.
-
Specify a random number using one of these methods:
-
To generate a random number with a maximum length, use the syntax {RND[<Length of random number>]}. You can have a maximum of 19 digits.
-
To generate a random number within a range, use the syntax {RND[<Lower limit>][<Upper limit>]}. The lower limit must be less than the upper limit, and negative values are possible. The generated integer is a value between the upper and lower limit, including boundaries.
-
-
Use the Insert step property to define a random number.
This example creates a 7-digit number:
schema: SimV1
- name: Service05
steps:
- direction: In
trigger:
- uri: '*'
- direction: Out
insert:
- value: '{RND[7]}'
This example creates an integer number between -789 and 123:
schema: SimV1
- name: Service06
steps:
- direction: In
trigger:
- uri: '*'
- direction: Out
insert:
- value: '{RND[-789][123]}'
Generate unique IDs
You can create a unique ID as a value for a message element. Unique IDs are generated sequentially, and each ID is assigned only once. Specify the length of the unique ID using the syntax {UNIQUEID[<length of uniqueID>]} in the Insert step property.
If there aren't enough IDs available and the system can't generate new IDs, an error occurs. Restart the environment to reset the unique IDs, or increase the length of the unique IDs.
In this example, you generate a unique ID that ranges from 0 to 9:
schema: SimV1
- name: Service07
steps:
- direction: In
trigger:
- uri: '*'
- direction: Out
insert:
- value: '{UNIQUEID[1]}'
Generate random strings with regular expressions
To generate a random string based on Microsoft regular expressions, use the syntax {RANDOMREGEX["<Regular expression>"]} in the Insert step property. For information on the rules and syntax of regular expressions, see the Microsoft REGEX documentation (opens in new tab).
The expression {RANDOMREGEX["^[A-Z][a-z]+[0-9]{4}$"]} creates a value that starts with an uppercase letter between A and Z, followed by any number of lowercase letters, and exactly four digits between 0 and 9. The ^ character marks the beginning of the line, and $ marks the end of the line.
This expression creates, for instance, Ecqwp1989.
Specify a time stamp
The dynamic expression {TIMESTAMP} returns the number of milliseconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.
Specify a time stamp using the Insert step property.
Use a counter
Use the dynamic expression {COUNTER} to set how many times a specified message should be sent or received before proceeding to the next step.
Use a counter with the Insert step property.