LF testbed2 topology, T-REX upgrade, vpe->vpp rename
[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
17 | Library | resources.libraries.python.TrafficScriptExecutor
18 | Variables | resources/libraries/python/IPv4NodeAddress.py
19
20 *** Keywords ***
21
22 | Setup IPv4 adresses on all DUT nodes in topology
23 | | [Documentation] | Setup IPv4 address on all DUTs in topology
24 | | [Arguments] | ${nodes} | ${nodes_addr}
25 | | DUT Nodes setup IPv4 addresses | ${nodes} | ${nodes_addr}
26
27 | Interfaces needed for IPv4 testing are in "${state}" state
28 | | Node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}" is in "${state}" state
29 | | Node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port3']['name']}" is in "${state}" state
30 | | Node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}" is in "${state}" state
31 | | Node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port3']['name']}" is in "${state}" state
32
33 | Routes are set up for IPv4 testing
34 | | ${gateway} = | Get IPv4 address of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port3']['name']}"
35 | | ${subnet} = | Get IPv4 subnet of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}"
36 | | ${prefix_length} = | Get IPv4 address prefix of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}"
37 | | Node "${nodes['DUT1']}" routes to IPv4 network "${subnet}" with prefix length "${prefix_length}" using interface "${nodes['DUT1']['interfaces']['port3']['name']}" via "${gateway}"
38 | | ${gateway} = | Get IPv4 address of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port3']['name']}"
39 | | ${subnet} = | Get IPv4 subnet of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}"
40 | | ${prefix_length} = | Get IPv4 address prefix of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}"
41 | | Node "${nodes['DUT2']}" routes to IPv4 network "${subnet}" with prefix length "${prefix_length}" using interface "${nodes['DUT2']['interfaces']['port3']['name']}" via "${gateway}"
42
43 | Setup DUT nodes for IPv4 testing
44 | | Interfaces needed for IPv4 testing are in "up" state
45 | | Setup IPv4 adresses on all DUT nodes in topology | ${nodes} | ${nodes_ipv4_addr}
46 | | Setup ARP on all DUTs | ${nodes}
47 | | Routes are set up for IPv4 testing
48
49 | Setup nodes for IPv4 testing
50 | | Interfaces needed for IPv4 testing are in "up" state
51 | | Setup IPv4 adresses on all DUT nodes in topology | ${nodes} | ${nodes_ipv4_addr}
52 | | Setup ARP on all DUTs | ${nodes}
53 | | Routes are set up for IPv4 testing
54
55 | TG interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
56 | | Node "${nodes['TG']}" interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
57
58 | Node "${from_node}" interface "${from_port}" can route to node "${to_node}" interface "${to_port}" "${hops}" hops away using IPv4
59 | | After ping is sent in topology "${nodes}" from node "${from_node}" interface "${from_port}" with destination IPv4 address of node "${to_node}" interface "${to_port}" a ping response arrives and TTL is decreased by "${hops}"
60
61 | Ipv4 icmp echo sweep
62 | | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
63 | | [Arguments] | ${src_node} | ${dst_node} | ${src_port} | ${dst_port}
64 | | ${src_ip}= | Get IPv4 address of node "${src_node}" interface "${src_port}"
65 | | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}"
66 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
67 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
68 | | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
69 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
70 | # TODO: end_size is currently minimum MTU size for Ethernet minus IPv4 and
71 | # ICMP echo header size (1500 - 20 - 8),
72 | # MTU info is not in VAT sw_interface_dump output
73 | | ${args}= | Set Variable | ${args} --start_size 0 --end_size 1472 --step 1
74 | | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args}
75
76 | Send ARP request and validate response
77 | | [Arguments] | ${tg_node} | ${vpp_node}
78 | | ${link_name}= | Get first active connecting link between node "${tg_node}" and "${vpp_node}"
79 | | ${src_if}= | Get interface by link name | ${tg_node} | ${link_name}
80 | | ${dst_if}= | Get interface by link name | ${vpp_node} | ${link_name}
81 | | ${src_ip}= | Get IPv4 address of node "${tg_node}" interface "${src_if}"
82 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}"
83 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
84 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
85 | | ${args}= | Traffic Script Gen Arg | ${src_if} | ${src_if} | ${src_mac}
86 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
87 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
88