CSIT-1459: Migrate IP libraries from VAT to PAPI
[csit.git] / resources / libraries / robot / overlay / vxlan.robot
1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library  | Collections
16 | Library  | resources.libraries.python.InterfaceUtil
17 | Library  | resources.libraries.python.IPUtil
18 | Library  | resources.libraries.python.IPv6Util
19 | Library  | resources.libraries.python.L2Util
20 | Library  | resources.libraries.python.NodePath
21 | ...
22 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
23 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
24 | Resource | resources/libraries/robot/shared/default.robot
25 | Resource | resources/libraries/robot/shared/interfaces.robot
26 | ...
27 | Documentation | VXLAN keywords
28
29 *** Keywords ***
30 | Configure IP addresses and neighbors on interfaces
31 | | [Documentation] | *Set IPv4 addresses on interfaces on DUTs.*
32 | | ... | If interface index is None then is determines with Get Interface Sw
33 | | ... | Index in this case it is required the interface to be present in
34 | | ... | topology dict. It also executes VPP IP Probe to determine MACs to IPs
35 | | ... | on DUTs.
36 | | ...
37 | | ... | _Set testcase variables with IP addresses and prefix length:_
38 | | ... | - ${dut1s_ip_address}
39 | | ... | - ${dut2s_ip_address}
40 | | ... | - ${duts_ip_address_prefix}
41 | | ...
42 | | [Arguments] | ${DUT1} | ${DUT1_INT_NAME} | ${DUT1_INT_INDEX}
43 | | ... | ${DUT2} | ${DUT2_INT_NAME} | ${DUT2_INT_INDEX}
44 | | Set Test Variable | ${dut1s_ip_address} | 172.16.0.1
45 | | Set Test Variable | ${dut2s_ip_address} | 172.16.0.2
46 | | Set Test Variable | ${duts_ip_address_prefix} | 24
47 | | ${DUT1_INT_KEY}= | Run Keyword If | ${DUT1_INT_INDEX} is None
48 | | ... | Get Interface by name | ${DUT1} | ${DUT1_INT_NAME}
49 | | ${DUT2_INT_KEY}= | Run Keyword If | ${DUT2_INT_INDEX} is None
50 | | ... | Get Interface by name | ${DUT2} | ${DUT2_INT_NAME}
51 | | ${DUT1_INT_INDEX}= | Run Keyword If | ${DUT1_INT_INDEX} is None
52 | | ... | Get Interface Sw Index | ${DUT1} | ${DUT1_INT_KEY}
53 | | ... | ELSE | Set Variable | ${DUT1_INT_INDEX}
54 | | ${DUT2_INT_INDEX}= | Run Keyword If | ${DUT2_INT_INDEX} is None
55 | | ... | Get Interface Sw Index | ${DUT2} | ${DUT2_INT_KEY}
56 | | ... | ELSE | Set Variable | ${DUT2_INT_INDEX}
57 | | ${DUT1_INT_MAC}= | Vpp Get Interface Mac | ${DUT1} | ${DUT1_INT_INDEX}
58 | | ${DUT2_INT_MAC}= | Vpp Get Interface Mac | ${DUT2} | ${DUT2_INT_INDEX}
59 | | VPP Interface Set IP Address | ${DUT1} | ${DUT1_INT_INDEX}
60 | | ... | ${dut1s_ip_address} | ${duts_ip_address_prefix}
61 | | VPP Interface Set IP Address | ${DUT2} | ${DUT2_INT_INDEX}
62 | | ... | ${dut2s_ip_address} | ${duts_ip_address_prefix}
63 | | VPP Add IP Neighbor
64 | | ... | ${DUT1} | ${DUT1_INT_INDEX} | ${dut2s_ip_address} | ${DUT2_INT_MAC}
65 | | VPP Add IP Neighbor
66 | | ... | ${DUT2} | ${DUT2_INT_INDEX} | ${dut1s_ip_address} | ${DUT1_INT_MAC}
67
68 | Add interfaces to L2BD
69 | | [Arguments] | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
70 | | Vpp Add L2 Bridge Domain | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
71
72 | Create vlan interfaces for VXLAN
73 | | [Documentation] | *Create VLAN subinterface on interfaces on DUTs with given
74 | | ... | VLAN ID.*
75 | | ...
76 | | ... | _Set testcase variables with name and index of created interfaces:_
77 | | ... | - ${dut1s_vlan_name}
78 | | ... | - ${dut1s_vlan_index}
79 | | ... | - ${dut2s_vlan_name}
80 | | ... | - ${dut2s_vlan_index}
81 | | ...
82 | | [Arguments] | ${VLAN} | ${DUT1} | ${INT1} | ${DUT2} | ${INT2}
83 | | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
84 | | ${INT2_NAME}= | Get interface name | ${DUT2} | ${INT2}
85 | | ${dut1s_vlan_name} | ${dut1s_vlan_index}= | Create Vlan Subinterface
86 | | ... | ${DUT1} | ${INT1_NAME} | ${VLAN}
87 | | ${dut2s_vlan_name} | ${dut2s_vlan_index}= | Create Vlan Subinterface
88 | | ... | ${DUT2} | ${INT2_NAME} | ${VLAN}
89 | | Set Interface State | ${DUT1} | ${dut1s_vlan_index} | up
90 | | Set Interface State | ${DUT2} | ${dut2s_vlan_index} | up
91 | | Set Test Variable | ${dut1s_vlan_name}
92 | | Set Test Variable | ${dut1s_vlan_index}
93 | | Set Test Variable | ${dut2s_vlan_name}
94 | | Set Test Variable | ${dut2s_vlan_index}
95
96 | Send VXLAN encapsulated packet and verify received packet
97 | | [Documentation] | Send VXLAN encapsulated Ethernet frame and check \
98 | | ... | received one.
99 | | ...
100 | | ... | *Arguments:*
101 | | ... | - tg_node - Node where to run traffic script. Type: dictionary
102 | | ... | - tx_if - Interface from where send VXLAN packet. Type: string
103 | | ... | - rx_if - Interface where receive VXLAN packet. Type: string
104 | | ... | - tx_src_mac - Source MAC address of sent packet. Type: string
105 | | ... | - tx_dst_mac - Destination MAC address of sent packet. Type: string
106 | | ... | - tx_src_ip - Source IP address of sent VXLAN packet. Type: string
107 | | ... | - tx_dst_ip - Destination IP address of sent VXLAN packet.
108 | | ... | Type: string
109 | | ... | - tx_vni - VNI of sent VXLAN packet. Type: string
110 | | ... | - rx_src_ip - Source IP address of received VXLAN packet. Type: string
111 | | ... | - rx_dst_ip - Destination IP address of received VXLAN packet.
112 | | ... | Type: string
113 | | ... | - rx_vni - VNI of received VXLAN packet. Type: string
114 | | ...
115 | | ... | *Return:*
116 | | ... | - No value returned
117 | | ...
118 | | ... | *Example:*
119 | | ...
120 | | ... | \| Send VXLAN encapsulated packet and verify received packet \
121 | | ... | \| ${tg_node} \| port4 \| port4 \
122 | | ... | \| fa:16:3e:6d:f9:c5 \| fa:16:3e:e6:6d:9a \| 192.168.0.1 \
123 | | ... | \| 192.168.0.2 \| ${101} \| 192.168.0.2 \| 192.168.0.1 \| ${102} \|
124 | | ...
125 | | [Arguments] | ${tg_node} | ${tx_if} | ${rx_if}
126 | | ... | ${tx_src_mac} | ${tx_dst_mac}
127 | | ... | ${tx_src_ip} | ${tx_dst_ip} | ${tx_vni}
128 | | ... | ${rx_src_ip} | ${rx_dst_ip} | ${rx_vni}
129 | | ${tx_if_name}= | Get interface name | ${tg_node} | ${tx_if}
130 | | ${rx_if_name}= | Get interface name | ${tg_node} | ${rx_if}
131 | | ${args}= | Catenate
132 | | ... | --tx_if ${tx_if_name}
133 | | ... | --rx_if ${rx_if_name}
134 | | ... | --tx_src_mac ${tx_src_mac}
135 | | ... | --tx_dst_mac ${tx_dst_mac}
136 | | ... | --tx_src_ip ${tx_src_ip}
137 | | ... | --tx_dst_ip ${tx_dst_ip}
138 | | ... | --tx_vni ${tx_vni}
139 | | ... | --rx_src_ip ${rx_src_ip}
140 | | ... | --rx_dst_ip ${rx_dst_ip}
141 | | ... | --rx_vni ${rx_vni}
142 | | Run Traffic Script On Node | send_vxlan_check_vxlan.py | ${tg_node}
143 | | ... | ${args}
144
145 | Get VXLAN dump
146 | | [Documentation] | Get VXLAN dump.
147 | | ...
148 | | ... | *Arguments:*
149 | | ... | - node - DUT node data. Type: dictionary
150 | | ... | - interface - Interface on the VPP node (Optional). Type: string
151 | | ...
152 | | [Arguments] | ${dut_node} | ${interface}=${None}
153 | | ...
154 | | [Return] | ${vxlan_dump}
155 | | ...
156 | | ${vxlan_dump}= | VXLAN Dump | ${dut_node} | ${interface}