Devnet
pyATS
12 Blitz Triggers

Understanding pyATS Blitz Triggers

pyATS Blitz Trigger is a YAML-driven template designed to simplify the creation and execution of test cases in pyATS. It offers a fast and efficient way to write and run test cases, requiring minimal Python knowledge. Let's explore the structure of a Blitz template and its capabilities:

Key Features:

  1. Fast and Efficient: Blitz triggers are optimized for speed and require little to no Python coding, making them ideal for rapid test case development and execution.

  2. YAML-Driven: Test cases are defined in YAML format, making them easy to write and understand, even for non-programmers.

  3. Predefined Actions: Blitz provides numerous predefined actions for common testing tasks. Custom actions can also be created using Python if needed.

  4. Integration with pyATS Building Blocks: Despite its simplicity, Blitz integrates seamlessly with pyATS functionalities such as connection management, configuration management, and operational state comparison.

Structure of a Blitz Testcase File:

  • Name: A meaningful name for the testcase, specified at the top of the file.

  • Source: Specifies the location of the Blitz trigger Library, typically set to genie.libs.sdk and triggers.blitz.blitz.Blitz.

  • Sections Block: Contains the keyword test_sections and marks the beginning of the collection of all sections used in the testcase.

  • Sections: Each section defines a set of actions to execute. Sections are named descriptively and contain a list of actions to be performed.

Common Blitz Actions:

  • Apply Configuration: Changes or modifies configurations on devices.

  • Verify Configuration: Parses device output to verify if the device state matches expectations.

  • Learn Feature: Retrieves operational state information from devices and verifies the results.

  • Integration with Other pyATS APIs: Calls various pyATS APIs and uses their outputs in actions.

  • YANG Integration: Acknowledges that data structures are based on YANG and works with them.

Example Testcase File:

  • Testcase Structure: The testcase consists of multiple sections, each containing various actions to be executed.

  • Indented YAML Code: Proper indentation is crucial in YAML for defining sections and actions correctly.

  • Comments for Clarity: The example testcase is commented to explain each section and action clearly.

Running Tests:

  • Using pyATS Job: Tests can be executed using a Python job file.

  • Single CLI Command: Alternatively, tests can be run using a single pyATS CLI command, specifying the path to the Blitz trigger YAML file and the testbed YAML file.

Example CLI Commands:

# Option 1: Using pyATS job
pyats run job <path_to_job_file>
 
# Option 2: Using a single command line
pyats run genie --trigger-datafile <path_to_blitz_file> --trigger-uids 'test1' --testbed-file testbed.yaml
  • <path_to_job_file>: Path to the Python job file.

  • <path_to_blitz_file>: Path to the Blitz trigger YAML file.

  • testbed.yaml: Path to the testbed YAML file.

  • 'test1': Name of the test to run. Multiple tests can be specified in an ordered list.

By leveraging pyATS Blitz Triggers, network engineers can quickly create and execute test cases, validate configurations, and ensure network reliability with ease.