SlideShare a Scribd company logo
1 of 42
Download to read offline
Dave Wapstra
Software Engineering Technical Leader
DEVNET-2744
Building your Certification
Test Suites using pyATS
Enter your personal notes here
Questions?
Use Cisco Webex App to chat
with the speaker after the session
Find this session in the Cisco Live Mobile App
Click “Join the Discussion”
Install the Webex App or go directly to the Webex space
Enter messages/questions in the Webex space
How
Webex spaces will be moderated
until February 24, 2023.
1
2
3
4
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Webex App
2
DEVNET-2744
Agenda
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Introduction
• Test Suite Creation
• Test Suite Execution
• CI/CD pipeline integration
• Conclusion
3
DEVNET-2744
Introduction
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Introduction
• Different types of test cases:
• pyATS Python Testcases
• pyATS Genie Triggers
• pyATS Blitz Triggers
• Execution and control
• Filter tests
• Execute on failure
• Pause execution on log message
• Verifications and Health
Create a set of automated test cases ('test suites') using pyATS
DEVNET-2744 5
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Introduction
• Prepare your test plan in Word/Excel/Wiki/etc.
• Identify TestCases, TestSections, Steps
• Create CSV file for use with pyats create project command
6
DEVNET-2744
Testcase;Testsection;Testsection Description;Step
TC1;section1;This is the first section;first step
TC1;section1;This is the first section;second step
TC2;section1;This is the first section;first step
TC2;section1;This is the first section;second step
Test Suite Creation
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Create Test Suite using pyats create project CLI
• You can use the pyats create project CLI command* with the CSV
input file to create the initial code from a template project
8
DEVNET-2744
* the pyats create project CLI enhancements will be released soon
$ pyats create project --csv-file data1.csv –-name testPyATS
$ pyats create project --csv-file data1.csv –-name testGenie 
--project-type genie
$ pyats create project --csv-file data1.csv --name testBlitz 
--project-type blitz
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
PyATS Test Suite
9
DEVNET-2744
testPyATS
├── testPyATS.py
├── testPyATS_data.yaml
├── testPyATS_job.py
├── testPyATS_job.tem
└── testbed.yaml
<- Project Name
<- Testcase module
<- Datafile
<- Job file
<- Manifest file
<- Testbed file
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
PyATS Test Suite
10
DEVNET-2744
class CommonSetup(aetest.CommonSetup):
..
class TC1(aetest.Testcase):
@aetest.setup
..
@aetest.test
def section1(self, steps):
with steps.start('first step') as step:
step.passed()
with steps.start('second step') as step:
step.passed()
@aetest.cleanup
..
class CommonCleanup(aetest.CommonCleanup):
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Genie Test Suite
11
DEVNET-2744
testGenie
├── data
│ ├── subsection-data.yaml
│ └── trigger-data.yaml
├── etc
│ └── testbed.yaml
├── local_libs
│ ├── __init__.py
│ └── commons.py
├── testGenie_job.py
├── testGenie_job.tem
└── testcases
└── testGenie.py
<- Project Name
Subsection datafile
Trigger datafile
Testbed file
Local library
Job file
Manifest file
Testcase module
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Genie Test Suite
12
DEVNET-2744
# testcases/testGenie.py
class TC1(Trigger):
@aetest.setup
..
@aetest.test
def section1(self, steps, uut):
with steps.start('first step') as step:
step.passed()
with steps.start('second step') as step:
step.passed()
@aetest.cleanup
..
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Genie Test Suite
13
DEVNET-2744
# data/trigger-data.yaml
TC1:
source:
pkg: testcases.testGenie
class: TC1
devices: [uut]
..
order:
- TC1
- TC2
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Genie Test Suite
14
DEVNET-2744
# data/subsection-data.yaml
setup:
sections:
connect:
method: local_libs.commons.connect
order: ['connect']
cleanup:
sections:
disconnect:
method: local_libs.commons.disconnect
order: ['disconnect']
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Blitz Test Suite
15
DEVNET-2744
testBlitz
├── testBlitz_job.py
├── testBlitz_job.tem
├── testbed.yaml
└── trigger-data.yaml
<- Project Name
Job file (for manifest)
Manifest file
Testbed file
Trigger datafile
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Blitz Test Suite
16
DEVNET-2744
TC1:
source:
pkg: genie.libs.sdk
class: triggers.blitz.blitz.Blitz
test_sections:
- section1: {} # Sections contain ”actions”
# Example action "execute":
# - execute:
# device: PE1
# command: show version
https://pubhub.devnetcloud.com/media/genie-docs/docs/blitz/design/actions/actions.html
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
Test suite development
DEVNET-2744
https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/apis
https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers
https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/models
Test Execution
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Execution using pyats run command
• You can use the pyats run CLI command to execute test suites
# pyATS job
$ pyats run job example_job.py --testbed-file testbed.yaml
# Genie and Blitz jobs
$ pyats run genie --testbed-file testbed.yaml --trigger-
datafile trigger-data.yaml --trigger-uids "Or(‘TC1|TC2’)”
# All jobs with manifest file
$ pyats run manifest example_job.tem
DEVNET-2744 19
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
PyATS Test Suite Execution Summary
20
DEVNET-2744
%EASYPY-INFO: Task-1: testPyATS
%EASYPY-INFO: |-- common_setup PASSED
%EASYPY-INFO: | `-- connect PASSED
%EASYPY-INFO: |-- TC1 PASSED
%EASYPY-INFO: | |-- setup PASSED
%EASYPY-INFO: | |-- section1 PASSED
%EASYPY-INFO: | | |-- STEP 1: first step PASSED
%EASYPY-INFO: | | `-- STEP 2: second step PASSED
%EASYPY-INFO: | `-- cleanup PASSED
%EASYPY-INFO: |-- TC2 PASSED
%EASYPY-INFO: | |-- setup PASSED
%EASYPY-INFO: | |-- section1 PASSED
%EASYPY-INFO: | | |-- STEP 1: first step PASSED
%EASYPY-INFO: | | `-- STEP 2: second step PASSED
%EASYPY-INFO: | `-- cleanup PASSED
%EASYPY-INFO: `-- common_cleanup PASSED
%EASYPY-INFO: `-- disconnect PASSED
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Genie Test Suite Execution Summary
21
DEVNET-2744
%EASYPY-INFO: Task-1: genie_testscript
%EASYPY-INFO: |-- common_setup PASSED
%EASYPY-INFO: | `-- connect PASSED
%EASYPY-INFO: |-- TC1.uut PASSED
%EASYPY-INFO: | |-- setup PASSED
%EASYPY-INFO: | |-- section1 PASSED
%EASYPY-INFO: | | |-- STEP 1: first step PASSED
%EASYPY-INFO: | | `-- STEP 2: second step PASSED
%EASYPY-INFO: | `-- cleanup PASSED
%EASYPY-INFO: |-- TC2.uut PASSED
%EASYPY-INFO: | |-- setup PASSED
%EASYPY-INFO: | |-- section1 PASSED
%EASYPY-INFO: | | |-- STEP 1: first step PASSED
%EASYPY-INFO: | | `-- STEP 2: second step PASSED
%EASYPY-INFO: | `-- cleanup PASSED
%EASYPY-INFO: `-- common_cleanup PASSED
%EASYPY-INFO: `-- disconnect PASSED
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Blitz Test Suite Execution Summary
22
DEVNET-2744
%EASYPY-INFO: Task-1: genie_testscript
%EASYPY-INFO: |-- common_setup PASSED
%EASYPY-INFO: | |-- connect PASSED
%EASYPY-INFO: | |-- configure SKIPPED
%EASYPY-INFO: | |-- configuration_snapshot PASSED
%EASYPY-INFO: | |-- save_bootvar PASSED
%EASYPY-INFO: | |-- learn_system_defaults PASSED
%EASYPY-INFO: | |-- initialize_traffic SKIPPED
%EASYPY-INFO: | `-- PostProcessor-2 PASSED
%EASYPY-INFO: |-- TC1.R2 PASSED
%EASYPY-INFO: | `-- section1 PASSED
%EASYPY-INFO: |-- TC2.R2 PASSED
%EASYPY-INFO: | `-- section1 PASSED
%EASYPY-INFO: `-- common_cleanup PASSED
%EASYPY-INFO: |-- verify_configuration_snapshot PASSED
%EASYPY-INFO: |-- stop_traffic SKIPPED
%EASYPY-INFO: `-- PostProcessor-2 PASSED
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Execution Control
• You can use the uids / trigger-uids CLI argument to filter testcases
# pyATS job
$ pyats run job … --uids "Or(‘TC1|TC2’)”
# Genie and Blitz jobs
$ pyats run genie … --trigger-uids "Or(‘TC1|TC2’)”
DEVNET-2744 23
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Execution Control – Execute on failure
• You can use the datafile with post processors to execute APIs or
commands on failed testcases
# pyATS datafile.yaml
processors:
post: processors.after_test
# trigger-datafile.yaml
global_processors:
post:
post_test:
method: processors.after_test
DEVNET-2744 24
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Execution Control – Execute on failure
Processor module with post failure action implementation (pyATS)
# processors.py
import logging
from pyats.results import Failed
logger = logging.getLogger(__name__)
def after_test(section):
if section.result == Failed and 
section.__context_type__ == 'Testcase':
logger.warning('Running checks after testcase failure')
DEVNET-2744 25
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Execution Control – Execute on failure
(Genie)
# trigger-datafile.yaml
global_processors:
post:
collect_show_tech:
method:
genie.libs.sdk.libs.abstracted_libs.processors.post_execute_command
parameters:
valid_section_results:
- failed
- passx
- errored
devices:
R1:
apis:
- api: get_show_tech
DEVNET-2744 26
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Pause on phrase
• You can use the Pause on Phrase feature to pause execution
$ pyats run job … --pause-on [regex string|yaml file]
$ pyats run job … --pause-on ".*TC1.*"
# pause.yaml
timeout: 600 # pause a maximum of 10 minutes
patterns:
- pattern: '.*pass.*' # pause on all log messages
# with .*pass.* in them
section: '^common_setup..*$' # for common_setup
DEVNET-2744 27
Verifications and
Health
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
PyATS Verification and pyATS Health
• Use the Verifications to verify device state in between test cases for
specific features
• Use pyATS Health to verify generic device status such as CPU,
Memory, Error messages, core files
$ pyats run job job.py --verification-uids "Or('Verf','Verf2')"
$ pyats run job job.py --health-checks core cpu logging memory
DEVNET-2744 29
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 30
PyATS Verifications
DEVNET-2744
%EASYPY-INFO: |-- Verifications.TC1.uut PASSED
%EASYPY-INFO: | `-- Verify_Module.uut.1 PASSED
%EASYPY-INFO: | `-- verify PASSED
%EASYPY-INFO: |-- TC1.uut PASSED
%EASYPY-INFO: | |-- setup PASSED
%EASYPY-INFO: | |-- section1 PASSED
%EASYPY-INFO: | | |-- STEP 1: first step PASSED
%EASYPY-INFO: | | `-- STEP 2: second step PASSED
%EASYPY-INFO: | `-- cleanup PASSED
%EASYPY-INFO: |-- Verifications.TC2.uut PASSED
%EASYPY-INFO: | `-- Verify_Module.uut.2 PASSED
%EASYPY-INFO: | `-- verify PASSED
$ pyats run job job.py --verification-uids "Or('Verify_Module')"
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 31
PyATS Health checks
DEVNET-2744
$ pyats run job job.py --health-checks core cpu logging memory
CI/CD pipeline
integration
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
CI/CD pipeline integration
• Exit codes
• XUNIT reports
DEVNET-2744 33
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
CI/CD pipeline integration – Exit codes
• pyats run exits with system exit code 0 (Success) if all the following
conditions are met:
Condition Description
Some tests were ran At least one test script/testcase was run and reported
Test results are available No exception seen while trying to access test results.
success rate is 100% Total # of tests with Passed, Passx or Skipped results / total # of tests.
All pre-job plugins ran ok No exception seen in any pre-job plugin.
All pre-task plugins ran ok No exception seen in any pre-task plugin for all scripts in the jobfile.
All post-task plugins ran ok No exception seen in any post-task plugin for all scripts in the jobfile.
All post-job plugins ran ok No exception seen in any post-job plugin.
DEVNET-2744 34
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
CI/CD pipeline integration – Exit codes
Code Description
1 Non-100% testcase success rate
2 Incorrect command-line arguments
3 Some errors/exceptions are seen while running plugins
4 All other exceptions unhandled by the infrastructure (unknown)
pyATS Return Codes
35
DEVNET-2744
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
CI/CD pipeline integration – XUNIT reports
36
DEVNET-2744
--xunit CLI option Enables the generation of an extra x-unit/j-unit
result report XML.
# enable generation
$ pyats run job /path/to/job/file.py --xunit
# enable and also copy report to specified location
$ pyats run job /path/to/job/file.py --xunit /path/to/dir
Conclusion
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Developing pyATS Test Suites
• Understanding of the different test suite types
• Understanding how to create a test suite and develop test cases
• Understanding how to control execution of test suites
• Understanding of additional verification and checks
• Understanding of integration with CI/CD pipelines
38
DEVNET-2744
https:://developer.cisco.com/pyats
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Complete your Session Survey
• Please complete your session survey
after each session. Your feedback
is important.
• All surveys can be taken in the Cisco Events Mobile App or
by logging in to the Session Catalog and clicking the
"Attendee Dashboard” at
https://www.ciscolive.com/emea/learn/sessions/session-catalog.html
39
DEVNET-2744
© 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public
Agenda
40
DEVNET-2744
Visit the On-Demand Library for more sessions
at ciscolive.com/on-demand.
Attend any of the related sessions at the DevNet,
Capture the Flag, and Walk-in Labs zones.
Visit the Cisco Showcase for related demos.
Book your one-on-one Meet the Engineer meeting.
Continue Your Education
Thank you
DEVNET-2744.pdf

More Related Content

Similar to DEVNET-2744.pdf

[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법Open Source Consulting
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)DECK36
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdfssusercbaa33
 
Workbook dtp added ccnp enterprise workbook v1.0
Workbook dtp added   ccnp enterprise workbook v1.0Workbook dtp added   ccnp enterprise workbook v1.0
Workbook dtp added ccnp enterprise workbook v1.0SagarR24
 
Ccnp enterprise workbook v1.0 ospf-updated
Ccnp enterprise workbook v1.0 ospf-updatedCcnp enterprise workbook v1.0 ospf-updated
Ccnp enterprise workbook v1.0 ospf-updatedSagarR24
 
Workbook added etherchannel ccnp enterprise workbook v1.0
Workbook added etherchannel ccnp enterprise workbook v1.0Workbook added etherchannel ccnp enterprise workbook v1.0
Workbook added etherchannel ccnp enterprise workbook v1.0SagarR24
 
Ccnp enterprise workbook v1.0 added hsrpv1
Ccnp enterprise workbook v1.0 added hsrpv1Ccnp enterprise workbook v1.0 added hsrpv1
Ccnp enterprise workbook v1.0 added hsrpv1SagarR24
 
Jenkins Pipelines Advanced
Jenkins Pipelines AdvancedJenkins Pipelines Advanced
Jenkins Pipelines AdvancedOliver Lemm
 
AzureDay Kyiv 2016 Release Management
AzureDay Kyiv 2016 Release ManagementAzureDay Kyiv 2016 Release Management
AzureDay Kyiv 2016 Release ManagementSergii Kryshtop
 
Advanced Troublesshooting Nexus 7K.pdf
Advanced Troublesshooting Nexus 7K.pdfAdvanced Troublesshooting Nexus 7K.pdf
Advanced Troublesshooting Nexus 7K.pdfJeanChristian12
 
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...YuChianWu
 
Viavi_TeraVM Core Emulator.pptx
Viavi_TeraVM Core Emulator.pptxViavi_TeraVM Core Emulator.pptx
Viavi_TeraVM Core Emulator.pptxmani723
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTKai Zhao
 
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using Yubikey
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using YubikeyPalo Alto Networks PANOS 5.0 Radius Authentication OTP using Yubikey
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using YubikeyAlberto Rivai
 
An Express Guide ~ Cacti for IT Infrastructure Monitoring & Graphing
An Express Guide ~ Cacti for IT Infrastructure Monitoring & GraphingAn Express Guide ~ Cacti for IT Infrastructure Monitoring & Graphing
An Express Guide ~ Cacti for IT Infrastructure Monitoring & GraphingAbhishek Kumar
 
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244Cisco DevNet
 

Similar to DEVNET-2744.pdf (20)

[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
 
Azure from scratch part 4
Azure from scratch part 4Azure from scratch part 4
Azure from scratch part 4
 
DevOps_project.pdf
DevOps_project.pdfDevOps_project.pdf
DevOps_project.pdf
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdf
 
Workbook dtp added ccnp enterprise workbook v1.0
Workbook dtp added   ccnp enterprise workbook v1.0Workbook dtp added   ccnp enterprise workbook v1.0
Workbook dtp added ccnp enterprise workbook v1.0
 
Ccnp enterprise workbook v1.0 ospf-updated
Ccnp enterprise workbook v1.0 ospf-updatedCcnp enterprise workbook v1.0 ospf-updated
Ccnp enterprise workbook v1.0 ospf-updated
 
Workbook added etherchannel ccnp enterprise workbook v1.0
Workbook added etherchannel ccnp enterprise workbook v1.0Workbook added etherchannel ccnp enterprise workbook v1.0
Workbook added etherchannel ccnp enterprise workbook v1.0
 
Ccnp enterprise workbook v1.0 added hsrpv1
Ccnp enterprise workbook v1.0 added hsrpv1Ccnp enterprise workbook v1.0 added hsrpv1
Ccnp enterprise workbook v1.0 added hsrpv1
 
Jenkins Pipelines Advanced
Jenkins Pipelines AdvancedJenkins Pipelines Advanced
Jenkins Pipelines Advanced
 
OpenStack with OpenDaylight
OpenStack with OpenDaylightOpenStack with OpenDaylight
OpenStack with OpenDaylight
 
AzureDay Kyiv 2016 Release Management
AzureDay Kyiv 2016 Release ManagementAzureDay Kyiv 2016 Release Management
AzureDay Kyiv 2016 Release Management
 
Advanced Troublesshooting Nexus 7K.pdf
Advanced Troublesshooting Nexus 7K.pdfAdvanced Troublesshooting Nexus 7K.pdf
Advanced Troublesshooting Nexus 7K.pdf
 
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
Im-A-Hacker-Get-Me-Out-Of-Here-Breaking-Network-Segregation-Using-Esoteric-Co...
 
Viavi_TeraVM Core Emulator.pptx
Viavi_TeraVM Core Emulator.pptxViavi_TeraVM Core Emulator.pptx
Viavi_TeraVM Core Emulator.pptx
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoT
 
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using Yubikey
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using YubikeyPalo Alto Networks PANOS 5.0 Radius Authentication OTP using Yubikey
Palo Alto Networks PANOS 5.0 Radius Authentication OTP using Yubikey
 
An Express Guide ~ Cacti for IT Infrastructure Monitoring & Graphing
An Express Guide ~ Cacti for IT Infrastructure Monitoring & GraphingAn Express Guide ~ Cacti for IT Infrastructure Monitoring & Graphing
An Express Guide ~ Cacti for IT Infrastructure Monitoring & Graphing
 
Optimizing Your CI Pipelines
Optimizing Your CI PipelinesOptimizing Your CI Pipelines
Optimizing Your CI Pipelines
 
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 

Recently uploaded (20)

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 

DEVNET-2744.pdf

  • 1. Dave Wapstra Software Engineering Technical Leader DEVNET-2744 Building your Certification Test Suites using pyATS
  • 2. Enter your personal notes here Questions? Use Cisco Webex App to chat with the speaker after the session Find this session in the Cisco Live Mobile App Click “Join the Discussion” Install the Webex App or go directly to the Webex space Enter messages/questions in the Webex space How Webex spaces will be moderated until February 24, 2023. 1 2 3 4 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Webex App 2 DEVNET-2744
  • 3. Agenda © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public • Introduction • Test Suite Creation • Test Suite Execution • CI/CD pipeline integration • Conclusion 3 DEVNET-2744
  • 5. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Introduction • Different types of test cases: • pyATS Python Testcases • pyATS Genie Triggers • pyATS Blitz Triggers • Execution and control • Filter tests • Execute on failure • Pause execution on log message • Verifications and Health Create a set of automated test cases ('test suites') using pyATS DEVNET-2744 5
  • 6. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Introduction • Prepare your test plan in Word/Excel/Wiki/etc. • Identify TestCases, TestSections, Steps • Create CSV file for use with pyats create project command 6 DEVNET-2744 Testcase;Testsection;Testsection Description;Step TC1;section1;This is the first section;first step TC1;section1;This is the first section;second step TC2;section1;This is the first section;first step TC2;section1;This is the first section;second step
  • 8. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Create Test Suite using pyats create project CLI • You can use the pyats create project CLI command* with the CSV input file to create the initial code from a template project 8 DEVNET-2744 * the pyats create project CLI enhancements will be released soon $ pyats create project --csv-file data1.csv –-name testPyATS $ pyats create project --csv-file data1.csv –-name testGenie --project-type genie $ pyats create project --csv-file data1.csv --name testBlitz --project-type blitz
  • 9. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public PyATS Test Suite 9 DEVNET-2744 testPyATS ├── testPyATS.py ├── testPyATS_data.yaml ├── testPyATS_job.py ├── testPyATS_job.tem └── testbed.yaml <- Project Name <- Testcase module <- Datafile <- Job file <- Manifest file <- Testbed file
  • 10. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public PyATS Test Suite 10 DEVNET-2744 class CommonSetup(aetest.CommonSetup): .. class TC1(aetest.Testcase): @aetest.setup .. @aetest.test def section1(self, steps): with steps.start('first step') as step: step.passed() with steps.start('second step') as step: step.passed() @aetest.cleanup .. class CommonCleanup(aetest.CommonCleanup):
  • 11. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Genie Test Suite 11 DEVNET-2744 testGenie ├── data │ ├── subsection-data.yaml │ └── trigger-data.yaml ├── etc │ └── testbed.yaml ├── local_libs │ ├── __init__.py │ └── commons.py ├── testGenie_job.py ├── testGenie_job.tem └── testcases └── testGenie.py <- Project Name Subsection datafile Trigger datafile Testbed file Local library Job file Manifest file Testcase module
  • 12. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Genie Test Suite 12 DEVNET-2744 # testcases/testGenie.py class TC1(Trigger): @aetest.setup .. @aetest.test def section1(self, steps, uut): with steps.start('first step') as step: step.passed() with steps.start('second step') as step: step.passed() @aetest.cleanup ..
  • 13. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Genie Test Suite 13 DEVNET-2744 # data/trigger-data.yaml TC1: source: pkg: testcases.testGenie class: TC1 devices: [uut] .. order: - TC1 - TC2
  • 14. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Genie Test Suite 14 DEVNET-2744 # data/subsection-data.yaml setup: sections: connect: method: local_libs.commons.connect order: ['connect'] cleanup: sections: disconnect: method: local_libs.commons.disconnect order: ['disconnect']
  • 15. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Blitz Test Suite 15 DEVNET-2744 testBlitz ├── testBlitz_job.py ├── testBlitz_job.tem ├── testbed.yaml └── trigger-data.yaml <- Project Name Job file (for manifest) Manifest file Testbed file Trigger datafile
  • 16. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Blitz Test Suite 16 DEVNET-2744 TC1: source: pkg: genie.libs.sdk class: triggers.blitz.blitz.Blitz test_sections: - section1: {} # Sections contain ”actions” # Example action "execute": # - execute: # device: PE1 # command: show version https://pubhub.devnetcloud.com/media/genie-docs/docs/blitz/design/actions/actions.html
  • 17. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 17 Test suite development DEVNET-2744 https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/apis https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/models
  • 19. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Test Execution using pyats run command • You can use the pyats run CLI command to execute test suites # pyATS job $ pyats run job example_job.py --testbed-file testbed.yaml # Genie and Blitz jobs $ pyats run genie --testbed-file testbed.yaml --trigger- datafile trigger-data.yaml --trigger-uids "Or(‘TC1|TC2’)” # All jobs with manifest file $ pyats run manifest example_job.tem DEVNET-2744 19
  • 20. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public PyATS Test Suite Execution Summary 20 DEVNET-2744 %EASYPY-INFO: Task-1: testPyATS %EASYPY-INFO: |-- common_setup PASSED %EASYPY-INFO: | `-- connect PASSED %EASYPY-INFO: |-- TC1 PASSED %EASYPY-INFO: | |-- setup PASSED %EASYPY-INFO: | |-- section1 PASSED %EASYPY-INFO: | | |-- STEP 1: first step PASSED %EASYPY-INFO: | | `-- STEP 2: second step PASSED %EASYPY-INFO: | `-- cleanup PASSED %EASYPY-INFO: |-- TC2 PASSED %EASYPY-INFO: | |-- setup PASSED %EASYPY-INFO: | |-- section1 PASSED %EASYPY-INFO: | | |-- STEP 1: first step PASSED %EASYPY-INFO: | | `-- STEP 2: second step PASSED %EASYPY-INFO: | `-- cleanup PASSED %EASYPY-INFO: `-- common_cleanup PASSED %EASYPY-INFO: `-- disconnect PASSED
  • 21. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Genie Test Suite Execution Summary 21 DEVNET-2744 %EASYPY-INFO: Task-1: genie_testscript %EASYPY-INFO: |-- common_setup PASSED %EASYPY-INFO: | `-- connect PASSED %EASYPY-INFO: |-- TC1.uut PASSED %EASYPY-INFO: | |-- setup PASSED %EASYPY-INFO: | |-- section1 PASSED %EASYPY-INFO: | | |-- STEP 1: first step PASSED %EASYPY-INFO: | | `-- STEP 2: second step PASSED %EASYPY-INFO: | `-- cleanup PASSED %EASYPY-INFO: |-- TC2.uut PASSED %EASYPY-INFO: | |-- setup PASSED %EASYPY-INFO: | |-- section1 PASSED %EASYPY-INFO: | | |-- STEP 1: first step PASSED %EASYPY-INFO: | | `-- STEP 2: second step PASSED %EASYPY-INFO: | `-- cleanup PASSED %EASYPY-INFO: `-- common_cleanup PASSED %EASYPY-INFO: `-- disconnect PASSED
  • 22. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Blitz Test Suite Execution Summary 22 DEVNET-2744 %EASYPY-INFO: Task-1: genie_testscript %EASYPY-INFO: |-- common_setup PASSED %EASYPY-INFO: | |-- connect PASSED %EASYPY-INFO: | |-- configure SKIPPED %EASYPY-INFO: | |-- configuration_snapshot PASSED %EASYPY-INFO: | |-- save_bootvar PASSED %EASYPY-INFO: | |-- learn_system_defaults PASSED %EASYPY-INFO: | |-- initialize_traffic SKIPPED %EASYPY-INFO: | `-- PostProcessor-2 PASSED %EASYPY-INFO: |-- TC1.R2 PASSED %EASYPY-INFO: | `-- section1 PASSED %EASYPY-INFO: |-- TC2.R2 PASSED %EASYPY-INFO: | `-- section1 PASSED %EASYPY-INFO: `-- common_cleanup PASSED %EASYPY-INFO: |-- verify_configuration_snapshot PASSED %EASYPY-INFO: |-- stop_traffic SKIPPED %EASYPY-INFO: `-- PostProcessor-2 PASSED
  • 23. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Test Execution Control • You can use the uids / trigger-uids CLI argument to filter testcases # pyATS job $ pyats run job … --uids "Or(‘TC1|TC2’)” # Genie and Blitz jobs $ pyats run genie … --trigger-uids "Or(‘TC1|TC2’)” DEVNET-2744 23
  • 24. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Test Execution Control – Execute on failure • You can use the datafile with post processors to execute APIs or commands on failed testcases # pyATS datafile.yaml processors: post: processors.after_test # trigger-datafile.yaml global_processors: post: post_test: method: processors.after_test DEVNET-2744 24
  • 25. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Test Execution Control – Execute on failure Processor module with post failure action implementation (pyATS) # processors.py import logging from pyats.results import Failed logger = logging.getLogger(__name__) def after_test(section): if section.result == Failed and section.__context_type__ == 'Testcase': logger.warning('Running checks after testcase failure') DEVNET-2744 25
  • 26. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Test Execution Control – Execute on failure (Genie) # trigger-datafile.yaml global_processors: post: collect_show_tech: method: genie.libs.sdk.libs.abstracted_libs.processors.post_execute_command parameters: valid_section_results: - failed - passx - errored devices: R1: apis: - api: get_show_tech DEVNET-2744 26
  • 27. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Pause on phrase • You can use the Pause on Phrase feature to pause execution $ pyats run job … --pause-on [regex string|yaml file] $ pyats run job … --pause-on ".*TC1.*" # pause.yaml timeout: 600 # pause a maximum of 10 minutes patterns: - pattern: '.*pass.*' # pause on all log messages # with .*pass.* in them section: '^common_setup..*$' # for common_setup DEVNET-2744 27
  • 29. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public PyATS Verification and pyATS Health • Use the Verifications to verify device state in between test cases for specific features • Use pyATS Health to verify generic device status such as CPU, Memory, Error messages, core files $ pyats run job job.py --verification-uids "Or('Verf','Verf2')" $ pyats run job job.py --health-checks core cpu logging memory DEVNET-2744 29
  • 30. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 30 PyATS Verifications DEVNET-2744 %EASYPY-INFO: |-- Verifications.TC1.uut PASSED %EASYPY-INFO: | `-- Verify_Module.uut.1 PASSED %EASYPY-INFO: | `-- verify PASSED %EASYPY-INFO: |-- TC1.uut PASSED %EASYPY-INFO: | |-- setup PASSED %EASYPY-INFO: | |-- section1 PASSED %EASYPY-INFO: | | |-- STEP 1: first step PASSED %EASYPY-INFO: | | `-- STEP 2: second step PASSED %EASYPY-INFO: | `-- cleanup PASSED %EASYPY-INFO: |-- Verifications.TC2.uut PASSED %EASYPY-INFO: | `-- Verify_Module.uut.2 PASSED %EASYPY-INFO: | `-- verify PASSED $ pyats run job job.py --verification-uids "Or('Verify_Module')"
  • 31. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 31 PyATS Health checks DEVNET-2744 $ pyats run job job.py --health-checks core cpu logging memory
  • 33. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public CI/CD pipeline integration • Exit codes • XUNIT reports DEVNET-2744 33
  • 34. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public CI/CD pipeline integration – Exit codes • pyats run exits with system exit code 0 (Success) if all the following conditions are met: Condition Description Some tests were ran At least one test script/testcase was run and reported Test results are available No exception seen while trying to access test results. success rate is 100% Total # of tests with Passed, Passx or Skipped results / total # of tests. All pre-job plugins ran ok No exception seen in any pre-job plugin. All pre-task plugins ran ok No exception seen in any pre-task plugin for all scripts in the jobfile. All post-task plugins ran ok No exception seen in any post-task plugin for all scripts in the jobfile. All post-job plugins ran ok No exception seen in any post-job plugin. DEVNET-2744 34
  • 35. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public CI/CD pipeline integration – Exit codes Code Description 1 Non-100% testcase success rate 2 Incorrect command-line arguments 3 Some errors/exceptions are seen while running plugins 4 All other exceptions unhandled by the infrastructure (unknown) pyATS Return Codes 35 DEVNET-2744
  • 36. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public CI/CD pipeline integration – XUNIT reports 36 DEVNET-2744 --xunit CLI option Enables the generation of an extra x-unit/j-unit result report XML. # enable generation $ pyats run job /path/to/job/file.py --xunit # enable and also copy report to specified location $ pyats run job /path/to/job/file.py --xunit /path/to/dir
  • 38. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Developing pyATS Test Suites • Understanding of the different test suite types • Understanding how to create a test suite and develop test cases • Understanding how to control execution of test suites • Understanding of additional verification and checks • Understanding of integration with CI/CD pipelines 38 DEVNET-2744 https:://developer.cisco.com/pyats
  • 39. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Complete your Session Survey • Please complete your session survey after each session. Your feedback is important. • All surveys can be taken in the Cisco Events Mobile App or by logging in to the Session Catalog and clicking the "Attendee Dashboard” at https://www.ciscolive.com/emea/learn/sessions/session-catalog.html 39 DEVNET-2744
  • 40. © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public Agenda 40 DEVNET-2744 Visit the On-Demand Library for more sessions at ciscolive.com/on-demand. Attend any of the related sessions at the DevNet, Capture the Flag, and Walk-in Labs zones. Visit the Cisco Showcase for related demos. Book your one-on-one Meet the Engineer meeting. Continue Your Education