Create Last Job File
CXTM Test Automation
  • Introduction
  • Services as Code (SaC)
  • CXTM Basics
  • CXTM Projects
  • CXTM Test Cases
  • CXTM Test Automation
  • CXTM Batches
  • Setup GitLab CI/CD
  • Configure L3Out
  • Test Results
  • CXTM Reporting
  • Continue your Education

Add Test Case Parameters

Now that test cases 01.01 - 01.05 have test case parameters, you'll complete test case 01.06 by adding a Job File and a parameter file.

Step 1 - Create Job File for Verify BGP Neighbor Failure and Recovery Convergence


From your project's Test Cases page:

  1. Locate the test case Verify BGP Neighbor Failure and Recovery Convergence that has identifier 01.06
  2. For this test case's row, click on the + (plus) link under the Job File? column



  3. For Runtime Image Version select cxta:24.2 from the dropdown



  4. Examine the Robot code below and insert it into the Script Text section of the Job File
  5.     
    *** Settings ***
    # CXTA
    Library             CXTA
    Resource            cxta.robot
    
    # Import Robot Framework keywords from open source or custom libraries:
    # http://robotframework.org/robotframework/#standard-libraries
    Library             Collections
    
    # Load topology/testbed file and connect to devices
    Suite Setup         Run Keywords
    ...                     load testbed
    ...                     AND
    ...                     SpirentRest Connect  device_name=SpirentRestDevice
    ...                     AND
    ...                     Connect to device "${FANOUT}" via "ssh"
    
    # Disconnect sessions from all devices
    Suite Teardown      Run Keywords
    ...                     disconnect from all devices
    ...                     AND
    ...                     SpirentRest End Session
    
    
    *** Test Cases ***
    1. START SPIRENT
        [Documentation]    Start Spirent devices and traffic
        SpirentRest Load Config  config_file_path=${spirent_config_file}  revoke_ownership=${true}
        SpirentRest Start Arp On All Devices
        Sleep  10s
        SpirentRest Start Streams  ${streamblocks}
    
    2. EXECUTE FAILURE
        [Documentation]    Execute the failure trigger
        Sleep  5s
        SpirentRest Clear Traffic Results
        Sleep  5s
        Spirent Verify No Drops
        Spirent Check Drops
        Select Device "${FANOUT}"
        Sendline "config t"
        Sendline "router bgp ${BGP_AS}"
        Sendline "vrf ${BGP_VRF}"
        Sendline "neighbor ${BGP_NBR}"
        Sendline "shutdown"
        Sleep  5s
    
    3. STOP SPIRENT AFTER FAILURE
        [Documentation]    Stop Spirent traffic streams
        SpirentRest Stop Streams  ${streamblocks}
    
    4. GET RESULTS AFTER FAILURE
        [Documentation]    Get traffic convergence results after the failure
        ${strms_convergence}=  Spirent Get Stream Convergence
        csv save ${strms_convergence} as "${FAILURE_EVENT_FILE_NAME}"
        ${strms_convergence_ms}  Create List
        FOR  ${strm_convergence}  IN  @{strms_convergence}
            ${convergence_ms}  Set Variable  ${strm_convergence['convergence_ms']}
            Append to List  ${strms_convergence_ms}  ${convergence_ms}
        END
        Sort List    ${strms_convergence_ms}
        Reverse List    ${strms_convergence_ms}
        ${status}=  Run Keyword And Return Status  Should be true  ${strms_convergence_ms[0]}<=${EXPECTED_FAILURE_CONVERGENCE}
        IF  ${status} != ${True}
            Fail  ++UNSUCCESSFUL++ Dropped Frame Duration ${strms_convergence_ms[0]} is more than the expected: ${EXPECTED_FAILURE_CONVERGENCE}
        ELSE
            Set Test Message  ++SUCCESSFUL++ Dropped Frame Duration ${strms_convergence_ms[0]} is <= to the expected: ${EXPECTED_FAILURE_CONVERGENCE}
        END
    
    5. RESTART SPIRENT
        [Documentation]    Start Spirent traffic streams
        SpirentRest Start Streams  ${streamblocks}
    
    6. EXECUTE RECOVERY
        [Documentation]    Execute the recovery trigger
        Sleep  5s
        SpirentRest Clear Traffic Results
        Sleep  5s
        Spirent Verify No Drops
        Spirent Check Drops
        Select Device "${FANOUT}"
        Sendline "config t"
        Sendline "router bgp ${BGP_AS}"
        Sendline "vrf ${BGP_VRF}"
        Sendline "neighbor ${BGP_NBR}"
        Sendline "no shutdown"
        Sleep  5s
    
    7. STOP SPIRENT AFTER RECOVERY
        [Documentation]    Stop Spirent traffic streams
        SpirentRest Stop Streams  ${streamblocks}
    
    8. GET RESULTS AFTER RECOVERY
        [Documentation]    Get traffic convergence results after the recovery
        ${strms_convergence}=  Spirent Get Stream Convergence
        csv save ${strms_convergence} as "${RECOVERY_EVENT_FILE_NAME}"
        ${strms_convergence_ms}  Create List
        FOR  ${strm_convergence}  IN  @{strms_convergence}
            ${convergence_ms}  Set Variable  ${strm_convergence['convergence_ms']}
            Append to List  ${strms_convergence_ms}  ${convergence_ms}
        END
        Sort List    ${strms_convergence_ms}
        Reverse List    ${strms_convergence_ms}
        ${status}=  Run Keyword And Return Status  Should be true  ${strms_convergence_ms[0]}<=${EXPECTED_RECOVERY_CONVERGENCE}
        IF  ${status} != ${True}
            Fail  ++UNSUCCESSFUL++ Dropped Frame Duration ${strms_convergence_ms[0]} is more than the expected: ${EXPECTED_RECOVERY_CONVERGENCE}
        ELSE
            Set Test Message  ++SUCCESSFUL++ Dropped Frame Duration ${strms_convergence_ms[0]} is <= to the expected: ${EXPECTED_RECOVERY_CONVERGENCE}
        END
    
    


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

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

        
    FANOUT: n9k-fanout1
    
    spirent_config_file: /tmp/LABATO-2205-user07.xml
    
    streamblocks:
      - pod07_107-1107
      - pod07_1107-107
    
    BGP_AS: 65999
    BGP_VRF: pod07-external
    BGP_NBR: 192.168.107.10
    
    EXPECTED_FAILURE_CONVERGENCE: 50
    EXPECTED_RECOVERY_CONVERGENCE: 1
    
    FAILURE_EVENT_FILE_NAME: BGP-Neighbor-Failure.csv
    RECOVERY_EVENT_FILE_NAME: BGP-Neighbor-Recovery.csv
    
    



  8. Scroll down to the the Advanced Settings section on this page and set the Execution Queue to 5.





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




Now that you've added a Job File and parameters to your last test case, you'll navigate to the project's Job Files page to set the Default Topology to the Topology you created earlier, SaC CAIT Lab Topology, for all Job Files.

Step 2 - Navigate to your project's Job Files page


Return to the sidebar.

  1. Scrolldown until you locate the heading Test Cases
  2. Under Test Cases, click Job Files


Step 3 - Set the Default Topology for all Job Files


From your project's Job Files page:

  1. Click on the check box icon to Select all visible Job Files
  2. Click on the pencil icon to Edit selected Job Files



  3. Click the Change Default Topology check box
  4. Select the SaC CAIT Lab Topology topology from the Default Topology dropdown
  5. Click the SUBMIT button



Continue to the next section to add your test cases to a Batch to be run in your CI/CD pipeline.