JT With Advanced Perl: Junos Automation Training For Junose Engineers
JT With Advanced Perl: Junos Automation Training For Junose Engineers
JUNOS Environment
JUNOSe Infrastructure SQATS JUNOS JT
Test Specification
Regression Harness
AMT/ATT
JustBig
JT::Test Library
jbatch/Regression Manager
Hardware Selection
Test Storage Reservations
params
cvs
Res
The res command line program works just like the systray program and resource browser page, and works from same db
$ res --help-list-cmd Usage: res [res-options] command [command-options-and-arguments] res commands are: co | checkout Checkout resources ci | checkin Checkin resources sh | show Show resources status up | update update existing reservations pm | preempt preempt existing reservations
Params
Params is a standalone system that finds hardware (routers, RouterTesters, etc.) that fits your testing needs
You define a list of constraints (e.g. a GE port on router1 should connect to a GE port on router2) and params will fill in the blanks The configuration file uses a c-like syntax of stanzas delimited with braces.
Params Expansion
.params File
r0 { system { model "m20"; } interfaces { r0-r1 { type "ether"; } } } r1 { system { model "m20"; } interfaces { r0-r1 { type "ether"; } } }
r0 { system { name "asahi"; cube "cube3"; make "juniper"; model "m20"; os "JunOS"; os-ver "5.1"; mgtaddr "10.255.14.218"; isoaddr "47.0005.80ff.f800.0000.0108.0001.0102.5501.4218.00"; } interfaces { r0-r1 { name "fe-0/1/0.0"; pic "fe-0/1/0"; unit 0; type "ether"; speed 100; ipaddr "192.168.199.130"; } } } r1 { system { name "redhook"; cube "cube3"; make "juniper"; model "m20"; os "JunOS"; os-ver "5.1"; mgtaddr "10.255.14.222"; isoaddr "47.0005.80ff.f800.0000.0108.0001.0102.5501.4222.00"; } interfaces { r0-r1 { name "fe-0/1/0.0"; pic "fe-0/1/0"; unit 0; type "ether"; speed 100; ipaddr "192.168.199.129"; } } }
.params dump
Params
Params Operation
If the -g option is not used then params will use the TE_TOPOLGY environment variable for the testbed name. Use -d to dump the entire filled params form Constraints that begin with x- are ignored by params but stay in form Use params-find help or man params-find for command usage
Params Data
Lab-trolls maintain params data params-info returns data from the params system for a given device
> params-info helium Params server for this session: moon.englab.juniper.net Current information for helium: Make..................juniper Model.................m10i Cube..................protocols-e-elements ISO address...........N/A Host re0 Loopback IP...........N/A Management IP.........10.5.11.43/16 Console IP............10.5.11.10 Default OS............JunOS 7.6 Update time...........#<LOCAL-TIME: 2006-07-12 13:38:37-07>
fe-0/0/0
hydrogen fe-0/0/0
Use man params-info for command usage Complete params info at http://params.englab.juniper.net:8000/params/index.html
JT
JT is the JUNOS Test System An object oriented interface written in Perl
JT is actually just a very large perl module (JT.pm) that provides many of the essential functions for testing.
Each router is an object in JT that tracks connections and receives commands Docs: http://wwwsystest.juniper.net/twiki/bin/view/Main/JTDoc umentation
Using JT
e.g. $r[0]->chk_version or $r[1]->chk_bgp_peer(peer=>'10.102.255.10', timeout=> 120); RouterTester (RT.pm), other libraries upcoming JUNOSe Routers (ERX.pm), Cisco (IOS.pm) Protocol Libraries (e.g. BGP, MPLS, Firewall, Scaling, SNMP, etc.)
JT::Test
Docs: http://wwwsystest.juniper.net/pub/doc/JT/Test/docs/
JT::Tests Role
Typical JT::Test flow:
Calls params with your .params file to determine what hardware to use.
Connects to routers (uses info from fulfilled params request). Saves router base configs; Cleans routers in preparation for testing. Configures interfaces (with params info) and (optionally) calls your userspecified test configs.
Commits routers.
Executes your test cases. Tracks test successes and failures. Upon failure, does postmortem (i.e., gather router information for troubleshooting purposes). Optionally does your postmortem routine. Restores router configs; exits routers.
Env variables:
PATH=/volume/perl/bin:/bin:/sbin:/usr/bin:/usr/sbin:/volume/labtools/bin:/usr/local/bin CVSROOT=cvs:/cvs/juniper CVS_RSH=ssh TE_DATA_TMPDIR=~/TE/regress/scripts/results TE_TOPOLOGY=protocols-e-elements PARAMS_VERSION=2
Test Structure
A .params file thats part of a JT::Test contains:
General JT settings (global x- parameters) e.g. x-log-level "TRACE"; x-set-user- parameters that define config/chkstatus/postmortem/etc e.g. x-set-user-configs "&sampleART::config"; x-testcase testcase definitions x-testcase-001 ( "x-is-run" 1 "Sample test case" e.g."x-descr"
"x-cmd" "x-args" "x-loop" "x-reset-config" ); "sampleART::TC1" "ENV" 1 0
See ~rdonle/sample/sampleART.pl.params
$p contains the complete params dump, including all x- parameters e.g. $p->{R0}->{SYSTEM}->{MODEL} == m20 See a complete dump at ~rdonle/sample/p-handle.txt e.g. $r[0]->{MODEL} == m20 See a complete dump at ~rdonle/sample/r-handle.txt
File Locations
.pl and .params files (the test itself) belong: .pm file (the tests library) belongs:
cvs/system-test/scripts/<group>
cvs/system-test/source/Testsuites/<group>
/volume/labtools/lib/JT/devel
Other Tools
Restores base config on router rsu -c <router name(s)> RSU with the -c option, will take the config file from /volume/labtools/lab-cvs/system-test/machine/<machinename>/config and place it on the router along with the default systest package. clean_config: very similar to rsu but runs in parallel for multiple routers
Typically, run: autoupd -j 8.2 -d --no-validate <router name(s)> If no specific version is specified the latest daily build will be installed. If you wanted a specific build autoupd would look like: autoupd -j 8.1B3.2 -d --no-validate <router name(s)>