Improving the PTL Framework
This page appears in the PTL Developer's Guide. The process for improving the PTL framework is the same as the process you use for changing source code in PBS Professional. Test command: pbs_benchpress PTL-based commands: pbs_config: for configuring PBS and PTL for testing Commands that are not currently in use: pbs_as: for future API mode Core Python library: PBSTestLib Supporting files for PBSTestLib: pbs_api_to_cli.py, pbs_ifl_mock.py PBS test suite: pbs_testsuite.py containing PBSTestSuite (which is Python testing framework) Utilities PTL provides, such as pbs_snaputils.py, pbs_logutils.py, pbs_dshutils.py, pbs_crayutils.py, etc. Feature-specific tests Test suites under this directory should inherit base class TestFunctional Tests related to PBS interfaces (IFL, TM, RM) Test suites under this directory should inherit base class TestInterfaces Performance tests Test suites under this directory should inherit base class TestPerformance Server & comm failover tests Stress, load, and endurance tests Test suites under this directory should inherit base class TestResilience Security tests Test suites under this directory should inherit base class TestSecurity Testing PTL itself Test suites under this directory should inherit base class TestSelf Upgrade-related tests Test suites under this directory should inherit base class TestUpgrades PTL is derived from Python's unittest. PTL uses nose plugins. Tests that test PTL are in pbspro/test/test/selftest, at https://github.com/PBSPro/pbspro/tree/master/test/tests/selftest This section is for PBS developers who may be adding a new job, queue, server, or vnode attribute, and need to write tests that depend on their new attribute. PTL does not automatically generate mappings from API to CLI, so when adding new attributes, it is the responsibility of the test writer to define the attribute conversion in ptl/lib/pbs_api_to_cli.py. They must also define the new attribute in ptl/lib/pbs_ifl_mock.py so that the attribute name can be dereferenced if the SWIG wrapping was not performed. We need to define it in pbs_api_to_cli.py as follows: ATTR_geometry: "W job_geometry=" Add it to ptl/lib/pbs_ifl_mock.py as follows: ATTR_geometry: "job_geometry" In order to get the API to use the new attribute, rerun pbs_swigify, so that symbols from pbs_ifl.h are read in PTL nose plugins are written for test collection, selection, observation, and reporting. Below are the various PTL plugins: PTLTestLoader: Load test cases from a given set of parameters PTLTestRunner: Run tests PTLTestInfo: Generate test suite and test case information PTLTestDb: Update the PTL execution data into a given data base type PTLTestData: Save post-analysis data on test case failure or error PTLTestTags: Load test cases from a given set of parameters for tag names Nose supports plugins for test collection, selection, observation, and reporting. Plugins need to implement certain mandatory methods. Plugin (hooks) fall into four broad categories: selecting and loading tests, handling errors raised by tests, preparing objects used in the testing process, and watching and reporting on test results. Some of the PTL plugins, with their purposes, are listed below: Load test cases from given parameters. Based on the parameters provided while running. This plugin is necessary to load the required list of tests. It also checks for unknown test suites and test cases if any, and excludes any tests specified for exclusion. PTL plugin to run tests. This plugin defines the following functionalities related to running tests: Start or stop the test Add error, success, or failure Track test timeout If post analysis is required, raise an exception when a test case failure threshold is reached Log handler for capturing logs printed by the test case via logging module Test result handling Load test cases from given parameters to get their information docstrings. This plugin is used to generate test suite info, rather than running tests. This info includes test suite and test case docstrings in hierarchical order. It can be queried using test suite names or tags. Update the PTL execution data into a given data base type such as File, HTML, etc. This plugin is for uploading PTL data into a data base. PTL data includes all the information regarding a PTL execution such as test name, test suite name, PBS version tested on, hostname where the test is run, test start time, end time, duration, and test status (skipped, timed out, errored, failed, succeeded, etc.) PTL data can be uploaded to any type of database, including File, JSON, HTML, and PostgresSQL. The PTLTestDb plugin also defines a method to send analyzed PBS daemon log information either to the screen or to a database file, which is used with the pbs_loganalyzer test command. Save post analysis data on test case failure or error. This plugin is for saving post analysis data on test case failure in PTL, along with tracking failures and handling test execution when failure thresholds are reached. Load test cases from given parameters for tag names. This plugin provides test tagging. It defines a Decorator function that adds tags to classes, functions, or methods, and loads the matching set of tests according to a given set of parameters. http://nose.readthedocs.io/en/latest/testing.html http://www.pbspro.org/ptldocs/ https://github.com/PBSPro/pbspro http://nose.readthedocs.io/en/latest/testing.htmlProcess for Improving PTL Framework
PTL Directory Structure
Contents of pbspro/test/fw/:
Directory Description of Contents fw bin
pbs_loganalyzer: for analyzing daemon and accounting logs
pbs_snapshot: for capturing state of complex
pbs_stat: for getting status of PBS objects, e.g. jobs, queues
pbs_cov: for getting code coverage
pbs_py_spawn: left over from another project
pbs_swigify: for future API modedoc Documentation source .rst files ptl PTL package lib utils plugins Nose plugins for PTL framework Contents of pbspro/test/tests/:
Directory Description of Contents tests functional interfaces performance resilience security selftest upgrades Construction of PTL
Testing PTL
Enhancing PTL for New PBS Attributes
How to Add a New Attribute to the Library
For example, let's assume we are introducing a new job attribute called ATTR_geometry that maps to the string "job_geometry". In order to be able to set this attribute for a job:Nose Plugins for PTL
PTLTestLoader
PTLTestRunner
PTLTestInfo
PTLTestDb
PTLTestData
PTLTestTags
Nose Documentation
http://pythontesting.net/framework/nose/nose-introduction/
http://nose.readthedocs.io/en/latest/plugins/writing.htmlRelated Links and References
Complete Doxygenated PTL Documentation
Repository
https://github.com/PBSPro/pbspro/testNose Documentation
http://pythontesting.net/framework/nose/nose-introduction/
http://nose.readthedocs.io/en/latest/plugins/writing.htmlPython Documentation