Step 4: Configure another script and execute it¶
Value Proposition: In this step, we will automate the verification of critical network infrastructure by creating and executing a robotic testing script. This automated testing approach allows organizations to ensure network reliability, reduce downtime risks, and enable efficient operations - ultimately improving business continuity and productivity while optimizing IT resource utilization.
Expand the left-hand navigational panel and scroll down to Test Cases and click on the Test Cases sub-section.
Let’s now add a new test case by clicking on the + button.
Click on the Open link to display the test case details.
The New Job File will be displayed, this screen contains an editor for ROBOT framework code execution. By default, this editor is populated with the basic ROBOT automation testing job-file. This default job-file that is loaded can be customized to your testing needs in the left-hand navigational panel.
Replace the
*** Test Cases ***
section with the following contents:*** Test Cases *** 1. CONNECT TO DEVICE UNDER TEST (SSH) connect to device "nx-osv-1" 2. VALIDATE VERSION ON THE DUTS AND INITIALIZING LOGGING run "show version" 3. COLLECT RUNNING CONFIGURATION FROM ALL DUTS initialize logging to "show_version_and_running_configuration.txt" # initialize logging activate report "show_version_and_running_configuration.txt" run "show ip route" run "show ip route summary" disable report logging #Disabling the show_version_and_running_configuration.txt logging report 4. VERIFY IPV4 IPADDRESS OF LOOPBACK1 run parsed json "sh interface lo0" ${LO0_IP}= get parsed "eth_ip_addr" #IPV4 loopback1 ip address Set Global Variable ${LO0_IP} 5. VALIDATE DESTINATION IPV4 ADDRESS REACHABILITY AND VERIFY THE PING COUNT ON DUT1 run "ping ${LO0_IP} count 10" run "ping ${LO0_IP} count 20" ${status}= Run Keyword And Return Status output contains "20 packets received" Run Keyword If '${status}' == 'False' FAIL ++UNSUCCESSFUL++ ${LO0_IP} address not reachable or packets loss ... ELSE set test message ++SUCCESSFUL++ ${LO0_IP} is reachable and no packets loss\n append=True
We now have a full ROBOT test. Select the latest “Runtime Image Version” container that has all these keyword libraries. Select
cxta:23.8
. Select Save to save this job file.We are now ready to run our first ROBOT test case! Click on the Run button in the execution section to begin the test.
The test will now show STARTED.
Note
You can click on the Task Id link to watch the job execution in real time. This test is executed very quickly. After a minute, if your screen does not load (stays black), click the job-file name ‘Verify routing information’ in the link at the top of the page to get back to the testing summary page.
The execution status will show COMPLETED for successful execution. If the execution status is anything other than COMPLETED, please reach out to your session speakers.
Refresh the page to see the execution details and move to the Run History section.
The Run History section will show all previous runs of this test case. Each test case run has a time stamp and the job result. Click the job time stamp to review the test results when the ROBOT test case is finished executing.
Click on the
log.html
in the artifact section to view the full audit trail of the script events and the logs associated with the execution.Click on + to expand this keyword section. Notice that by expanding the various keywords, you can see more detail at each step. The steps here show that the first keyword load testbed loaded the topology file you created earlier in this exercise. The next step connects to device “nx-osv-1” using the connection information provided to connect to the device.
Expand Step #4 and Step #5 to view the output execution for “identifying the loopback address” and then “ping connectivity to the loopback address” to make sure they are back in a good operating state.
Section author: Nandakumar Arunachalam <narunach@cisco.com>, Jinrui Wang <jinrwang@cisco.com>, Luis Rueda <lurueda@cisco.com>, Jairo Leon <jaileon@cisco.com>