go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/suites/crud/linux_ip_route_crud.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 crud 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 26 *** Test Cases *** 27 Configure Environment 28 [Tags] setup 29 Add Agent VPP Node agent_vpp_1 30 31 Show Interfaces Before Setup 32 vpp_term: Show Interfaces agent_vpp_1 33 34 Setup Interfaces 35 Put Veth Interface Via Linux Plugin node=agent_vpp_1 namespace=ns1 name=ns1_veth1 host_if_name=ns1_veth1_linux mac=d2:74:8c:12:67:d2 peer=ns2_veth2 ip=192.168.22.1 36 Put Veth Interface Via Linux Plugin node=agent_vpp_1 namespace=ns2 name=ns2_veth2 host_if_name=ns2_veth2_linux mac=92:c7:42:67:ab:cd peer=ns1_veth1 ip=192.168.22.2 37 38 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Interfaces node=agent_vpp_1 namespace=ns1 interface=ns1_veth1 39 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Interfaces node=agent_vpp_1 namespace=ns2 interface=ns2_veth2 40 41 # This should work by default after veth interface setup 42 Ping in namespace node=agent_vpp_1 namespace=ns1 ip=192.168.22.2 43 Ping in namespace node=agent_vpp_1 namespace=ns2 ip=192.168.22.1 44 45 Create Linux Routes 46 Put Linux Route node=agent_vpp_1 namespace=ns1 interface=ns1_veth1 ip=192.168.22.2 prefix=32 next_hop=192.168.22.1 47 Put Linux Route node=agent_vpp_1 namespace=ns2 interface=ns2_veth2 ip=192.168.22.1 prefix=32 next_hop=192.168.22.2 48 Put Linux Route node=agent_vpp_1 namespace=ns1 interface=ns1_veth1 ip=8.8.8.8 prefix=32 next_hop=192.168.22.1 49 Put Linux Route node=agent_vpp_1 namespace=ns2 interface=ns2_veth2 ip=9.9.9.9 prefix=32 next_hop=192.168.22.2 50 51 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns1 ip=192.168.22.2 52 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.168.22.1 53 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns1 ip=8.8.8.8 54 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=9.9.9.9 55 56 # created routes should not exist in other namespace 57 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns2 ip=192.168.22.2 58 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns1 ip=192.168.22.1 59 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns2 ip=8.8.8.8 60 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns1 ip=9.9.9.9 61 62 Read Route Information From Setup Database 63 Get Linux Route As Json node=agent_vpp_1 interface=ns1_veth1 ip=192.168.22.2 prefix=32 64 Get Linux Route As Json node=agent_vpp_1 interface=ns2_veth2 ip=192.168.22.1 prefix=32 65 Get Linux Route As Json node=agent_vpp_1 interface=ns1_veth1 ip=8.8.8.8 prefix=32 66 Get Linux Route As Json node=agent_vpp_1 interface=ns2_veth2 ip=9.9.9.9 prefix=32 67 68 Change Linux Routes Without Deleting Key (Changing Metric) 69 # changing of gateway - this is incorrect/ the record would not be put in the database - Let us change metric 70 Put Linux Route node=agent_vpp_1 namespace=ns1 interface=ns1_veth1 ip=8.8.8.8 prefix=32 next_hop=192.168.22.1 metric=55 71 72 # testing if there is the new metric 73 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes Metric node=agent_vpp_1 namespace=ns1 ip=8.8.8.8 metric=55 74 75 Change Linux Routes At First Deleting Key And Putting The Same Secondly Deleting Key Then Putting It To Other Namespace 76 Delete Linux Route node=agent_vpp_1 interface=ns2_veth2 ip=9.9.9.9 prefix=32 77 78 79 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns2 ip=9.9.9.9 80 81 # we create exactly the same as deleted route 82 Put Linux Route node=agent_vpp_1 namespace=ns2 interface=ns2_veth2 ip=9.9.9.9 prefix=32 next_hop=192.168.22.2 83 84 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=9.9.9.9 85 86 # delete again 87 Delete Linux Route node=agent_vpp_1 interface=ns2_veth2 ip=9.9.9.9 prefix=32 88 89 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns2 ip=9.9.9.9 90 91 # we try to transfer route to other namespace - there is also need to change appropriately gateway 92 Put Linux Route node=agent_vpp_1 namespace=ns1 interface=ns1_veth1 ip=9.9.9.9 prefix=32 next_hop=192.168.22.1 93 94 95 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Removed Linux Route node=agent_vpp_1 namespace=ns2 ip=9.9.9.9 96 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes Gateway node=agent_vpp_1 namespace=ns1 ip=9.9.9.9 next_hop=192.168.22.1 97 98 At first create route and after that create inteface in namespace 3 99 Put Linux Route node=agent_vpp_1 namespace=ns3 interface=ns3_veth3 ip=192.169.22.22 prefix=32 next_hop=192.169.22.3 100 Put Linux Route node=agent_vpp_1 namespace=ns3 interface=ns3_veth3 ip=192.168.22.2 prefix=32 next_hop=192.169.22.3 101 Put Linux Route node=agent_vpp_1 namespace=ns3 interface=ns3_veth3 ip=192.168.22.1 prefix=32 next_hop=192.169.22.3 102 Put Linux Route node=agent_vpp_1 namespace=ns2 interface=ns2_veth3 ip=192.169.22.3 prefix=32 next_hop=192.169.22.22 103 104 Put Veth Interface Via Linux Plugin node=agent_vpp_1 namespace=ns3 name=ns3_veth3 host_if_name=ns3_veth3_linux mac=92:c7:42:67:ab:ce peer=ns2_veth3 ip=192.169.22.3 105 Put Veth Interface Via Linux Plugin node=agent_vpp_1 namespace=ns2 name=ns2_veth3 host_if_name=ns2_veth3_linux mac=92:c7:42:67:ab:cf peer=ns3_veth3 ip=192.169.22.22 106 107 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Interfaces node=agent_vpp_1 namespace=ns3 interface=ns3_veth3 108 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Interfaces node=agent_vpp_1 namespace=ns2 interface=ns2_veth3 109 110 Ping in namespace node=agent_vpp_1 namespace=ns2 ip=192.169.22.3 111 Ping in namespace node=agent_vpp_1 namespace=ns3 ip=192.169.22.22 112 113 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.1 114 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.2 115 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.169.22.22 116 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.169.22.3 117 118 # tested also above, but repeat after giving exact routes 119 Ping in namespace node=agent_vpp_1 namespace=ns3 ip=192.169.22.22 120 Ping in namespace node=agent_vpp_1 namespace=ns2 ip=192.169.22.3 121 # this works 122 Ping in namespace node=agent_vpp_1 namespace=ns3 ip=192.168.22.2 123 124 # this does not work 125 # https://serverfault.com/questions/568839/linux-network-namespaces-ping-fails-on-specific-veth 126 # https://unix.stackexchange.com/questions/391193/how-to-forward-traffic-between-linux-network-namespaces 127 #Ping in namespace node=agent_vpp_1 namespace=ns3 ip=192.168.22.1 128 129 # routy sa zalozia po uspesnom pingu zo ns3 ?! or ping fails 130 # Ping in namespace node=agent_vpp_1 namespace=ns1 ip=192.169.22.3 131 132 Check linux Routes On VPP1 133 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns1 ip=192.168.22.2 134 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.168.22.1 135 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes Gateway node=agent_vpp_1 namespace=ns1 ip=8.8.8.8 next_hop=192.168.22.1 136 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes Gateway node=agent_vpp_1 namespace=ns1 ip=9.9.9.9 next_hop=192.168.22.1 137 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.1 138 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.2 139 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.169.22.22 140 Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.169.22.3 141 142 Remove VPP Nodes 143 Remove All Nodes 144 Sleep ${RESYNC_SLEEP} 145 146 Start VPP1 Again 147 Add Agent VPP Node agent_vpp_1 148 Sleep ${RESYNC_WAIT} 149 150 Check Linux Interfaces On VPP1 After Resync 151 ${out}= Execute In Container agent_vpp_1 ip netns exec ns1 ip a 152 Should Contain ${out} ns1_veth1_linux 153 154 ${out}= Execute In Container agent_vpp_1 ip netns exec ns2 ip a 155 Should Contain ${out} ns2_veth2_linux 156 Should Contain ${out} ns2_veth3_linux 157 158 ${out}= Execute In Container agent_vpp_1 ip netns exec ns3 ip a 159 Should Contain ${out} ns3_veth3_linux 160 161 Check linux Routes On VPP1 After Resync 162 Check Linux Routes node=agent_vpp_1 namespace=ns1 ip=192.168.22.2 163 Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.168.22.1 164 Check Linux Routes Gateway node=agent_vpp_1 namespace=ns1 ip=8.8.8.8 next_hop=192.168.22.1 165 Check Linux Routes Gateway node=agent_vpp_1 namespace=ns1 ip=9.9.9.9 next_hop=192.168.22.1 166 Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.1 167 Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.168.22.2 168 Check Linux Routes node=agent_vpp_1 namespace=ns3 ip=192.169.22.22 169 Check Linux Routes node=agent_vpp_1 namespace=ns2 ip=192.169.22.3 170 171 172 *** Keywords *** 173 Check Linux Interfaces 174 [Arguments] ${node} ${namespace} ${interface} 175 ${out}= Execute In Container ${node} ip netns exec ${namespace} ip a 176 Should Contain ${out} ${interface} 177 178 Check Linux Routes 179 [Arguments] ${node} ${namespace} ${ip} 180 ${out}= Execute In Container ${node} ip netns exec ${namespace} ip route show 181 Should Contain ${out} ${ip} via 182 183 Check Linux Routes Gateway 184 [Arguments] ${node} ${namespace} ${ip} ${next_hop}=${EMPTY} 185 ${out}= Execute In Container ${node} ip netns exec ${namespace} ip route show 186 Should Contain ${out} ${ip} via ${next_hop} 187 188 Check Linux Routes Metric 189 [Arguments] ${node} ${namespace} ${ip} ${metric} 190 ${out}= Execute In Container ${node} ip netns exec ${namespace} ip route show 191 Should Match Regexp ${out} ${ip} via.*metric ${metric}\\s 192 193 Check Removed Linux Route 194 [Arguments] ${node} ${namespace} ${ip} 195 ${out}= Execute In Container ${node} ip netns exec ${namespace} ip route show 196 Should Not Contain ${out} ${ip} via 197 198 Ping in namespace 199 [Arguments] ${node} ${namespace} ${ip} 200 ${out}= Execute In Container ${node} ip netns exec ${namespace} ping -c 5 ${ip} 201 Should Contain ${out} from ${ip} 202 Should Not Contain ${out} 100% packet loss 203 204 *** Keywords *** 205 TestSetup 206 Make Datastore Snapshots ${TEST_NAME}_test_setup 207 208 TestTeardown 209 Make Datastore Snapshots ${TEST_NAME}_test_teardown