Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now that we have our two scripts written, we can put them together in a scenario. A scenario is a collection of steps and/or groups of steps that are run as a unit. Within a scenario, all steps can be run in parallel as long as their dependencies are satisfied. We can use the requires attribute of the steps to be sure that the dependencies are given specified to make them run in the correct order.

Here is a scenario that will run both the shell and Python scripts and check the results of the scripts:

Code Block
languagexml
titleScenario to test maps CLI command

 

<scenario name="maps-cli"
          description="maps CLI command test">
    <group name="Maps-Cli">

        <!-- Shell script based checks -->
        <!-- Check map known to have 0 entries -->
        <step name="Maps-Cli.Find-Intent-Mapping-Shell"
              exec="onos-find-map ${OCI} onos-intent-mapping intentMapping"/>
        <step name="Maps-Cli.Check-Intent-Mapping-Shell" requires="^"
              exec="test ${intentMappingSize} -eq 0"/>

        <!-- Check map known to have at least 50 entries -->
        <step name="Maps-Cli.Find-Intent-Mapping2-Shell"
              exec="onos-find-map ${OCI} onos-app-ids appIdsMapping"/>
        <step name="Maps-Cli.Check-App-Ids-Mapping-Shell" requires="^"
              exec="test ${appIdsMappingSize} -gt 50"/>

        <!-- Python based checks -->
        <!-- Check map known to have 0 entries -->
        <step name="Maps-Cli.Find-Intent-Mapping-Python"
              exec="onos-find-and-check-map ${OCI} onos-intent-mapping yes"/>
        <!-- Check map known to have more than 0 entries -->
        <step name="Maps-Cli.Find-App-Id-Mapping"
              exec="onos-find-and-check-map ${OCI} onos-app-ids no"/>

    </group>
</scenario>

The first element is the scenario element. You can specify a name and a longer description about what your scenario does.

The group element is a convenient way of keeping a series of steps together. ( Need more here )

Note that since an STC scenario is an XML document, we can add standard XML commenting using <!-- ... -->

The remainder of the scenario is the step declarations we saw earlier. These define the execution of the test and the checks that will be performed. Note the use of requires attributes to make sure that steps with dependencies are run in the proper order.

Once the scenario is written, we can run it using the stc driver:

Image Added

Notice that the starting time of many of the steps is the same. This is because any steps that don't have requires dependencies can be started simultaneously. The entire scenario completes quickly because much of it is run in parallel. 

The code for these examples may be found in the ONOS source tree in tools/test/scenarios/maps-cli.xml 

 

Things to include:

  • Setting debug=true env variables
  • conditional attributes: if, unless
  • Importing other scenarios
  • Namespaces 

...