CSIT-576 HC Test: Improve SPAN test coverage
[csit.git] / resources / libraries / robot / ipv4.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 *** Settings ***
14 | Resource | resources/libraries/robot/default.robot
15 | Resource | resources/libraries/robot/counters.robot
16 | Library | resources.libraries.python.IPv4Util.IPv4Util
17 | Library | resources.libraries.python.IPv4Setup.IPv4Setup
18 | Library | resources.libraries.python.NodePath
19 | Library | resources.libraries.python.Routing
20 | Library | resources.libraries.python.TrafficScriptExecutor
21 | Library | resources.libraries.python.InterfaceUtil
22 | Variables | resources/libraries/python/IPv4NodeAddress.py | ${nodes}
23
24 *** Keywords ***
25
26 | Setup IPv4 adresses on all DUT nodes in topology
27 | | [Documentation] | Setup IPv4 address on all DUTs in topology
28 | | [Arguments] | ${nodes} | ${nodes_addr}
29 | | ${interfaces}= | VPP nodes set ipv4 addresses | ${nodes} | ${nodes_addr}
30 | | :FOR | ${interface} | IN | @{interfaces}
31 | | | Set Interface State | @{interface} | up | if_type=name
32
33 | Routes are set up for IPv4 testing
34 | | [Documentation] | Setup routing on all VPP nodes required for IPv4 tests
35 | | [Arguments] | ${nodes} | ${nodes_addr}
36 | | Append Nodes | ${nodes['DUT1']} | ${nodes['DUT2']}
37 | | Compute Path
38 | | ${tg}= | Set Variable | ${nodes['TG']}
39 | | ${dut1_if} | ${dut1}= | First Interface
40 | | ${dut2_if} | ${dut2}= | Last Interface
41 | | ${dut1_if_addr}= | Get IPv4 address of node "${dut1}" interface "${dut1_if}" from "${nodes_addr}"
42 | | ${dut2_if_addr}= | Get IPv4 address of node "${dut2}" interface "${dut2_if}" from "${nodes_addr}"
43 | | @{tg_dut1_links}= | Get active links connecting "${tg}" and "${dut1}"
44 | | @{tg_dut2_links}= | Get active links connecting "${tg}" and "${dut2}"
45 | | :FOR | ${link} | IN | @{tg_dut1_links}
46 | | | ${net}= | Get Link Address | ${link} | ${nodes_addr}
47 | | | ${prefix}= | Get Link Prefix | ${link} | ${nodes_addr}
48 | | | Vpp Route Add | ${dut2} | ${net} | ${prefix} | ${dut1_if_addr} | ${dut2_if}
49 | | :FOR | ${link} | IN | @{tg_dut2_links}
50 | | | ${net}= | Get Link Address | ${link} | ${nodes_addr}
51 | | | ${prefix}= | Get Link Prefix | ${link} | ${nodes_addr}
52 | | | Vpp Route Add | ${dut1} | ${net} | ${prefix} | ${dut2_if_addr} | ${dut1_if}
53
54 | Setup DUT nodes for IPv4 testing
55 | | Setup IPv4 adresses on all DUT nodes in topology | ${nodes} | ${nodes_ipv4_addr}
56 | | Setup ARP on all DUTs | ${nodes} | ${nodes_ipv4_addr}
57 | | Routes are set up for IPv4 testing | ${nodes} | ${nodes_ipv4_addr}
58 | | All Vpp Interfaces Ready Wait | ${nodes}
59
60 | TG interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
61 | | Node "${nodes['TG']}" interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
62
63 | Node "${from_node}" interface "${from_port}" can route to node "${to_node}" interface "${to_port}" ${hops} hops away using IPv4
64 | | ${src_ip}= | Get IPv4 address of node "${from_node}" interface "${from_port}" from "${nodes_ipv4_addr}"
65 | | ${dst_ip}= | Get IPv4 address of node "${to_node}" interface "${to_port}" from "${nodes_ipv4_addr}"
66 | | ${src_mac}= | Get interface mac | ${from_node} | ${from_port}
67 | | ${dst_mac}= | Get interface mac | ${to_node} | ${to_port}
68 | | ${is_dst_tg}= | Is TG node | ${to_node}
69 | | ${adj_node} | ${adj_int}= | Get adjacent node and interface | ${nodes} | ${from_node} | ${from_port}
70 | | ${from_port_name}= | Get interface name | ${from_node} | ${from_port}
71 | | ${to_port_name}= | Get interface name | ${to_node} | ${to_port}
72 | | ${adj_int_mac}= | Get interface MAC | ${adj_node} | ${adj_int}
73 | | ${args}= | Traffic Script Gen Arg | ${to_port_name} | ${from_port_name} | ${src_mac}
74 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
75 | | ${args}= | Catenate | ${args} | --hops ${hops} | --first_hop_mac ${adj_int_mac}
76 | |          | ...      | --is_dst_tg ${is_dst_tg}
77 | | Run Traffic Script On Node | ipv4_ping_ttl_check.py | ${from_node} | ${args}
78
79 | Ipv4 icmp echo sweep
80 | | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
81 | | [Arguments] | ${src_node} | ${dst_node} | ${start_size} | ${end_size} | ${step}
82 | | Append Nodes | ${src_node} | ${dst_node}
83 | | Compute Path
84 | | ${src_port} | ${src_node}= | First Interface
85 | | ${dst_port} | ${dst_node}= | Last Interface
86 | | ${src_ip}= | Get IPv4 address of node "${src_node}" interface "${src_port}" from "${nodes_ipv4_addr}"
87 | | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}" from "${nodes_ipv4_addr}"
88 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
89 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
90 | | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
91 | | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name}
92 | |          | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
93 | | ${args}= | Set Variable
94 | | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
95 | | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args}
96 | | ... | timeout=${180}
97
98 | Send ARP request and validate response
99 | | [Arguments] | ${tg_node} | ${vpp_node}
100 | | ${link_name}= | Get first active connecting link between node "${tg_node}" and "${vpp_node}"
101 | | ${src_if}= | Get interface by link name | ${tg_node} | ${link_name}
102 | | ${dst_if}= | Get interface by link name | ${vpp_node} | ${link_name}
103 | | ${src_ip}= | Get IPv4 address of node "${tg_node}" interface "${src_if}" from "${nodes_ipv4_addr}"
104 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}" from "${nodes_ipv4_addr}"
105 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
106 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
107 | | ${src_if_name}= | Get interface name | ${tg_node} | ${src_if}
108 | | ${args}= | Traffic Script Gen Arg | ${src_if_name} | ${src_if_name} | ${src_mac}
109 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
110 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
111
112 | IP addresses are set on interfaces
113 | | [Documentation] | Iterates through @{args} list and Set Interface Address
114 | | ...             | for every (${dut_node}, ${interface}, ${address},
115 | | ...             | ${prefix}) tuple.
116 | | ...
117 | | ... | *Arguments:*
118 | | ... | - ${dut_node} - Node where IP address should be set to.
119 | | ... |   Type: dictionary
120 | | ... | - ${interface} - Interface name. Type: string
121 | | ... | - ${address} - IP address. Type: string
122 | | ... | - ${prefix} - Prefix length. Type: integer
123 | | ...
124 | | ... | *Example:*
125 | | ...
126 | | ... | \| IP addresses are set on interfaces \
127 | | ... | \| ${dut1_node} \| ${dut1_to_dut2} \| 192.168.1.1 \| 24 \|
128 | | ... | \| ... \| ${dut1_node} \| ${dut1_to_tg}   \| 192.168.2.1 \| 24 \|
129 | | ...
130 | | [Arguments] | @{args}
131 | | :FOR | ${dut_node} | ${interface} | ${address} | ${prefix} | IN | @{args}
132 | | | Set Interface Address | ${dut_node} | ${interface} | ${address}
133 | | | ... | ${prefix}
134
135 | Node replies to ICMP echo request
136 | | [Documentation] | Run traffic script that waits for ICMP reply and ignores
137 | | ...             | all other packets.
138 | | ...
139 | | ... | *Arguments:*
140 | | ... | - tg_node - TG node where run traffic script. Type: dictionary
141 | | ... | - tg_interface - TG interface where send ICMP echo request.
142 | | ... |   Type: string
143 | | ... | - dst_mac - Destination MAC address. Type: string
144 | | ... | - src_mac - Source MAC address. Type: string
145 | | ... | - dst_ip - Destination IP address. Type: string
146 | | ... | - src_ip - Source IP address. Type: string
147 | | ... | - timeout - Wait timeout in seconds (Default: 10). Type: integer
148 | | ...
149 | | ... | *Example:*
150 | | ...
151 | | ... | \| Node replies to ICMP echo request \
152 | | ... | \| ${nodes['TG']} \| eth2 \
153 | | ... | \| 08:00:27:46:2b:4c \| 08:00:27:66:b8:57 \
154 | | ... | \| 192.168.23.10 \| 192.168.23.1 \| 10 \|
155 | | ...
156 | | [Arguments] | ${tg_node} | ${tg_interface}
157 | | ... | ${dst_mac} | ${src_mac} | ${dst_ip} | ${src_ip} | ${timeout}=${10}
158 | | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
159 | | ${args}= | Catenate | --rx_if | ${tg_interface_name} | --tx_if | ${tg_interface_name}
160 | | ... | --dst_mac | ${dst_mac} | --src_mac | ${src_mac}
161 | | ... | --dst_ip | ${dst_ip} | --src_ip | ${src_ip} | --timeout | ${timeout}
162 | | Run Traffic Script On Node | send_icmp_wait_for_reply.py
163 | | ... | ${tg_node} | ${args}