jbot(juniperbot) · • • • gherkins

21
JBOT (Juniper Bot) Oct 2017 Pablo Sagrera ( [email protected] ) Efrain Gonzalez ([email protected])

Upload: vankhue

Post on 10-Sep-2018

253 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 1

JBOT  (Juniper  Bot)  Oct 2017 Pablo Sagrera ([email protected]) Efrain Gonzalez ([email protected])

Page 2: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 2

Setup for JBOT- Overview •  Solution is based on:

•  Docker

•  Robot Framework

•  Jenkins

Page 3: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 4: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 5: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 6: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 7: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 7

Robot Framework – Test Cases Sections: *** Settings *** *** Variables *** *** Test Cases ***

Page 8: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 9: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 10: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 10

Robot Framework – Test Cases

*** Test Cases***

Test case name Test case definition

Page 11: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 11

Robot Framework – Resource file - Settings

Path to variables file

Standard libraries Custom libraries

 ***  Settings***  

Page 12: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 12

Robot Framework – Resource file - Keywords

 ***  Keywords***  

Keyword name

Keyword definition

Page 13: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 13

Robot Framework – Putting all together

KEYWORDS

CUSTOM LIBRARY TEST CASE

upgrade.robot resources.txt pybot_jrouter.py

Page 14: JBOT(JuniperBot) · •  •  • Gherkins

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.

Page 15: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 15

Robot Framework – Report file

•  Tagging •  Statistics (including Pass/Fail ratios)

•  Timing (including elapsed times)

•  Logging  

Page 16: JBOT(JuniperBot) · •  •  • Gherkins

Copyright © 2014 Juniper Networks, Inc. 16

Robot Framework – Log file

Page 17: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 18: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 19: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 20: JBOT(JuniperBot) · •  •  • Gherkins

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

Page 21: JBOT(JuniperBot) · •  •  • Gherkins

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