Update of latest tests.
[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 and TG 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 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 | TG interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
50 | | Node "${nodes['TG']}" interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
51
52 | Node "${from_node}" interface "${from_port}" can route to node "${to_node}" interface "${to_port}" "${hops}" hops away using IPv4
53 | | 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}"
54
55 | Ipv4 icmp echo sweep
56 | | [Documentation] | Type of the src_node must be TG and dst_node must be DUT
57 | | [Arguments] | ${src_node} | ${dst_node} | ${src_port} | ${dst_port}
58 | | ${src_ip}= | Get IPv4 address of node "${src_node}" interface "${src_port}"
59 | | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}"
60 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
61 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
62 | | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
63 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
64 | # TODO: end_size is currently minimum MTU size for Ethernet minus IPv4 and
65 | # ICMP echo header size (1500 - 20 - 8),
66 | # MTU info is not in VAT sw_interface_dump output
67 | | ${args}= | Set Variable | ${args} --start_size 0 --end_size 1472 --step 1
68 | | Run Traffic Script On Node | ipv4_sweep_ping.py | ${src_node} | ${args}
69
70 | Send ARP request and validate response
71 | | [Arguments] | ${tg_node} | ${vpp_node}
72 | | ${link_name}= | Get first active connecting link between node "${tg_node}" and "${vpp_node}"
73 | | ${src_if}= | Get interface by link name | ${tg_node} | ${link_name}
74 | | ${dst_if}= | Get interface by link name | ${vpp_node} | ${link_name}
75 | | ${src_ip}= | Get IPv4 address of node "${tg_node}" interface "${src_if}"
76 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}"
77 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
78 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
79 | | ${args}= | Traffic Script Gen Arg | ${src_if} | ${src_if} | ${src_mac}
80 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
81 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
82