1. Contents

1.1 Abbreviations

API:   Application Programming Interface
CLI:   Command-line Interface
fw:    
framework
PBS
:  PBS Professional
PTL:  PbsTestLab

2. PTL Framework Components



PTL Framework Components

2.1 Interfaces to PBS


PTL executes tests with PBS operations using interfaces including the following:

PTL provides two ways of running tests:

2.2 PBS Entities: Core Library

The PTL library provides PBS IFL operations through either SWIG wrappers or the PBS CLI.  It contains classes that encapsulate the following PBS entities:

The PTL libary includes utility classes to convert PBS data structures and attributes to Python lists, strings, and dictionaries. It provides APIs for high-level PBS operations to operate on PBS entities.  The PTL library provides the below PBS entity objects used in writing tests:

2.3 Distributed Shell Utilities


The PBS shell utilities are a set of functions to run commands, copy files, get process information, and parse a PBS configuration on an arbitrary host.  Below are a few examples of the functions that these utilities provide:

2.4 Log Utilities

Miscellaneous utilities to process and analyze PBS log files.  Contains utilities to parse and report metrics from server, scheduler, MoM, and accounting logs. Metrics include number of jobs queued, run, ended, cycle duration, and in-scheduler duration.  Below are a few examples of the utilities and functions:

2.5 Testing Utilities

PTL provides testing utilities as modules that aid in building tests using the PTL objects of PBS entities.

These are in pbspro/test/fw/ptl/utils (https://github.com/PBSPro/pbspro/tree/master/test/fw/ptl/utils)

Below are a few of the testing utilities:

pbs_testsuite

This utility defines a main master test suite class called PBSTestSuite that defines generic setup, teardown, and logging functions to be used. It is taken as parent class for most tests. This class by default instantiates server, scheduler, MoM, and comm objects connected to localhost. It also provides a wrapper class to handle multiple service instances (i.e., MoM, server, and scheduler) and certain aiding functions such as a function to skip a test, a function to check modules available on the system, etc. This utility is explained in detail in a later section of this document.

pbs_cliutils

Generic system command interface utility that provides functions such as:

pbs_covutils

Code coverage utilities.  Below are a few of the functionalities provided by these utilities:

pbs_procutils

Utilities to query process information.  Below are a few of the utilities and functions provided:

pbs_fileutils

Utility to walk a file using the result of 'head' or 'tail' on the local file system. Below are a few of the functions provided:

2.6 Test Commands, Log Analyzer, Stat, and Filter


This layer contains the following test commands:

The link below explains how to use the above test commands:
https://pbspro.atlassian.net/wiki/display/DG/Using+PTL+for+Testing#UsingPTLforTesting-Overviewofcommands

3. PTL Library: Objects and APIs

The PTL core library consists of objects encapsulating PBS entities.  These entities are described in the following sections.

3.1 PBS Server Object

For PBS server configuration and control. 
A server object is an instance of the Server class.  A server object is a container for PBS server attributes, and uses wrappers for the IFL API to perform operations on the server.  For example, you can use it to submit, status, delete, manage, etc. jobs, reservations, and configurations.
The server class also offers higher-level routines to ease testing.  Examples: a function that reverts the PBS server configuration to prior known "out of the box" settings, a function to expect an attribute to match a given value as per an operation, and a function to return the count of anything queried in the PBS setup such as the  number of nodes etc. based on certain conditions.
The class contains routines to act upon the PBS server daemon, such as starting, stopping, or restarting the PBS server daemon, and a function to match log messages in the daemon log files.
The server class also contains a dictionary that holds general configuration for the framework's operations, such as operation mode (PTL_CLI or PTL_API), maximum attempts to try while checking for a command in a test condition, and the interval between which this check of the command happens.
Below is a depiction of the Server class hierarchy:

Server Class

3.2 PBS Scheduler Object

Container of Scheduler-related properties. 
The Scheduler class contains routines to update scheduler configuration along with routines to act upon the PBS scheduler daemon, such as starting, stopping, or restarting the PBS scheduler daemon, and function to match log messages in the daemon log files.
This class also offers higher-level routines to ease testing.   Examples: a function that reverts the PBS scheduler configuration to prior known "out of the box" settings, and a function to save daemon configurations.
Below is a depiction of the Scheduler class hierarchy:

3.3 PBS MoM Object

Container for MoM properties. 
The MoM class contains routines to update MoM attributes and act upon the PBS MoM daemon. Provides various MoM operations, such as creation, insertion, and deletion of vnodes.
This class also offers higher-level routines to ease testing.  Examples: a function that reverts the PBS MoM configuration to prior known "out of the box" settings, and a function to save daemon configuration.
Below is a depiction of the MoM class hierarchy:

MoM Class

3.4 PBS Comm Object

For PBS Comm configuration and control. 
This class also offers higher-level routines to ease testing, for example: a function that reverts the PBS comm configuration to prior known "out of the box" settings, and a function to save daemon configurations.
Below is a depiction of the comm class hierarchy:

Comm Class

3.5 PBS Job Object

Container for PBS Job attributes and resources. 
This class defines certain default options of a PBS job including job name, job directory, mail_point, job priority, rerunnable, option to keep job output-error files on execution node, etc. These are overridden when any exclusive specifications are made after job object instantiation. Below are a few methods defined inside this class:

Below is depiction of the job class hierarchy:

3.6 PBS Reservation Object

Container for PBS Reservation attributes and resources. It initializes default start and end time; overridden when exclusive specifications are made. 

Below is a depiction of the reservation class hierarchy:

Reservation Class

3.7 PBS Queue Object

Container for a PBS queue.  Holds attributes of the queue and a pointer to the server. Also defines a method to revert queue attributes to defaults.
Below is a depiction of the queue class hierarchy:

Queue Class

3.8 PBS Hook Object

Represents a PBS hook.  Holds attribute information and a pointer to the server.
Below is a depiction of the class hierarchy:

Hook Class

4. Communication of PBS Data in PTL


A test step involves sending the input data necessary for PBS operations to the PTL API and returning of the results of this PBS operation in test-understandable format. In this flow, based on the PTL operation mode, the below data formats are involved:

4.1 PBS Data Flow and Conversion in PTL


BatchUtils is a Utility class to create, convert, or display various PBS data structures. It is defined in PTL's core library (pbs_testlib) and is needed to convert the data as depicted below for PBS operations in PTL.

4.1.1 Data Flow and Conversion During Testing of PBS

Data Flow When Testing PBS

Testing PBS Operation in API Mode

  1. The test provides the necessary PBS data in Python data structures to PTL API
  2. This data is converted to PBS data structure format using functions defined in BatchUtils
  3. The data is then passed to PBS IFL Wrapper functions to execute the test step

Testing PBS Operation in CLI Mode

  1. The test provides the necessary PBS data in Python data structures to PTL API
  2. This data is mapped to PBS command arguments using functions defined in BatchUtils
  3. Then the whole PBS command is run by PTL

4.1.2 Data Flow and Conversion for Result of Testing PBS

Data Flow for PBS Test Result

Testing Result of PBS Operation in API Mode

  1. The result of a PBS operationin API mode returns in PBS data structure format. 
  2. This result is converted to Python format using functions defined in BatchUtils.

Testing Result of PBS Operation in CLI Mode

  1. The result of a PBS operation in CLI mode returns in the PBS format made up of a list of "key=value" pairs. 
  2. This result is converted to convenient Python data structure format using functions defined in BatchUtils.

4.2 Flow of Methods During Test Case Execution


Below is the flow of methods inside a PTL test suite that is inherited from the master test suite, named PBSTestSuite, when test cases are executed:

Method Flow in Test Suite

5. PBSTestSuite

5.1 Overview of PBSTestSuite

PBSTestSuite is a master test suite class that defines generic setup, teardown, and logging functions to be used by inherited test suites. This class instantiates server, scheduler, MoM, and comm objects connected to localhost. This class has functions that include deletion of all jobs and reservations, reversion of server and scheduler configuration to defaults, and checks to ensure that there is at least one CPU to schedule work on before running a test. This class also accepts a bunch of custom parameters based on the necessary test setup.

5.2 Parent Methods Defined in the Parent Class (PBSTestSuite)

5.3 Custom Methods Defined In the Test Suite

5.4 Reverting to Defaults

Server, scheduler, MoM, and queue each have a method to revert to defaults.  Here is a description of what each one does:

5.4.1 Reverting Server to Defaults

5.4.2 Reverting Queue to Defaults

5.4.3 Reverting Scheduler to Defaults

5.4.4. Reverting MoM to Defaults

5.5 Generic Setup and Teardown Functions

SetUpClass Method

SetUp Method

TearDown Method

TearDownClass Method


6. Decorators

PTL provides decorators for use at the test suite level and at the test case level.  These decorators are defined in pbs_testsuite.py.

How to Use Decorators

   @timeout(900)
def test_smoke(Self):

7. Exception Handling

PTL defines a generic exception called "PtlException", which is inherited by numerous custom exceptions defined for multiple types of PBS operation failures.  PtlException defines generic errors raised by PTL operations. It sets a return value, a return code, and a message:

A post function and associated positional and named arguments are available to perform any necessary cleanup.

A bunch of exceptions are inherited from generic PtlException that are necessary for PBS operation error handling.

8. Related Links and References

Complete Doxygenated PTL Documentation

http://www.pbspro.org/ptldocs/

Repository

https://github.com/PBSPro/pbspro
https://github.com/PBSPro/pbspro/test

Nose Documentation

http://nose.readthedocs.io/en/latest/testing.html
http://pythontesting.net/framework/nose/nose-introduction/
http://nose.readthedocs.io/en/latest/plugins/writing.html

Python Documentation

https://docs.python.org/2.7/tutorial/



OSS Site Map

Developer Guide Pages