go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/suites/traffic/linux_traffic/1x_vpp_3x_namespaces_traffic.robot (about)

     1  *** Settings ***
     2  Library      OperatingSystem
     3  #Library      RequestsLibrary
     4  #Library      SSHLibrary      timeout=60s
     5  #Library      String
     6  
     7  Resource     ../../../variables/${VARIABLES}_variables.robot
     8  
     9  Resource     ../../../libraries/all_libs.robot
    10  
    11  Force Tags        traffic     IPv4
    12  Suite Setup       Testsuite Setup
    13  Suite Teardown    Testsuite Teardown
    14  Test Setup        TestSetup
    15  Test Teardown     TestTeardown
    16  
    17  *** Variables ***
    18  ${VARIABLES}=          common
    19  ${ENV}=                common
    20  ${WAIT_TIMEOUT}=       20s
    21  ${SYNC_SLEEP}=         3s
    22  ${RESYNC_SLEEP}=       1s
    23  # wait for resync vpps after restart
    24  ${RESYNC_WAIT}=        30s
    25  ${IP_1}=               192.168.22.1
    26  ${IP_2}=               192.168.22.2
    27  ${IP_3}=               192.168.22.5
    28  ${IP_4}=               192.168.22.6
    29  ${PREFIX}=             30
    30  
    31  *** Test Cases ***
    32  Configure Environment
    33      [Tags]    setup
    34      Add Agent VPP Node    agent_vpp_1
    35  
    36  Show Interfaces Before Setup
    37      vpp_term: Show Interfaces    agent_vpp_1
    38  
    39  Setup Interfaces
    40      Put Veth Interface Via Linux Plugin    node=agent_vpp_1    namespace=ns1
    41      ...    name=ns1_veth1    host_if_name=ns1_veth1_linux    mac=d2:74:8c:12:67:d2
    42      ...    peer=ns2_veth2    ip=${IP_1}    prefix=${PREFIX}
    43      Put Veth Interface Via Linux Plugin    node=agent_vpp_1    namespace=ns2
    44      ...    name=ns2_veth2    host_if_name=ns2_veth2_linux    mac=92:c7:42:67:ab:cd
    45      ...    peer=ns1_veth1    ip=${IP_2}    prefix=${PREFIX}
    46  
    47      Put Veth Interface Via Linux Plugin    node=agent_vpp_1    namespace=ns2
    48      ...    name=ns2_veth3    host_if_name=ns2_veth3_linux    mac=92:c7:42:67:ab:cf
    49      ...    peer=ns3_veth3    ip=${IP_3}    prefix=${PREFIX}
    50      Put Veth Interface Via Linux Plugin    node=agent_vpp_1    namespace=ns3
    51      ...    name=ns3_veth3    host_if_name=ns3_veth3_linux    mac=92:c7:42:67:ab:ce
    52      ...    peer=ns2_veth3    ip=${IP_4}    prefix=${PREFIX}
    53      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    54      ...    Check Linux Interfaces    node=agent_vpp_1    namespace=ns1    interface=ns1_veth1
    55      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    56      ...    Check Linux Interfaces    node=agent_vpp_1    namespace=ns2    interface=ns2_veth2
    57      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    58      ...    Check Linux Interfaces    node=agent_vpp_1    namespace=ns2    interface=ns2_veth3
    59      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    60      ...    Check Linux Interfaces    node=agent_vpp_1    namespace=ns3    interface=ns3_veth3
    61  
    62  Ping Within The Same Namespace
    63      Ping in namespace    node=agent_vpp_1    namespace=ns1    ip=${IP_2}
    64      Ping in namespace    node=agent_vpp_1    namespace=ns2    ip=${IP_1}
    65      Ping in namespace    node=agent_vpp_1    namespace=ns2    ip=${IP_4}
    66      Ping in namespace    node=agent_vpp_1    namespace=ns3    ip=${IP_3}
    67  
    68  Create Linux Routes
    69      Put Linux Route    node=agent_vpp_1    namespace=ns1    interface=ns1_veth1
    70      ...    ip=${IP_4}    prefix=32    next_hop=${IP_2}
    71      Put Linux Route    node=agent_vpp_1    namespace=ns3    interface=ns3_veth3
    72      ...    ip=${IP_1}    prefix=32    next_hop=${IP_3}
    73      # Enable forwarding in namespace ns2
    74      Execute In Container    agent_vpp_1    ip netns exec ns2 sysctl -w net.ipv4.ip_forward=1
    75  
    76  Ping Across Namespaces
    77      Ping in namespace    node=agent_vpp_1    namespace=ns1    ip=${IP_4}
    78      Ping in namespace    node=agent_vpp_1    namespace=ns3    ip=${IP_1}
    79  
    80  Create Linux Default Routes
    81      Put Default Linux Route    node=agent_vpp_1    namespace=ns1    interface=ns1_veth1
    82      ...    next_hop=${IP_2}
    83      Put Default Linux Route    node=agent_vpp_1    namespace=ns3    interface=ns3_veth3
    84      ...    next_hop=${IP_3}
    85      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    86      ...    Check Linux Default Routes    node=agent_vpp_1    namespace=ns1    next_hop=${IP_2}
    87      Wait Until Keyword Succeeds   ${WAIT_TIMEOUT}   ${SYNC_SLEEP}
    88      ...    Check Linux Default Routes    node=agent_vpp_1    namespace=ns3    next_hop=${IP_3}
    89  
    90  Ping Across Namespaces Through Default Route
    91      Ping in namespace via interface    node=agent_vpp_1    namespace=ns1    ip=${IP_3}    interface=ns1_veth1_linux
    92      Ping in namespace via interface    node=agent_vpp_1    namespace=ns3    ip=${IP_2}    interface=ns3_veth3_linux
    93  
    94  Restart VPP Node
    95      Remove All Nodes
    96      Sleep   ${RESYNC_SLEEP}
    97      Add Agent VPP Node    agent_vpp_1
    98      Sleep    ${RESYNC_WAIT}
    99      Execute In Container    agent_vpp_1    ip netns exec ns2 sysctl -w net.ipv4.ip_forward=1
   100  
   101  
   102  Check Linux Interfaces On VPP1 After Resync
   103      ${out}=    Execute In Container    agent_vpp_1    ip netns exec ns1 ip address
   104      Should Contain    ${out}    ns1_veth1_linux
   105  
   106      ${out}=    Execute In Container    agent_vpp_1    ip netns exec ns2 ip address
   107      Should Contain    ${out}    ns2_veth2_linux
   108      Should Contain    ${out}    ns2_veth3_linux
   109  
   110      ${out}=    Execute In Container    agent_vpp_1    ip netns exec ns3 ip address
   111      Should Contain    ${out}    ns3_veth3_linux
   112  
   113      Check Linux Interfaces    node=agent_vpp_1    namespace=ns1    interface=ns1_veth1
   114      Check Linux Interfaces    node=agent_vpp_1    namespace=ns2    interface=ns2_veth2
   115  
   116      Check Linux Interfaces    node=agent_vpp_1    namespace=ns2    interface=ns2_veth3
   117      Check Linux Interfaces    node=agent_vpp_1    namespace=ns3    interface=ns3_veth3
   118  
   119  Retry All Pings After Resync
   120      Ping in namespace    node=agent_vpp_1    namespace=ns1    ip=${IP_2}
   121      Ping in namespace    node=agent_vpp_1    namespace=ns2    ip=${IP_1}
   122  
   123      Ping in namespace    node=agent_vpp_1    namespace=ns2    ip=${IP_4}
   124      Ping in namespace    node=agent_vpp_1    namespace=ns3    ip=${IP_3}
   125  
   126      Ping in namespace    node=agent_vpp_1    namespace=ns1    ip=${IP_3}
   127      Ping in namespace    node=agent_vpp_1    namespace=ns3    ip=${IP_2}
   128  
   129      Ping in namespace    node=agent_vpp_1    namespace=ns1    ip=${IP_4}
   130      Ping in namespace    node=agent_vpp_1    namespace=ns3    ip=${IP_1}
   131  
   132  *** Keywords ***
   133  Check Linux Interfaces
   134      [Arguments]    ${node}    ${namespace}    ${interface}
   135      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip address
   136      Should Contain    ${out}    ${interface}
   137  
   138  Check Linux Routes
   139      [Arguments]    ${node}    ${namespace}    ${ip}
   140      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip route show
   141      Should Contain    ${out}    ${ip} via
   142  
   143  Check Linux Routes Gateway
   144      [Arguments]    ${node}    ${namespace}    ${ip}    ${next_hop}=${EMPTY}
   145      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip route show
   146      Should Contain    ${out}    ${ip} via ${next_hop}
   147  
   148  Check Linux Default Routes
   149      [Arguments]    ${node}    ${namespace}    ${next_hop}
   150      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip route show
   151      Should Contain    ${out}    default via ${next_hop}
   152  
   153  Check Linux Routes Metric
   154      [Arguments]    ${node}    ${namespace}    ${ip}    ${metric}
   155      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip route show
   156      Should Match Regexp    ${out}    ${ip} via.*metric ${metric}\\s
   157  
   158  Check Removed Linux Route
   159      [Arguments]    ${node}    ${namespace}    ${ip}
   160      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ip route show
   161      Should Not Contain    ${out}    ${ip} via
   162  
   163  Ping in namespace
   164      [Arguments]    ${node}    ${namespace}    ${ip}
   165      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ping -c 5 ${ip}
   166      Should Contain     ${out}    from ${ip}
   167      Should Not Contain    ${out}    100% packet loss
   168  
   169  Ping in namespace via interface
   170      [Arguments]    ${node}    ${namespace}    ${ip}    ${interface}
   171      ${out}=    Execute In Container    ${node}    ip netns exec ${namespace} ping -c 5 -I ${interface} ${ip}
   172      Should Contain     ${out}    from ${ip}
   173      Should Not Contain    ${out}    100% packet loss
   174  
   175  TestSetup
   176      Make Datastore Snapshots    ${TEST_NAME}_test_setup
   177  
   178  TestTeardown
   179      Make Datastore Snapshots    ${TEST_NAME}_test_teardown