OSPF Test Job Files
CXTM Test Automation
  • Introduction
  • CXTM Basics
  • CXTM Projects
  • CXTM Test Cases
  • CXTM Test Automation
  • Revisit Imported Test Cases
  • CXTM Batches
  • CXTM Notifications
  • NetDevOps
  • CXTM Reporting
  • CXTM References
  • Bonus: Project Users
  • Bonus: CXTM REST API
  • Bonus: Secret Env Variables

Create OSPF Test Job Files

In the next steps, you will create test cases that verify that OSPF neighbors are up on the IOS-XE, IOS-XR, and NXOS devices in your testbed.

Step 1 - Verify OSPF Neighbor State on IOS-XE via CLI


From your test case Job File page:

  1. Navigate back to your project home by clicking on the Project LTROPS-2711 tab in the navigation breadcrumbs.



  2. Click on VIEW TEST CASES



  3. Locate the test case Verify OSPF Neighbor State on IOS-XE via CLI that has identifier 2.01
  4. For this test case's row, click on the + (plus) icon under the Job File? column



  5. For Runtime Image Version select cxta:24.5 from the dropdown



  6. Examine the Robot test automation below and insert it into the Script Text section of the Job File
  7.     
    *** Settings ***
    Library     CXTA
    Resource    cxta.robot
    
    Library     Collections
    
    Suite Setup         Run Keywords
    ...                 load testbed
    
    Suite Teardown      Run Keywords
    ...                 disconnect from all devices
    
    *** Test Cases ***
    1. Connect to Devices
        FOR  ${DEVICE}  IN  @{DEVICES}
            ${status}=  Run Keyword And Ignore Error  connect to device "${DEVICE}"
            IF  '${status[0]}' == 'FAIL'
                Fail  ++UNSUCCESSFUL++ ${DEVICE} not connected
            ELSE
                set test message  ++SUCCESSFUL++ ${DEVICE} connected \n  append=True
            END
        END
    
    2. Verify OSPF Neighbor State
        FOR  ${DEVICE}  IN  @{DEVICES}
            ${output}=  parse "show ip ospf neighbor" on device "${DEVICE}"
            @{interfaces}=  Get Dictionary Keys  ${output['interfaces']}
                FOR  ${interface}  IN  @{interfaces}
                    @{neighbors}=  Get Dictionary Keys  ${output['interfaces']['${interface}']['neighbors']}
                    FOR  ${neighbor}  IN  @{neighbors}
                        ${state}=  Get From Dictionary  ${output['interfaces']['${interface}']['neighbors']['${neighbor}']}  state
                        ${status}=  Run Keyword and Return Status  should be true  '${EXPECTED_STATE}' in '${state}'
                        IF  '${status}' == 'False'
                            Fail  ++UNSUCCESSFUL++ neighbor ${neighbor} state on ${DEVICE} is not '${EXPECTED_STATE}'
                        ELSE
                            set test message  ++SUCCESSFUL++ neighbor ${neighbor} state on ${DEVICE} is '${EXPECTED_STATE}' \n  append=True
                        END
                    END
                END
        END
    


  8. Use the parameters below and insert them into the Parameter File section of your Job File.
  9. Warning

    NOTE: You may need to scroll down to see the Parameter File section.

        
    DEVICES:
        - CSR1Kv-01
    
    EXPECTED_STATE:  FULL
    


  10. Scroll back up to the top of the Job File page and click Save


Step 2 - Create Job File for Verify OSPF Neighbors State on IOS-XR via NETCONF Test Case


From your test case Job File page:

  1. Navigate back to your project home by clicking on the Project LTROPS-2711 tab in the navigation breadcrumbs.



  2. Click on VIEW TEST CASES



  3. Locate the test case Verify OSPF Neighbor State on IOS-XR via NETCONF that has identifier 2.02
  4. For this test case's row, click on the + (plus) icon under the Job File? column



  5. For Runtime Image Version select cxta:24.5 from the dropdown



  6. Examine the Robot test automation below and insert it into the Script Text section of the Job File
  7.     
    *** Settings ***
    
    # CXTA
    Library  CXTA
    Resource  cxta.robot
    
    Suite Setup     Run Keywords
    ...             load testbed
    
    Suite Teardown      Run Keywords
    ...                 Disconnect From All Devices
    
    *** Test Cases ***
    Connect to device via NETCONF
        [Documentation]  Connect to device(s) under test via NETCONF connection.
    
        set netconf timeout to "180" seconds
        ${status}=  Run Keyword And Ignore Error  connect to device "${DEVICE}" via netconf using alias "nc1"
        IF  '${status[0]}' == 'FAIL'
            Fail  ++UNSUCCESSFUL++ ${DEVICE} not connected
        ELSE
            Set Test Message  ++SUCCESSFUL++ ${DEVICE} connected \n  append=True
        END
    
    Verify Device OSPF Neighbors State via NETCONF Get Operation
        [Documentation]  Verify OSPF neighbors are in expected state via NETCONF.
    
        ${output}  ${dict}=     netconf get    filter_type=subtree  filter=${RPC_FILTER}  reply_dict=${true}  device=${DEVICE}  alias=nc1
        Log  ${output}
        Log  ${dict}
        ${ospf_neighbor_list}=    Set Variable  ${dict['rpc-reply']['data']['ospf']['processes']['process']['default-vrf']['adjacency-information']['neighbors']['neighbor']}
        FOR  ${ospf_neighbor}  IN  @{ospf_neighbor_list}
            ${status}=  Run Keyword and Return Status  Should Be Equal As Strings  ${EXPECTED_STATE}  ${ospf_neighbor['neighbor-state']}
            IF  ${status}
                Set Test Message  ++SUCCESSFUL++ ${DEVICE} has OSPF neighbors in the expected ${EXPECTED_STATE} state\n  append=True
            ELSE
                ${ospf_neighbor_addr}=  Set Variable  ${ospf_neighbor['neighbor-address']}
                Fail  ++UNSUCCESSFUL++ Expected OSPF neighbor state was ${EXPECTED_STATE}, but ${DEVICE} has OSPF neighbor ${ospf_neighbor_addr} in the ${ospf_neighbor['neighbor-state'] state
            END
        END
    


  8. Use the parameters below and insert them into the Parameter File section of your Job File.
  9. Warning

    NOTE: You may need to scroll down to see the Parameter File section.

        
    DEVICE: XR9Kv-01
    
    RPC_FILTER: |
        <ospf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-ospf-oper">
        <processes>
            <process>
            <default-vrf>
                <adjacency-information>
                <neighbors/>
                </adjacency-information>
            </default-vrf>
            </process>
        </processes>
        </ospf>
    
    EXPECTED_STATE: mgmt-nbr-full
    


  10. Scroll back up to the top of the Job File page and click Save


Step 3 - Create Job File for Verify OSPF Neighbors State on NX-OS via REST Test Case


From your test case Job File page:

  1. Navigate back to your project home by clicking on the Project LTROPS-2711 tab in the navigation breadcrumbs.



  2. Click on VIEW TEST CASES



  3. Locate the test case Verify OSPF Neighbor State on NX-OS via REST that has identifier 2.03
  4. For this test case's row, click on the + (plus) icon under the Job File? column



  5. For Runtime Image Version select cxta:24.5 from the dropdown



  6. Examine the Robot test automation below and insert it into the Script Text section of the Job File
  7.     
    *** Settings ***
    
    Library     CXTA
    Resource    cxta.robot
    Library     genie.libs.robot.GenieRobot
    Library     genie.libs.robot.GenieRobotApis
    
    Suite Setup         Run Keywords
    ...                 load testbed        #load testbed file
    
    Suite Teardown      Run Keywords
    ...                 disconnect from all devices   #disconnect from all devices
    
    *** Test Cases ***
    
    1. CONNECT TO DEVICE UNDER TEST (REST)
        [Documentation]  Connect to DUTs using rest connection.
    
        ${status}=  Run Keyword And Ignore Error  connect to device "${DEVICE}" via "rest"
        IF  '${status[0]}' == 'FAIL'
            Fail  ++UNSUCCESSFUL++ ${DEVICE} not connected
        ELSE
            set test message  ++SUCCESSFUL++ ${DEVICE} connected \n  append=True
        END
    
    2. VERIFY ALL CONFIGURED OSPF NEIGHBOR STATES ARE FULL FOR THE GIVEN DUT
        [Documentation]  Verify all ospf neighbors states.
    
        ${resp}=   nxapi method nxapi cli  device=${DEVICE}  action=send  commands=show ip ospf neighbors  message_format=json_rpc  command_type=cli  alias=rest
        FOR  ${neighbor}  IN  ${resp.json()}[result][body][TABLE_ctx][ROW_ctx][TABLE_nbr]
            VAR  ${state}  ${neighbor}[ROW_nbr][state]
            VAR  ${rid}  ${neighbor}[ROW_nbr][rid]
            IF  '${state}' == '${EXPECTED_STATE}'
                set test message  ++SUCCESSFUL++ Neighbor ${rid} state is ${state} \n  append=True
            ELSE
                Fail  ++UNSUCCESSFUL++ Neighbor ${rid} state is ${state}
            END
    
        END
    


  8. Use the parameters below and insert them into the Parameter File section of your Job File.
  9. Warning

    NOTE: You may need to scroll down to see the Parameter File section.

        
    DEVICE: N9Kv-01
    
    EXPECTED_STATE: FULL
    


  10. Scroll back up to the top of the Job File page and click Save


Step 4 - Verify Test Case and Job File Associations


From your project :

  1. Navigate back to your project home by clicking on the Project LTROPS-2711 tab in the navigation breadcrumbs.



  2. Click on VIEW TEST CASES



  3. Examine your test case list and confirm test cases with identifiers 1.01 through 2.05 all have their respective Job File? column set to a Yes




Continue to the next section to update the BGP test cases you imported earlier in the lab.