CSIT-562 HC Test: Persistence suite rework, part1
[csit.git] / resources / libraries / robot / vxlan.robot
1 # Copyright (c) 2016 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 | Resource | resources/libraries/robot/default.robot
17 | Resource | resources/libraries/robot/interfaces.robot
18 | Resource | resources/libraries/robot/bridge_domain.robot
19 | Resource | resources/libraries/robot/l2_xconnect.robot
20 | Library  | resources.libraries.python.L2Util
21 | Library  | resources.libraries.python.IPUtil
22 | Library  | resources.libraries.python.IPv4Util
23 | Library  | resources.libraries.python.IPv6Util
24 | Library  | resources.libraries.python.IPv4Setup
25 | Library  | resources.libraries.python.NodePath
26
27 *** Keywords ***
28 | IP addresses are set on interfaces
29 | | [Documentation] | *Set IPv4 addresses on interfaces on DUTs.*
30 | | ... | If interface index is None then is determines with Get Interface Sw Index
31 | | ... | in this case it is required the interface to be present in topology dict.
32 | | ... | It also executes VPP IP Probe to determine MACs to IPs on DUTs
33 | | ...
34 | | ... | _Set testcase variables with IP addresses and prefix length:_
35 | | ... | - ${dut1s_ip_address}
36 | | ... | - ${dut2s_ip_address}
37 | | ... | - ${duts_ip_address_prefix}
38 | | ...
39 | | [Arguments] | ${DUT1} | ${DUT1_INT_NAME} | ${DUT1_INT_INDEX}
40 | | ...         | ${DUT2} | ${DUT2_INT_NAME} | ${DUT2_INT_INDEX}
41 | | Set Test Variable | ${dut1s_ip_address} | 172.16.0.1
42 | | Set Test Variable | ${dut2s_ip_address} | 172.16.0.2
43 | | Set Test Variable | ${duts_ip_address_prefix} | 24
44 | | ${DUT1_INT_KEY}= | Run Keyword If | ${DUT1_INT_INDEX} is None
45 | |                  | ... | Get Interface by name | ${DUT1} | ${DUT1_INT_NAME}
46 | | ${DUT2_INT_KEY}= | Run Keyword If | ${DUT2_INT_INDEX} is None
47 | |                  | ... | Get Interface by name | ${DUT2} | ${DUT2_INT_NAME}
48 | | ${DUT1_INT_INDEX}= | Run Keyword If | ${DUT1_INT_INDEX} is None
49 | |                    | ... | Get Interface Sw Index | ${DUT1} | ${DUT1_INT_KEY}
50 | |                    | ... | ELSE | Set Variable | ${DUT1_INT_INDEX}
51 | | ${DUT2_INT_INDEX}= | Run Keyword If | ${DUT2_INT_INDEX} is None
52 | |                    | ... | Get Interface Sw Index | ${DUT2} | ${DUT2_INT_KEY}
53 | |                    | ... | ELSE | Set Variable | ${DUT2_INT_INDEX}
54 | | ${DUT1_INT_MAC}= | Vpp Get Interface Mac | ${DUT1} | ${DUT1_INT_INDEX}
55 | | ${DUT2_INT_MAC}= | Vpp Get Interface Mac | ${DUT2} | ${DUT2_INT_INDEX}
56 | | Set Interface Address | ${DUT1} | ${DUT1_INT_INDEX}
57 | | ... | ${dut1s_ip_address} | ${duts_ip_address_prefix}
58 | | Set Interface Address | ${DUT2} | ${DUT2_INT_INDEX}
59 | | ... | ${dut2s_ip_address} | ${duts_ip_address_prefix}
60 | | Add IP Neighbor | ${DUT1} | ${DUT1_INT_INDEX} | ${dut2s_ip_address} | ${DUT2_INT_MAC}
61 | | Add IP Neighbor | ${DUT2} | ${DUT2_INT_INDEX} | ${dut1s_ip_address} | ${DUT1_INT_MAC}
62
63 | VXLAN interface is created
64 | | [Arguments] | ${DUT} | ${VNI} | ${SRC_IP} | ${DST_IP}
65 | | Create VXLAN interface | ${DUT} | ${VNI} | ${SRC_IP} | ${DST_IP}
66
67 | Interfaces are added to BD
68 | | [Arguments] | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
69 | | Vpp Add L2 Bridge Domain | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
70
71 | Interfaces are added to xconnect
72 | | [Arguments] | ${DUT} | ${INTERFACE_1} | ${INTERFACE_2}
73 | | L2 setup xconnect on DUT | ${DUT} | ${INTERFACE_1} | ${INTERFACE_2}
74
75 | Vlan interfaces for VXLAN are created
76 | | [Documentation] | *Create VLAN subinterface on interfaces on DUTs with given VLAN ID.*
77 | | ...
78 | | ... | _Set testcase variables with name and index of created interfaces:_
79 | | ... | - ${dut1s_vlan_name}
80 | | ... | - ${dut1s_vlan_index}
81 | | ... | - ${dut2s_vlan_name}
82 | | ... | - ${dut2s_vlan_index}
83 | | ...
84 | | [Arguments] | ${VLAN} | ${DUT1} | ${INT1} | ${DUT2} | ${INT2}
85 | | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
86 | | ${INT2_NAME}= | Get interface name | ${DUT2} | ${INT2}
87 | | ${dut1s_vlan_name} | ${dut1s_vlan_index}= | Create Vlan Subinterface
88 | |                    | ...                  | ${DUT1} | ${INT1_NAME} | ${VLAN}
89 | | ${dut2s_vlan_name} | ${dut2s_vlan_index}= | Create Vlan Subinterface
90 | |                    | ...                  | ${DUT2} | ${INT2_NAME} | ${VLAN}
91 | | Set Interface State | ${DUT1} | ${dut1s_vlan_index} | up
92 | | Set Interface State | ${DUT2} | ${dut2s_vlan_index} | up
93 | | Set Test Variable | ${dut1s_vlan_name}
94 | | Set Test Variable | ${dut1s_vlan_index}
95 | | Set Test Variable | ${dut2s_vlan_name}
96 | | Set Test Variable | ${dut2s_vlan_index}
97
98 | Send VXLAN receive VXLAN Packet
99 | | [Documentation] | Send VXLAN encapsulated Ethernet frame and check \
100 | | ... | received one.
101 | | ...
102 | | ... | *Arguments:*
103 | | ... | - tg_node - Node where to run traffic script. Type: dictionary
104 | | ... | - tx_if - Interface from where send VXLAN packet. Type: string
105 | | ... | - rx_if - Interface where receive VXLAN packet. Type: string
106 | | ... | - tx_src_mac - Source MAC address of sent packet. Type: string
107 | | ... | - tx_dst_mac - Destination MAC address of sent packet. Type: string
108 | | ... | - tx_src_ip - Source IP address of sent VXLAN packet. Type: string
109 | | ... | - tx_dst_ip - Destination IP address of sent VXLAN packet.
110 | | ... |   Type: string
111 | | ... | - tx_vni - VNI of sent VXLAN packet. Type: string
112 | | ... | - rx_src_ip - Source IP address of received VXLAN packet. Type: string
113 | | ... | - rx_dst_ip - Destination IP address of received VXLAN packet.
114 | | ... |   Type: string
115 | | ... | - rx_vni - VNI of received VXLAN packet. Type: string
116 | | ...
117 | | ... | *Return:*
118 | | ... | - No value returned
119 | | ...
120 | | ... | *Example:*
121 | | ...
122 | | ... | \| Send VXLAN receive VXLAN Packet \| ${tg_node} \| port4 \| port4  \
123 | | ... | \| fa:16:3e:6d:f9:c5 \| fa:16:3e:e6:6d:9a \| 192.168.0.1  \
124 | | ... | \| 192.168.0.2 \| ${101} \| 192.168.0.2 \| 192.168.0.1 \| ${102} \|
125 | | ...
126 | | [Arguments] | ${tg_node} | ${tx_if} | ${rx_if}
127 | | ... | ${tx_src_mac} | ${tx_dst_mac}
128 | | ... | ${tx_src_ip} | ${tx_dst_ip} | ${tx_vni}
129 | | ... | ${rx_src_ip} | ${rx_dst_ip} | ${rx_vni}
130 | | ${tx_if_name}= | Get interface name | ${tg_node} | ${tx_if}
131 | | ${rx_if_name}= | Get interface name | ${tg_node} | ${rx_if}
132 | | ${args}= | Catenate
133 | | ... | --tx_if ${tx_if_name}
134 | | ... | --rx_if ${rx_if_name}
135 | | ... | --tx_src_mac ${tx_src_mac}
136 | | ... | --tx_dst_mac ${tx_dst_mac}
137 | | ... | --tx_src_ip ${tx_src_ip}
138 | | ... | --tx_dst_ip ${tx_dst_ip}
139 | | ... | --tx_vni ${tx_vni}
140 | | ... | --rx_src_ip ${rx_src_ip}
141 | | ... | --rx_dst_ip ${rx_dst_ip}
142 | | ... | --rx_vni ${rx_vni}
143 | | Run Traffic Script On Node | send_vxlan_check_vxlan.py | ${tg_node} | ${args}