Add Honeycomb VxLAN test suite
[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
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 | | ${args}= | Traffic Script Gen Arg | ${to_port} | ${from_port} | ${src_mac}
71 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
72 | | ${args}= | Catenate | ${args} | --hops ${hops} | --first_hop_mac ${adj_int['mac_address']}
73 | |          | ...      | --is_dst_tg ${is_dst_tg}
74 | | Run Traffic Script On Node | ipv4_ping_ttl_check.py | ${from_node} | ${args}
75
76 | 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 | | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
88 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
89 | | ${args}= | Set Variable
90 | | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
91 | | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args} | ${20}
92
93 | Send ARP request and validate response
94 | | [Arguments] | ${tg_node} | ${vpp_node}
95 | | ${link_name}= | Get first active connecting link between node "${tg_node}" and "${vpp_node}"
96 | | ${src_if}= | Get interface by link name | ${tg_node} | ${link_name}
97 | | ${dst_if}= | Get interface by link name | ${vpp_node} | ${link_name}
98 | | ${src_ip}= | Get IPv4 address of node "${tg_node}" interface "${src_if}" from "${nodes_ipv4_addr}"
99 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}" from "${nodes_ipv4_addr}"
100 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
101 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
102 | | ${args}= | Traffic Script Gen Arg | ${src_if} | ${src_if} | ${src_mac}
103 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
104 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
105
106 | IP addresses are set on interfaces
107 | | [Documentation] | Iterates through @{args} list and Set Interface Address
108 | | ...             | for every (${dut_node}, ${interface}, ${address},
109 | | ...             | ${prefix}) tuple.
110 | | ...
111 | | ... | *Arguments:*
112 | | ... | - ${dut_node} - Node where IP address should be set to.
113 | | ... |   Type: dictionary
114 | | ... | - ${interface} - Interface name. Type: string
115 | | ... | - ${address} - IP address. Type: string
116 | | ... | - ${prefix} - Prefix length. Type: integer
117 | | ...
118 | | ... | *Example:*
119 | | ...
120 | | ... | \| IP addresses are set on interfaces \
121 | | ... | \| ${dut1_node} \| ${dut1_to_dut2} \| 192.168.1.1 \| 24 \|
122 | | ... | \| ... \| ${dut1_node} \| ${dut1_to_tg}   \| 192.168.2.1 \| 24 \|
123 | | ...
124 | | [Arguments] | @{args}
125 | | :FOR | ${dut_node} | ${interface} | ${address} | ${prefix} | IN | @{args}
126 | | | Set Interface Address | ${dut_node} | ${interface} | ${address}
127 | | | ... | ${prefix}