Class Index

Classes


Class Result

Class Summary
Constructor Attributes Constructor Name and Description
 
Result()
Represents the Result being produced for the currently playing Composition.
Field Summary
Field Attributes Field Name and Description
{long}  
id
The ID of the Result in the Repository.
<constant> {integer}  
An indicator to be passed in for the "level" parameter of the "postMessage" method.
<constant> {integer}  
An indicator to be passed in for the "level" parameter of the "postMessage" method.
<constant> {integer}  
An indicator to be passed in for the "level" parameter of the "postMessage" method.
<constant> {integer}  
An indicator to be passed in for the "level" parameter of the "postMessage" method.
{String}  
The name of the Result in the Repository (the base name only, does not include the path).
{String}  
The "summary" text that will be shown in the Result for the Composition.
Method Summary
Method Attributes Method Name and Description
 
postMessage(level, titleText, detailsText)
Adds a custom event to the Result object with the given title and detail text.
 
recordActionCompletion(target, action)
Records the completion of a simulated Action (Message) into the Result.
 
Records the completion of a simulated Transaction that was started previously via the recordTransactionCompletion method.
 
Records the start of a simulated Transaction into the Result.
Class Detail
Result()
Represents the Result being produced for the currently playing Composition.
Field Detail
{long} id
The ID of the Result in the Repository. -1 if no Result is being written.

Read only.


<constant> {integer} LEVEL_ERROR
An indicator to be passed in for the "level" parameter of the "postMessage" method.

<constant> {integer} LEVEL_INFO
An indicator to be passed in for the "level" parameter of the "postMessage" method.

<constant> {integer} LEVEL_STATISTICS
An indicator to be passed in for the "level" parameter of the "postMessage" method.

<constant> {integer} LEVEL_VERBOSE
An indicator to be passed in for the "level" parameter of the "postMessage" method.

{String} name
The name of the Result in the Repository (the base name only, does not include the path). Null if no Result is being written.

Read only.


{String} summary
The "summary" text that will be shown in the Result for the Composition.

Summary text also displays on the status line while the Composition is playing.

If the summary text is not set by a Script, it will contain the text of the first error that occured during the Composition. If the summary text is set by a Script, the text set by the Script takes precedence over any error text that would ordinarily display.

Example of setting the summary text to a custom value:

$context.result.summary = "I got to here.";
Method Detail
postMessage(level, titleText, detailsText)
Adds a custom event to the Result object with the given title and detail text.

Example of posting a custom informational event to the Result:

$context.result.postMessage($context.result.LEVEL_INFO, "Hello, world!");

Example of posting a custom error event with multi-line details to the Result:

var details = "The error happened at:\n" + Date.now() + "\nAnd the value of i was:\n" + i;
$context.result.postMessage($context.result.LEVEL_ERROR, "An error happened.", details);
Parameters:
{integer} level

One of the LEVEL_xxxx indicators.

{String} titleText

Title text. Should be a single line only.

{String} detailsText Optional, Default: null

Optional detail text. Can be multiple lines.


recordActionCompletion(target, action)
Records the completion of a simulated Action (Message) into the Result. Typically used when custom Java Code inside a Custom Module is used to implement some sort of custom Message-like capability, this function allows those actions, and their statistics, to be recorded in the Result as if they were standard Messages.

This method does not actually cause any Message sending or receiving, it is used to record such activity when it is done in some other way other than via a standard Message.

Typically the Script would make one or more calls to Java in one or more Custom Modules. Those calls would return information and statistics about what happened, and then this this function would be called one or more times by the Script to record in the Composition's Result what happened.

This function has two required parameters. Both parameters can be any type of JavaScript object, although usually they would just be plain Objects. Each object is expected to have certain properties with certain pre-defined names.

The target object is expected to have property values that describe the target of the action. This takes the place of the Target object that a standard Message would have. It is expected to have the following property values:

Property name Value type Required? Description
name String Yes The name by which the Target of this action is known within it's Clip in the Composition (the Clip within which the calling Script resides). This cannot be the same as the name used for any real Target within the Clip.

This name is used to "consolidate" or "link up" actions to the same Target. If two simulated actions within the same Clip give the same simulated target name, they will be considered to be using that same single target for Result reporting purposes.

repositoryPath String Yes See repositoryName.
repositoryName String Yes repositoryName and repositoryPath are the Repository names to be used for this simulted target, as if it was a real Target that came from the Repository. This can be any name and path desired and need not necessarily match the name of any real object in the Repository. However, it should be a correctly-formatted Repository path and name.

repositoryName and repositoryPath are ignored if the target had already been created earlier and this is a later call that "links up" with the same target.

For Results reporting purposes, the Repository path and name are used to aggregate the data for Targets that are used in multiple places within the Composition. If two simulated targets have the same Repository name and path, Results reporting will consider this to be the same Target used in multiple places, and in some displays will combine the data for those two simulated targets.

The action object is expected to have property values that describe the action that was taken. This takes the place of the standard Message object. It is expected to have the following property values:

Property name Value type Required? Description
parentPathType String No See parentName
parentName String No parentPathType and parentPath specify the "starting point" of the path, and the path itself, respectively, to the containing item into which this action is to be recorded. These are relative to the context in which the current Script is playing, as specified for property paths within "In Situ Substitution Specifications" (ISSEs).

Refer to the separate documentation on ISSEs on CloudLink for more information about pathing.

The parent item specified must be a Clip or a container within a Clip, and must be an item that is currently playing (has started but has not yet completed). Typically this might be either some parent of the current Script, or else a simulated Transaction that was started earlier by calling the recordTransactionStart() method.

If these members are null, the parent of the current Script will be used as the parent.

name String Yes The name to be assigned to the action. Corresponds to the name of a Message if this had been a standard Message. This name cannnot be the same as the name of any other object in the parent container
repeatIndex integer No An optional repeat index if the simulated action is to be considered to be repeating. Negative or omitted means no repeat. The index cannot be the same as any other index given with the same name previously. Gaps within the indexes are permitted.
operation String No The "operation" for this action. This can be any string desired, it is merely reported in the Result, in the same way that "GET", "POST", etc. are reported for an HTTP Message.
url String No The "URL" for this action. This can be any string desired, it is merely reported in the Result.

Although this URL is not used to perform any actual processing, it will still be parsed during Result processing and therefore if given it should be a correctly-formatted URL.

The URL is used in the "URL Analysis" and "Error Analysis" widgets, as well as some charts that are shown by domain. At this time, no Results displays use the query string portion of the URL, but other parts of the URL, such as the protocol and domain are used.

failureText String No If the action is to be considered as having failed, this is the error text for the failure. This text is used only if the "completionType" is "Fail"
validationPassed boolean No True if the action's "validation" is to be considered to have passed for Result reporting purposes. True is assumed if omitted.
textSent String No The text that was sent for this action, to be reported in the Result.
textReceived String No The text of the response that was received for this action, to be reported in the Result.
completionType String Yes The completion type for this action. Must be "Success", "Fail", or "Stop". Not case sensitive.
duration integer No The length of time, in milliseconds, spent actually communicating to perform this action, in milliseconds. Zero is assumed if omitted.
deltaFromScheduledStart integer No The difference, in milliseconds, between the time this action was "scheduled" to be started and when it was actually started. Usually only meant to be used for Timed Clips. If omitted, it is assumed that there was no scheduled time to compare against.
bytesSent integer No The number of bytes sent for this action. Zero is assumed if omitted.
bytesReceived integer No The number of bytes received for this action. Zero is assumed if omitted.
totalPortRetryCount integer No The number of retries required to obtain a port from the OS in order to perform this action. Zero is assumed if omitted.
totalPortRetryTime integer No The amount of time, in milliseconds, spent retrying to obtain a port from the OS in order to perform this action. Zero is assumed if omitted.
connectionEstablishTime integer No The amount of time, in milliseconds, spent establishing a connection for this action. Zero is assumed if omitted.
sendTime integer No The amount of time, in milliseconds, spent sending for this action. Zero is assumed if omitted.
receiveTime integer No The amount of time, in milliseconds, spent receiving for this action. Zero is assumed if omitted.
totalTime integer No The total amount of time, in milliseconds, spent for this action, including communication time and other overhead processing time. Zero is assumed if omitted.
ttfb integer No Time to first byte, in milliseconds. Zero is assumed if omitted.
ttlb integer No Time to last byte, in milliseconds. Zero is assumed if omitted.
dnsLookupDuration integer No The amount of time, in milliseconds, spent performing DNS lookup for this action. Zero is assumed if omitted.
waitForConnectionPoolTime integer No The amount of time, in milliseconds, spent waiting on a Connection Pool for this action. Zero is assumed if omitted.

Here is an example Script. It is assumed that there is a Custom Module that contains a Java class named "org.example.ExampleSender" that implements the sending in a method called "sendSomething" and returns the result of the send in a Java class named "ExampleSenderOutput" that contains public members for each of the values being returned.

importPackage(org.example);

// Invoke the Java code in the Custom Module to do the actual sending.
var exampleSender = new ExampleSender();
var exampleSenderOutput = exampleSender.sendSomething("Some text to send");

// Create the JS object to represent the simulated Target.
var pretendTarget = new Object();
pretendTarget.name = "My Target";
pretendTarget.repositoryPath = "/Some folder name";
pretendTarget.repositoryName = "My pretend Repository Target";

// Create the JS object to represent the action that was just executed.
var pretendAction = new Object();
pretendAction.name = "My action";
pretendAction.repeatIndex = -1;
pretendAction.operation = exampleSenderOutput.m_operation;
pretendAction.url = exampleSenderOutput.m_url;
pretendAction.failureText = exampleSenderOutput.m_failureText;
pretendAction.validationPassed = exampleSenderOutput.m_validationPasses;
pretendAction.textSent = exampleSenderOutput.m_textSent;
pretendAction.textReceived = exampleSenderOutput.m_textReceived;
pretendAction.duration = exampleSenderOutput.m_duration;
pretendAction.completionType = exampleSenderOutput.m_completionType;
pretendAction.deltaFromScheduledStart = exampleSenderOutput.m_deltaFromScheduledStart;
pretendAction.bytesSent = exampleSenderOutput.m_bytesSent;
pretendAction.bytesReceived = exampleSenderOutput.m_bytesReceived;
pretendAction.totalPortRetryCount = exampleSenderOutput.m_totalPortRetryCount;
pretendAction.connectionEstablishTime = exampleSenderOutput.m_connectionEstablishTime;
pretendAction.sendTime = exampleSenderOutput.m_sendTime;
pretendAction.receiveTime = exampleSenderOutput.m_receiveTime;
pretendAction.totalTime = exampleSenderOutput.m_totalTime;
pretendAction.ttfb = exampleSenderOutput.m_ttfb;
pretendAction.ttlb = exampleSenderOutput.m_ttlb;
pretendAction.dnsLookupDuration = exampleSenderOutput.m_dnsLookupDuration;
pretendAction.waitForConnectionPoolTime = exampleSenderOutput.m_waitForConnectionPoolTime;

// Record the action in the Result.
$context.result.recordActionCompletion(pretendTarget, pretendAction);

Note that the above approach was used for illustrative purposes, but another approach might be to have the Java code return a Java object that contains exactly all of the members expected for the "action" parameter, and then that object could be passed directly to the recordActionCompletion call. In that case, the Script would look as follows:

importPackage(org.example);

// Invoke the Java code in the Custom Module to do the actual sending.
// In this case, the Java code is expected to return an object that contains
// exactly all of the members expected by "recordActionCompletion".
var exampleSender = new ExampleSender();
var exampleSenderOutput = exampleSender.sendSomething("Some text to send");

// Create the JS object to represent the simulated Target.
var pretendTarget = new Object();
pretendTarget.name = "My Target";
pretendTarget.repositoryPath = "/Some folder name";
pretendTarget.repositoryName = "My pretend Repository Target";

// Record the action in the Result.
$context.result.recordActionCompletion(pretendTarget, exampleSenderOutput);

When the Composition Result is viewed in the Results Viewer, the Clip in which the Script resides will show a Target named "My Target" and the container in which the Script resides will show a Message named "My action", along with events showing the information shown for any Message, such as what was sent and what was received. In addition, the statistics for the action will be added to the various widget displays and charts as appropriate.

Parameters:
{object} target

An object with property values that describe the the "Target" of the operation.

{object} action

An object with property values that describe the action that was taken and the result of that action.

Since:
Build 6594

recordTransactionCompletion(transaction)
Records the completion of a simulated Transaction that was started previously via the recordTransactionCompletion method.

This function has one required parameter. It can be any type of JavaScript object, although usually it would just be a plain Object. The object is expected to have certain properties with certain pre-defined names.

The object is expected to have property values that describe the Transaction to be completed. It is expected to have the following property values:

Property name Value type Required? Description
parentPathType String No See parentName
parentName String No parentPathType and parentPath specify the "starting point" of the path, and the path itself, respectively, to the containing item of this Transaction. These are relative to the context in which the current Script is playing, as specified for property paths within "In Situ Substitution Specifications" (ISSEs).

Refer to the separate documentation on ISSEs on CloudLink for more information about pathing.

The values given in this method must match the values given in the recordTransactionStart method.

name String Yes The name that was assigned to the Transaction by the recordTransactionStart method.
repeatIndex integer No The repeat index that was assigned to the Transaction by the recordTransactionStart method.
completionType String Yes The completion type for this Transaction. Must be "Success", "Fail", or "Stop".
failureText String No If the Transaction is to be considered as having failed, this is the error text for the failure. This text is used only if "completionType" is "Fail"
actualDuration integer No The actual duration of the Transaction in milliseconds. If this value is less than zero or omitted, the duration will be computed by subtracting the time of this call from the start time.
effectiveDuration integer No The "effective" duration of the Transaction in milliseconds. If this value is less than zero or omitted, the actual duration will be used as the "effective" duration.
Parameters:
{object} transaction

An object with property values that specify the the Transaction and innformation about it's completion.

Since:
Build 7038

recordTransactionStart(transaction)
Records the start of a simulated Transaction into the Result. It will be recorded into the Result similar to a standard Transaction object that would appear inside of a Clip.

The Transaction will be empty unless simulated actions are recorded inside of it using the recordActionCompletion method, and/or nested Transactions are created inside of it using this method.

Code that is adding simulated actions to the Result can also create Transactions and place the actions inside of those Transactions, to control how things appear and how statistics are computed in the Result.

This function has one required parameter. It can be any type of JavaScript object, although usually it would just be a plain Object. The object is expected to have certain properties with certain pre-defined names.

The object is expected to have property values that describe the Transaction to be started. It is expected to have the following property values:

Property name Value type Required? Description
parentPathType String No See parentName
parentName String No parentPathType and parentPath specify the "starting point" of the path, and the path itself, respectively, to the containing item into which this action is to be recorded. These are relative to the context in which the current Script is playing, as specified for property paths within "In Situ Substitution Specifications" (ISSEs).

Refer to the separate documentation on ISSEs on CloudLink for more information about pathing.

The parent item specified must be a Clip or a container within a Clip, and must be an item that is currently playing (has started but has not yet completed). Typically this might be either some parent of the current Script, or else a simulated Transaction that was started earlier by calling the recordTransactionStart() method.

If these members are null, the parent of the current Script will be used as the parent.

name String Yes The name to be assigned to the Transaction. This name cannnot be the same as the name of any other object in the parent container
repeatIndex integer No An optional repeat index if the simulated Transaction is to be considered to be repeating. Negative or omitted means no repeat. The index cannot be the same as any other index given with the same name previously. Gaps within the indexes are permitted.
startTime integer No The start time of the Transaction, a value as would be returned by Date.getTime(). If this value is negative or omitted, the start time will be assumed to be the time of this call.
deltaFromScheduledStart integer No The difference, in milliseconds, between the time this action was "scheduled" to be started and when it was actually started. Usually only meant to be used for Timed Clips. If omitted, it is assumed that there was no scheduled time to compare against.
Parameters:
{object} transaction

An object with property values that describe the the Transaction.

Since:
Build 7038

SOASTA CloudTest Script Documentation (build 8744.736). Copyright 2006-2011. All rights reserved.