STAF eXecution Engine (SXE) Service User's Guide

Version 3.0.3

Last updated: December 1, 2009


Table of Contents

  • Overview
  • Installation and Configuration
  • Variables
  • Request Syntax
  • EXECUTE
  • LIST
  • VERSION
  • HELP
  • SXE Error Code Reference
  • Service Logging

  • Overview

    The STAF eXecution Engine (SXE) service is an external STAF service, written in Java, that is intended to allow the user to sequentially execute any number of STAF commands. The SXE service reads a file containing STAF commands and executes them in the order which they appear in the file.

    The purpose of the SXE service is to provide a simple STAF service to execute a list of STAF commands specified in a file.


    Installation and Configuration

    This service requires:

    Install the SXE service by downloading the SXEV303.tar/zip file from Get STAF Services and extracting its contents to a local directory (e.g. C:\STAF\services or /usr/local/staf/services). The STAFSXE.jar file is the service jar file needed when registering the SXE service.

    The SXE service is written in Java and since it is an external service, it must be registered with the SERVICE configuration statement in the STAF configuration file. The syntax is:

    SERVICE <Name> LIBRARY JSTAF EXECUTE <Service Jar File Name>
                   [OPTION <Name[=Value]>]... [PARMS LOGNAME <Logname>]
    
    where:

    Examples

    SERVICE SXE LIBRARY JSTAF EXECUTE C:/staf/services/sxe/STAFSXE.jar
    
    SERVICE SXE LIBRARY JSTAF EXECUTE {STAF/Config/STAFRoot}/services/sxe/STAFSXE.jar \
                PARMS LOGNAME SXEServiceLog
    
    Or, you can dynamically add the SXE service using the SERVICE service's ADD SERVICE request.

    In most cases, the way that you would use this service is that you would designate a system as the SXE Server. That system would have STAF installed, plus the SXE service with the SERVICE configuration statement in the configuration file that is shown above. Assuming that the machine name for the SXE server is server1, an example of the command line interface to execute a file would be:

      STAF server1 SXE EXECUTE FILE C:/tests/sxeTest.txt


    Variables

    The following variables may be defined for the SXE service and will affect the behavior of the SXE service:

    STAF/Service/SXE/LogLevel: Specifies the level (amount) of logging to be performed
    STAF/Service/SXE/ElapsedTarget: Sets the target for elapsed time for the testcase
    STAF/Service/SXE/ElapsedTolerance: Sets the tolerance for the elapsed time target for the testcase

    Elapsed Time Checking

    If both of the variables ElapsedTarget and ElapsedTolerance are set with valid values from within the file passed to the SXE EXECUTE command, Elapsed Time Checking will be enabled. This indicates that after SXE has successfully completed executing all the commands in the specified file, it will check to see if the actual elapsed time is greater than:

    ElapsedTarget + (ElapsedTarget * ElapsedTolerance%)
    
    If it is, an ElapsedTargetExceeded return code will be returned. Otherwise, RC 0 will be returned indicating success.

    Request Syntax

    The SXE service provides the following requests:

    EXECUTE

    Executes all the STAF commands specified in a file. Each file will be given a STAF handle and all commands will be executed using this STAF handle. The fully qualified filename is passed to STAF during handle registration.

    When SXE is given a file to execute, it will execute each command in the file sequentially, proceeding to the next command after the previous command returns. Should a command return a non-zero return code, SXE execution will halt and RC 4001 (Execution Error) will be returned and the result buffer from will contain additional information about the failing command.

    Syntax

    EXECUTE FILE <File> [LOOP <Number of loops> | MINRUNTIME <hh:mm>]
    

    FILE specifies the fully-qualified name of a file which contains a list of STAF commands to execute.

    LOOP specifies the number of times that the file should be executed. FOREVER may be specified to indicate an infinite loop. If this option is not specified, the file will be executed once.

    MINRUNTIME specifies the minimum amount of time that the test should execute. It's format is hh:mm. If at the end of an iteration, the entire execution time for this test is greater than or equal to the minimum runtime, the test will end. Otherwise, a new iteration of the test will begin.

    Notes:

    1. SXE will set a handle variable named sxeloop and it will contain the number of the current loop iteration.
    2. The parameters LOOP and MINRUNTIME are mutually exclusive.

    Security

    Minimum security level of 3 required to submit an EXECUTE request.

    File format

    The file specified for an EXECUTE request should contain be a text file, where each line in the file should contain a single STAF command in the following format:

    <Endpoint> <Service> <Request>
    
    where:

    Blank lines in the file are ignored. If the first non white-space character of a line is '#', that line will be treated as a comment.

    Here is a sample file:

    local PING    PING
    local MISC    VERSION
    local PROCESS START COMMAND notepad
    

    Here is another sample file that enables elapsed time checking by setting variables STAF/Service/SXE/ElapsedTarget and STAF/Service/SXE/ElapsedTolerance within the file.

    # Run TestA and TestB and do elapsed time checking
    
    local           VAR     SET VAR STAF/Service/SXE/ElapsedTarget=0:30:0.0
    local           VAR     SET VAR STAF/Service/SXE/ElapsedTolerance=20
    local           FS      COPY DIRECTORY C:/tests TOMACHINE client1.ibm.com
    client1.ibm.com PROCESS START COMMAND C:/tests/testA.exe WAIT
    client1.ibm.com FS      COPY FILE C:/tests/testA.res TOFILE C:/results/testA.res
    client1.ibm.com PROCESS START COMMAND C:/tests/testB.exe WAIT
    client1.ibm.com FS      COPY FILE C:/tests/testB.res TOFILE C:/results/testB.res
    client3.ibm.com EVENT   GENERATE TYPE myTests SUBTYPE complete
    

    Return Codes

    All return codes from EXECUTE are documented in "SXE Error Code Reference".

    Results

    Examples:

    LIST

    LIST allows you to list the current operational settings for the SXE service.

    Syntax

    LIST SETTINGS
    

    Security

    This request requires at least trust level 2.

    Results

    The result buffer for a LIST SETTINGS request will contain a marshalled <Map:STAF/Service/SXE/Settings> representing the operational settings for the SXE service. The map is defined as follows:

    Definition of map class STAF/Service/SXE/Settings
    Description: This map class represents the settings for the SXE service.
    Key Name Display Name Type Format / Value
    logName Log Name <String>
    Notes:
    1. The "Log Name" value is the name of the STAF log where the SXE service logs information. It's value can be overridden via the LOGONAME parameter when registering the SXE service.

    Examples

    VERSION

    VERSION displays the SXE Service version.

    Syntax

    VERSION

    Security

    This request requires at least trust level 1.

    Results

    The result is the version number of the SXE service.

    Examples

    HELP

    HELP displays the request options and how to use them.

    Syntax

    HELP

    Security

    This request requires at least trust level 1.

    Results

    The result buffer contains the Help messages for the request options for the SXE service.

    Examples


    SXE Error Code Reference

    In addition to the common STAF return codes, the following SXE return codes are defined:

    Table 1. SXE Service Return Codes
    Error Code Meaning Comment
    4001 Execution Error An error occurred during execution of the file.
    4004 Elapsed Target Exceeded The time specified by ElapsedTarget and ElapsedTolerance was exceeded when this file was executed.
    4005 Error Generating Elapsed Target and/or Elapsed Tolerance values Check the assigned values of STAF/Service/SXE/ElapsedTarget and STAF/Service/SXE/ElapsedTolerance.


    Service Logging

    If you have turned on service logging, the SXE service maintains a machine log as follows:

    If variable STAF/Service/SXE/LogLevel does not exist or is set to None, no logging will be performed by the SXE service. This variable is checked at each logging attempt. Therefore, the log level may be dynamically changed, even during file execution.

    The logname for the SXE service is SXELOG unless overridden using the LOGNAME parameter when registering the service.

    Here is an example of what a SXE service log on machine server1.austin.ibm.com could look like if STAF/Service/SXE/LogLevel is set to File (shown via a request from the command line in the verbose format):

    C:\>STAF server1 LOG QUERY MACHINE server1.austin.ibm.com LOGNAME SXELOG
    Response
    --------
    [
      {
        Date-Time: 20050128-14:08:31
        Level    : Start
        Message  : {
          Loop Number: 1
          Time       : 14:8:31.444
        }
      }
      {
        Date-Time: 20050128-14:08:32
        Level    : Stop
        Message  : {
          Loop Number: 1
          Time       : 14:8:32.515
        }
      }
      {
        Date-Time: 20050128-14:08:32
        Level    : Pass
        Message  : {
          Loop Number              : 1
          Elapsed Time             : 0:0:1.071
          Elapsed Target           :
          Elapsed Tolerance Percent: 0
        }
      }
    ]
    

    Here is an example of what a SXE service log on machine server1.austin.ibm.com could look like if STAF/Service/SXE/LogLevel is set to Command (shown via a request from the command line in the verbose format):

    C:\>STAF server1 LOG QUERY MACHINE server1.austin.ibm.com LOGNAME SXELOG
    Response
    --------
    [
      {
        Date-Time: 20050128-14:10:47
        Level    : Start
        Message  : {
          Loop Number: 1
          Time       : 14:10:47.399
        }
      }
      {
        Date-Time: 20050128-14:10:47
        Level    : Info
        Message  : {
          Action : Begin
          Command: client1 ping ping
          Result : 
        }
      }
      {
        Date-Time: 20050128-14:10:47
        Level    : Info
        Message  : {
          Action : End
          Command: client1 ping ping
          Result : PONG
        }
      }
      {
        Date-Time: 20050128-14:10:47
        Level    : Info
        Message  : {
          Action : Begin
          Command: local delay delay 1000
          Result : 
        }
      }
      {
        Date-Time: 20050128-14:10:48
        Level    : Info
        Message  : {
          Action : End
          Command: local delay delay 1000
          Result :
        }
      }
      {
        Date-Time: 20050128-14:10:48
        Level    : Stop
        Message  : {
          Loop Number: 1
          Time       : 14:10:48.521
        }
      }
      {
        Date-Time: 20050128-14:10:48
        Level    : Pass
        Message  : {
          Loop Number              : 1
          Elapsed Time             : 0:0:1.122
          Elapsed Target           :
          Elapsed Tolerance Percent: 0
        }
      }
    ]