jbot(juniperbot) · • • • gherkins
TRANSCRIPT
Copyright © 2014 Juniper Networks, Inc. 1
JBOT (Juniper Bot) Oct 2017 Pablo Sagrera ([email protected]) Efrain Gonzalez ([email protected])
Copyright © 2014 Juniper Networks, Inc. 2
Setup for JBOT- Overview • Solution is based on:
• Docker
• Robot Framework
• Jenkins
Copyright © 2014 Juniper Networks, Inc. 3
Docker – What is it?
• Docker containers
• It is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization
• It offers a container-based virtualization platform to power your applications
Copyright © 2014 Juniper Networks, Inc. 4
Robot Framework – What is it?
• Generic test automation framework
• Utilizes the keyword-driven testing approach • Suitable for both “normal” test automation and Acceptance test-driven
development (ATDD) • Implemented with Python
• Can be extended natively using python or Java • Other languages supported via remote interface
• Open Source • Hosted in github, Apache 2 license • Very active community
Copyright © 2014 Juniper Networks, Inc. 5
Jenkins – What is it? • Jenkins
It is an application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. Contains Robot Framework plugin
Copyright © 2014 Juniper Networks, Inc. 6
Robot Framework – Stuff you Need to Know • Test Suites
• Collection of test cases • Test Cases
• Used to create the actual test • Keywords
• Test cases are created from keywords that can come from two sources: • Library Keywords
• Standard, External (3rd Party) or Custom Libraries • User Keywords
• MPLS, L2VPN, RSVP, etc…
• Variables • Test case • Command line • External File
Copyright © 2014 Juniper Networks, Inc. 7
Robot Framework – Test Cases Sections: *** Settings *** *** Variables *** *** Test Cases ***
Copyright © 2014 Juniper Networks, Inc. 8
Robot Framework Test Cases - Settings *** Settings *** • Resources file path
• Resources file contains keywords • Suite Setup
• Executed before any test cases in the test suite • Suite Teardown
• Executed after any test cases in the test suite or in case of test case failure
Copyright © 2014 Juniper Networks, Inc. 9
Robot Framework Test Cases - Variables Usually any data used in tests that is subject to change is best defined as variables. *** Variables ***
Built-in variable
Custom variable
Copyright © 2014 Juniper Networks, Inc. 10
Robot Framework – Test Cases
*** Test Cases***
Test case name Test case definition
Copyright © 2014 Juniper Networks, Inc. 11
Robot Framework – Resource file - Settings
Path to variables file
Standard libraries Custom libraries
*** Settings***
Copyright © 2014 Juniper Networks, Inc. 12
Robot Framework – Resource file - Keywords
*** Keywords***
Keyword name
Keyword definition
Copyright © 2014 Juniper Networks, Inc. 13
Robot Framework – Putting all together
KEYWORDS
CUSTOM LIBRARY TEST CASE
upgrade.robot resources.txt pybot_jrouter.py
Copyright © 2014 Juniper Networks, Inc. 14
Robot Framework – How to execute it • The easiest way to execute tests is using ‘robot’ script created as part of the
normal installation: • robot -o rbavdva2-02.xml -v master_router:rbavdva2-02 -v backup_router:rbavdva2-01 -v
username:junipersup -v password:4ld3r44n upgrade.robot • -o: XML output file • -v: variables in the test data
• Data sources given to Robot Framework are either test case files or directories containing them and/or other directories.
Copyright © 2014 Juniper Networks, Inc. 15
Robot Framework – Report file
• Tagging • Statistics (including Pass/Fail ratios)
• Timing (including elapsed times)
• Logging
Copyright © 2014 Juniper Networks, Inc. 16
Robot Framework – Log file
Copyright © 2014 Juniper Networks, Inc. 17
Use Cases
#1 - JunOS Validation Testing
#2 - JunOS Live Upgrades
#3 - LIVE Service Migration
LAB and regression test
Up to 5 routers per night per maintenance window
4 migration windows per week
Copyright © 2014 Juniper Networks, Inc. 18
Use Case #1 – JunOS Validating Testing
#1 - JunOS Validation Testing
WHAT
Daily lab cleanup
Uncovering race conditions require multiple test runs
Unit test across all lab setup elements to isolate card-combination issues
Traffic generator integration for traffic flow
Detailed Robot Framework Reports for customer, including snapshots and graphs taken from
openNTI
Copyright © 2014 Juniper Networks, Inc. 19
Use Case #2 – JunOS Live Upgrades
#2 - JunOS Live Upgrades
WHAT
Automatic upload of the JunOs package to the boxes
Automatic execution of the upgrade workflow, including switchovers and reboots
Customized comparison of relevant operational information before and after the upgrade
Automatic notification Mail report
Copyright © 2014 Juniper Networks, Inc. 20
Use Case #3 – Live Services Migration
#1 – Live Services Migration
WHAT
PreMigration Tests : Check for potential problems after applying configuration just before to move
services
PostMigration Tests : Comparasion of the state of the services in source and destination
Sanity checks
Copyright © 2014 Juniper Networks, Inc. 21
References • Open-nti
• https://github.com/Juniper/open-nti
• Docker • https://www.docker.com/
• InfluxDB • http://influxdb.com/
• Grafana • http://grafana.org/
• Robot Framework • http://www.robotframework.org • https://github.com/robotframework/QuickStartGuide
• Gherkins • https://github.com/cucumber/cucumber/wiki/Given-When-Then