- Subscribe to RSS Feed
- Bookmark
- Subscribe
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content
|
This topic presents miscellaneous SOASTA CloudTest scripts. Scripts can be copied and pasted directly into the SOASTA CloudTest Script Editor using Central > Scripts. Longer scripts have an accompanying image that can be clicked to pop out the full example s ript. Shorter scripts are presented inline (in the right column). |
|
Miscellaneous Scripts |
|
In those cases where you need a script to skip playing the remainder of the current repeat of the current test clip, you would do: |
|
|
If the clip was serially repeating and you want to end it completely, including stopping it from repeating any further, you would do: |
|
|
If the clip was serially repeating and you wanted the current repeat to finish, but not repeat any more after that, you would do: |
|
|
Optionally, if you want to cause the container to error out, supply error text like in the following example: |
|
msg.clearResponse();) is the main part of this script. It is useful for ensuring that large responses do not stay in memory if they are no longer needed. |
|
This Random Think Times script resets all subsequent delays to have a random think time between the interval specified in the script below. If you want to set all delays to zero, just set both the minimum and maximum delay times to zero. |
|
Immediately aborts play of the current Script, and considers the Script to have failed with the given error text. If no error text is provided, the text “Script aborted.” is used. So, for example, in those cases where the eval/throw statement is used (such as in the Validation Scripts), you could instead do: |
|
This overrides a target to either use or not use SSL (i.e. HTTP to HTTPS or vice versa). |
|
Stopping a composition using a script is a simple, one-line operation calling the |
|
This example shows how to URL encode text. This is useful in cases where certain characters like a plus sign (+) need to be encoded to go on a URL – as %2B. This script is also useful because it shows how to create a function that performs the encoding. This function can be called multiple times in the script. |
|
|
Another example of using the replace function to do encoding is presented in the right column. This script uses different statements for each replacement rather than combining them together (as the first example shows). |
|
The example script on the right is not run in a separate script object – it is run directly in the query string parameter of a message. In this example, it is adding the VUNumber property value to 500. Note: all properties are a string, so the property needs to be converted to a number before it can be used in math calculations. |
|
This creates an array with all of the values of the href tags in the response. |
|
|
To print out the values in the result as a comma-separated list: |
|
|
To print out the values in the result as separate lines: |
|
The Determine dates 30 and 31 days from now script calculates today's date in the individual pieces of month, day, and year in both 2 and 4 digits. It then calculates two other dates in individual parts based on today's date. These two dates are 30 and 31 days into the future from today's date. |
|
The following brief script reads a clip property into a test using a variable.
|
|
The brief script on the right is used to trim spaces from a string. |
|
The Conditional Logic using Chains and Random Numbers script plays a chain 10% of the time and turns it off the remaining 90% of the time. |
|
|
Lines 12-14 generate a random integer contained within the two extremes. |
|
|
Line 20 creates a variable, chain, that gets the child of the name specified. |
|
|
Lines 23-25 generate a random number between 1-10. |
|
|
Use the var, num1, from above to play the clip, otherwise set it to 0 using |
|
This simple script replaces any spaces in the |
|
This script precedes a chain in a test clip and sets the number of chain repeats to 10 dynamically during test execution. |
|
Script 14-1 and Script 14-2 work together to simulate DNS lookups (over a defined set of IP addresses). Script 14-1 randomly picks an IP address from a specified list and sets the target IP address and hostname for the next message with the randomly selected IP information. In cases where both HTTP and HTTPS targets need to be set with the randomly selected IP information, Script 14-2 performs a host override for the second target. For example, if the first target is HTTP, place Script 14-1 before the first message that uses the HTTP target (e.g. using nextItem) and Script 14-2 before the first message that uses the HTTPS target. In the Script 14-1 example, there are four IP addresses in use:
On each test clip, randomly select one of these IP addresses to run the test against. Once the random IP is selected, Script 14-2 does a host override to point to <a href="http://your.domain.com/" target="_blank">http://your.domain.com/> your.domain.com/ <http://your.domain.com/> . Put Script 1 before the first target. Put Script 2 before the second target using that hostname. So, if the first target is HTTP, put Script 1 the first message that uses the HTTP target and Script 2 before the first message that uses the HTTPS target. |
Script 14-1
Script 14-2
|




