03964181b531c32b3c90d19e6b9d7b6a6ac8a2ba
[csit.git] / resources / libraries / robot / ip / ip4.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/shared/default.robot
15 | Resource | resources/libraries/robot/shared/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 | Configure IPv4 addresses on all DUTs
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 | Configure routes for IPv4 test
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 | Configure DUT nodes for IPv4 testing
55 | | Configure IPv4 addresses on all DUTs | ${nodes} | ${nodes_ipv4_addr}
56 | | Setup ARP on all DUTs | ${nodes} | ${nodes_ipv4_addr}
57 | | Configure routes for IPv4 test | ${nodes} | ${nodes_ipv4_addr}
58 | | All Vpp Interfaces Ready Wait | ${nodes}
59
60 | Route traffic from interface '${from_port}' on node '${from_node}' to interface '${to_port}' on node '${to_node}' '${hops}' hops away using IPv4
61 | | ${src_ip}= | Get IPv4 address of node "${from_node}" interface "${from_port}" from "${nodes_ipv4_addr}"
62 | | ${dst_ip}= | Get IPv4 address of node "${to_node}" interface "${to_port}" from "${nodes_ipv4_addr}"
63 | | ${src_mac}= | Get interface mac | ${from_node} | ${from_port}
64 | | ${dst_mac}= | Get interface mac | ${to_node} | ${to_port}
65 | | ${is_dst_tg}= | Is TG node | ${to_node}
66 | | ${adj_node} | ${adj_int}= | Get adjacent node and interface | ${nodes} | ${from_node} | ${from_port}
67 | | ${from_port_name}= | Get interface name | ${from_node} | ${from_port}
68 | | ${to_port_name}= | Get interface name | ${to_node} | ${to_port}
69 | | ${adj_int_mac}= | Get interface MAC | ${adj_node} | ${adj_int}
70 | | ${args}= | Traffic Script Gen Arg | ${to_port_name} | ${from_port_name} | ${src_mac}
71 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
72 | | ${args}= | Catenate | ${args} | --hops ${hops} | --first_hop_mac ${adj_int_mac}
73 | |          | ...      | --is_dst_tg ${is_dst_tg}
74 | | Run Traffic Script On Node | ipv4_ping_ttl_check.py | ${from_node} | ${args}
75
76 | Execute IPv4 ICMP echo sweep
77 | | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
78 | | [Arguments] | ${src_node} | ${dst_node} | ${start_size} | ${end_size} | ${step}
79 | | Append Nodes | ${src_node} | ${dst_node}
80 | | Compute Path
81 | | ${src_port} | ${src_node}= | First Interface
82 | | ${dst_port} | ${dst_node}= | Last Interface
83 | | ${src_ip}= | Get IPv4 address of node "${src_node}" interface "${src_port}" from "${nodes_ipv4_addr}"
84 | | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}" from "${nodes_ipv4_addr}"
85 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
86 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
87 | | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
88 | | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name}
89 | |          | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
90 | | ${args}= | Set Variable
91 | | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
92 | | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args}
93 | | ... | timeout=${180}
94
95 | Send ARP request and verify response
96 | | [Arguments] | ${tg_node} | ${vpp_node}
97 | | ${link_name}= | Get first active connecting link between node "${tg_node}" and "${vpp_node}"
98 | | ${src_if}= | Get interface by link name | ${tg_node} | ${link_name}
99 | | ${dst_if}= | Get interface by link name | ${vpp_node} | ${link_name}
100 | | ${src_ip}= | Get IPv4 address of node "${tg_node}" interface "${src_if}" from "${nodes_ipv4_addr}"
101 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}" from "${nodes_ipv4_addr}"
102 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
103 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
104 | | ${src_if_name}= | Get interface name | ${tg_node} | ${src_if}
105 | | ${args}= | Traffic Script Gen Arg | ${src_if_name} | ${src_if_name} | ${src_mac}
106 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
107 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
108
109 | Configure IP addresses on interfaces
110 | | [Documentation] | Iterates through @{args} list and Set Interface Address
111 | | ... | for every (${dut_node}, ${interface}, ${address},
112 | | ... | ${prefix}) tuple.
113 | | ...
114 | | ... | *Arguments:*
115 | | ... | - ${dut_node} - Node where IP address should be set to.
116 | | ... | Type: dictionary
117 | | ... | - ${interface} - Interface name. Type: string
118 | | ... | - ${address} - IP address. Type: string
119 | | ... | - ${prefix} - Prefix length. Type: integer
120 | | ...
121 | | ... | *Example:*
122 | | ...
123 | | ... | \| Configure IP addresses on interfaces \
124 | | ... | \| ${dut1_node} \| ${dut1_to_dut2} \| 192.168.1.1 \| 24 \|
125 | | ... | \| ... \| ${dut1_node} \| ${dut1_to_tg}   \| 192.168.2.1 \| 24 \|
126 | | ...
127 | | [Arguments] | @{args}
128 | | :FOR | ${dut_node} | ${interface} | ${address} | ${prefix} | IN | @{args}
129 | | | Set Interface Address | ${dut_node} | ${interface} | ${address}
130 | | | ... | ${prefix}
131
132 | Send ICMP echo request and verify answer
133 | | [Documentation] | Run traffic script that waits for ICMP reply and ignores
134 | | ... | all other packets.
135 | | ...
136 | | ... | *Arguments:*
137 | | ... | - tg_node - TG node where run traffic script. Type: dictionary
138 | | ... | - tg_interface - TG interface where send ICMP echo request.
139 | | ... | Type: string
140 | | ... | - dst_mac - Destination MAC address. Type: string
141 | | ... | - src_mac - Source MAC address. Type: string
142 | | ... | - dst_ip - Destination IP address. Type: string
143 | | ... | - src_ip - Source IP address. Type: string
144 | | ... | - timeout - Wait timeout in seconds (Default: 10). Type: integer
145 | | ...
146 | | ... | *Example:*
147 | | ...
148 | | ... | \| Send ICMP echo request and verify answer \
149 | | ... | \| ${nodes['TG']} \| eth2 \
150 | | ... | \| 08:00:27:46:2b:4c \| 08:00:27:66:b8:57 \
151 | | ... | \| 192.168.23.10 \| 192.168.23.1 \| 10 \|
152 | | ...
153 | | [Arguments] | ${tg_node} | ${tg_interface}
154 | | ... | ${dst_mac} | ${src_mac} | ${dst_ip} | ${src_ip} | ${timeout}=${10}
155 | | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
156 | | ${args}= | Catenate | --rx_if | ${tg_interface_name} | --tx_if | ${tg_interface_name}
157 | | ... | --dst_mac | ${dst_mac} | --src_mac | ${src_mac}
158 | | ... | --dst_ip | ${dst_ip} | --src_ip | ${src_ip} | --timeout | ${timeout}
159 | | Run Traffic Script On Node | send_icmp_wait_for_reply.py
160 | | ... | ${tg_node} | ${args}