25 Using the Block Scenarios Module

This chapter provides instructions on using the OpenScript Block Scenarios Module, which provides support for generating complex Virtual User scenarios.

25.1 About the Block Scenario Module

The Block Scenarios Module is an auxiliary module to generate complex Virtual User scenarios. These scenarios can have multiple execution paths. When creating Block Scenarios, you specify the distribution of the execution paths by selecting the percentage of blocks and scripts that make up a path.

Block scenarios can contain both virtual user scripts and script blocks. A script block can contain one or more scripts as well as child blocks and child scripts. Specific functions within a script can also be called. Each block and script can be set to run always or be assigned a percentage that specifies the run distribution of the blocks and scripts within the block scenario. The following example shows a block scenario script in XML format (a tree view is also available in OpenScript):

<block name="Main" iterations=3">
 <script name="Login"/>
 <block name="SearchOrAct">
   <script name="Search" percent="90"/>
   <block name="Act" percent="10">
      <script name="Buy" percent="50"/>
      <script name="Sell" percent="50"/>
   </block>
 </block>
 <script name="Logout"/>
</block>

The "Main" block is the parent block of the block scenario which contains two scripts, "Login" and "Logout", and a script block, "SearchOrAct". The "SearchOrAct" script block contains one script, "Search", and a child block containing two scripts, "Buy" and "Sell".

The "Main" block is set to run three iterations. The "Main" block will always run the "Login" script, "SearchOrAct" block, and "Logout" scripts during each iteration. When the "SearchOrAct" block is run, there is a 90 percent chance the "Search" script will be run and 10 percent chance the "Act" block will be run. If the "Act" block is run, there is a 50 percent chance the "Buy" script will be run and a 50 percent chance the "Sell" script will be run.

The scenario runs scripts using a random distribution within the script blocks. Each iteration, the outcome of what the Virtual User does could be different. The percentage distribution is random, so it is not guaranteed to match the exact percentages specified. However, when run enough times to generate a large enough sample size, the results should be close to the specified percentages. The percentages set must equal 100 percent for scripts within a block, child blocks within a block, and blocks within a scenario. The percentage value displays in red in the block XML tree view of the Details view if the percentage total does not equal 100 percent.

When running with multiple virtual users, random probability will decide which path each Virtual User goes through the scenario.

Scripts must be added to the Block Scenario project as script assets before the building the block scenario in the UI.

25.2 Creating Block Scenario Projects

Block Scenario project are created similar to other script projects. However, instead of recording the scenario, scripts are added manually as script assets. The scripts and blocks are added to the block scenario tree based upon how you want to build the scenario and execution paths.

To creating a block scenario project:

  1. Start OpenScript.

  2. Select New from the File menu.

  3. Expand the Load Testing group.

  4. Select Block Scenarios Script.

  5. Click Next.

  6. Select the Repository and Workspace.

  7. Enter a script name.

  8. Click Finish. A new Script tree is created in the Script View.

  9. Add scripts to the block scenario project as script assets. See Section 25.2.1, "Adding Script Assets to Block Scenario Projects".

  10. Expand the Run node of the script and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  11. Right-click nodes in the Block XML Tree of the Details view to add blocks and scripts to the tree.

  12. Save the block scenario script when finished.

25.2.1 Adding Script Assets to Block Scenario Projects

You must add scripts as script assets to block scenario projects before building the block scenario structure. The scripts must exist before they can be added.

To add assets to a block scenario project:

  1. Open or create a block scenario project.

  2. Select the Assets tab in the script view.

  3. Select Script as the type of asset to add and click Add.

  4. Set the Relative to option. The Relative to current script and Relative to a repository options specify how the current script will locate the specified script asset. The Relative to a repository option locates the script asset by a repository path such as, [Repository: Default] Default!/WebTutor, if the asset is selected from a repository. The Relative to current script option locates the script asset by a relative path such as ../WebTutor. Selecting the The Relative to current script option is not recommended as script-relative paths are more brittle than repository-relative paths if scripts are moved or shared.

    The following are guidelines when using script assets in a team or distributed environment:

    • Do not use Absolute Paths when referring to assets or saving assets. Oracle Load Testing does not support absolute paths.

    • OpenScript, Oracle Test Manager, Oracle Load Testing, and all command-line agents should all use the same shared repository names and paths.

    • Do not refer to an asset in another repository by a relative path.

  5. Click OK to add the asset to the script properties.

  6. Repeat the steps to add all of the scripts that will be included in the block scenario project.

  7. Click OK when finished adding script assets to close the script properties.

  8. Use the right-click menu options of the Block XML Tree tab of the Details view to add blocks and scripts to the scenario.

  9. Save the block scenario script when finished.

25.3 Modifying Block Scenarios

This section explains the procedures for adding and editing blocks and scripts to the block scenario tree.

25.3.1 Adding Blocks

Blocks are used in a block scenario to create groupings of scripts and child blocks that create the structure and execution paths that make up the scenario.

To add a block to a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Right-click nodes in the Block XML Tree of the Details view and select Add Block. This dialog box lets you add or edit a script block in a Block Scenarios project.

    Name: Specifies the name of the script block.

    Iterations: Specifies the number of iterations to run the script block.

    Schedule: Specifies the scheduling of the script block.

    • Always schedule to run: When selected, the block is always run during each iteration of the block scenario.

    • Only schedule to run with [] % of VUs: When selected, the block (and script(s)/block(s) within the block) will be run the based upon the specified percentage. The scenario runs scripts using a random distribution within the script block. For example, if you define a block scenario as follows:

      <block name="Main" iterations=3">
       <script name="Login"/>
       <block name="SearchOrAct">
         <script name="Search" percent="90"/>
         <block name="Act" percent="10">
            <script name="Buy" percent="50"/>
            <script name="Sell" percent="50"/>
         </block>
       </block>
       <script name="Logout"/>
      </block>
      

      During playback with 1 VU, the VU will iterate over the "Main" block for 3 iterations. During each iteration of the "Main" block, the VU will always run the "Login" script, run either the "Search" script or the "Act" block, then always run the "Logout" script. During each iteration of the "SearchOrAct" block, there is a 90 percent chance the VU will run the "Search" script and there is a 10 percent chance the VU will run the "Act" block. In the 10 percent chance that the VU will run the "Act" block, there will be a 50 percent chance the VU will run the Buy script, and a 50 percent chance the VU will run the "Sell" script.

      The percentages set must equal 100 percent for scripts within a block, child blocks within a block, and blocks within a scenario. The percentage value displays in red in the block tree view of the Details view if the percentage total does not equal 100 percent.

  4. Enter a name for the block.

  5. Specify the number of iterations to run the block.

  6. Specify the Schedule for how the block will run. If you want the block to run always during each iteration, select Always schedule to run. If you want the block to run a percentage of the time within the scenario, select Only schedule to run with [] % of VUs and specify the percentage.

  7. Click OK.

  8. Repeat the steps to add other blocks to the scenario.

25.3.2 Adding Scripts

Scripts perform the user actions that make up the scenario.

To add a script to a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Right-click nodes in the Block XML Tree of the Details view and select Add Script. This dialog box lets you specify the scripts to include in a script block of block scenario project.

    Script: Specifies the name of the script to include in the script block.

    Run: Specifies if the entire script or a specific function within the script will be run.

    • Script: When selected, the entire script is run.

    • Specific Function: When selected, only the selected script function is run. Select the function from the list.

    Iterations: Specifies the number of iterations to run the script block.

    Schedule: Specifies the scheduling of the script block.

    • Always schedule to run: When selected, the block is always run during each iteration of the block scenario.

    • Only schedule to run with [] % of VUs: When selected, the block (and script(s)/block(s) within the block) will be run the based upon the specified percentage. The scenario runs scripts using a random distribution within the script block. For example, if you define a block scenario as follows:

      <block name="Main" iterations=3">
       <script name="Login"/>
       <block name="SearchOrAct">
         <script name="Search" percent="90"/>
         <block name="Act" percent="10">
            <script name="Buy" percent="50"/>
            <script name="Sell" percent="50"/>
         </block>
       </block>
       <script name="Logout"/>
      </block>
      

      During playback with 1 VU, the VU will iterate over the "Main" block for 3 iterations. During each iteration of the "Main" block, the VU will always run the "Login" script, run either the "Search" script or the "Act" block, then always run the "Logout" script. During each iteration of the "SearchOrAct" block, there is a 90 percent chance the VU will run the "Search" script and there is a 10 percent chance the VU will run the "Act" block. In the 10 percent chance that the VU will run the "Act" block, there will be a 50 percent chance the VU will run the Buy script, and a 50 percent chance the VU will run the "Sell" script.

      The percentages set must equal 100 percent for scripts within a block, child blocks within a block, and blocks within a scenario. The percentage value displays in red in the block tree view of the Details view if the percentage total does not equal 100 percent.

  4. Select the script to run from the Script list or click New to add a new script.

  5. Specify the number of iterations to run the script.

  6. Specify the Schedule for how the script will run. If you want the script to run always during each iteration, select Always schedule to run. If you want the script to run a percentage of the time within the block or scenario, select Only schedule to run with [] % of VUs and specify the percentage.

  7. Click OK.

  8. Repeat the steps to add other scripts to the scenario.

25.3.3 Adding Child Blocks

Child blocks can be used to create groupings of scripts and other child blocks that create the structure and execution paths that make up the scenario.

To add a child block to a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Select the node in the Block XML Tree where you want to add the child block.

  4. Right-click and select Add Block as Child.

  5. Enter a name for the child block.

  6. Specify the number of iterations to run the block.

  7. Specify the Schedule for how the block will run. If you want the block to run always during each iteration, select Always schedule to run. If you want the block to run a percentage of the time within the scenario, select Only schedule to run with [] % of VUs and specify the percentage.

  8. Click OK.

  9. Repeat the steps to add other child blocks to the scenario.

25.3.4 Adding Child Scripts

To add a child script to a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Select the node in the Block XML tree where you want to add the child script.

  4. Right-click and select Add Script as Child.

  5. Select the script to run from the Script list or click New to add a new script.

  6. Specify the number of iterations to run the script.

  7. Specify the Schedule for how the script will run. If you want the script to run always during each iteration,, select Always schedule to run. If you want the script to run a percentage of the time within the scenario, select Only schedule to run with [] % of VUs and specify the percentage.

  8. Click OK.

  9. Repeat the steps to add other child scripts to the scenario.

25.3.5 Editing Block and Script Settings

To edit block or script settings in a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Select the node in the Block XML Tree that you want to edit.

  4. Right-click and select Edit.

  5. Edit the block or script settings.

  6. Click OK.

25.3.6 Moving Blocks and Scripts within a Scenario

To move a block or script within a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Select the block or script you wish to move in the Block XML Tree tab of the Details view.

  4. Right-click the node and select Move Up or Move Down.

25.3.7 Deleting Blocks and Scripts from a Scenario

To delete blocks or scripts from a block scenario project:

  1. Open or create a Block Scenario project and add script assets.

  2. Expand the Run node of the script tree and select the Run Scenario node. The Details view shows the Block XML and Block XML Tree tabs.

  3. Select the node in the Block XML Tree that you want to delete.

  4. Right-click the node and select Delete.

25.4 Playing Back Block Scenario Scripts

Block scenario scripts can be played back in OpenScript as a single Virtual User or in Oracle Load Testing in multi-user scenarios.

The scenario runs scripts using a random distribution within the script blocks. Each iteration, the outcome of what the Virtual User does could be different. The percentage distribution is random, so it is not guaranteed to match the exact percentages specified. However, when run enough times to generate a large enough sample size, the results should be close to the specified percentages.

When running with multiple virtual users, random probability will decide which path each Virtual User goes through the scenario.