bf67ab78941bff78dd5830aa551afdfbc57236a0
[csit.git] / resources / libraries / robot / policer.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
14 *** Settings ***
15 | Resource | resources/libraries/robot/default.robot
16 | Resource | resources/libraries/robot/testing_path.robot
17 | Library | resources.libraries.python.Policer
18 | Library | resources.libraries.python.InterfaceUtil
19 | Library | resources.libraries.python.IPv4Util
20 | Library | resources.libraries.python.TrafficScriptExecutor
21 | Library | resources.libraries.python.IPv6Util
22 | Library | resources.libraries.python.IPv6Setup
23 | Library | resources.libraries.python.IPv4Setup.Dut | ${nodes['DUT1']}
24 | ...     | WITH NAME | dut1_v4
25 | Documentation | *Policer keywords*
26
27 *** Keywords ***
28 | Setup Topology for IPv4 policer testing
29 | | [Documentation] | Setup topology for IPv4 policer testing.
30 | | ...
31 | | ... | _NOTE:_ This KW sets following test case variables:
32 | | ... | - dut_to_tg_if1_ip - DUT first interface IP address. Type: string
33 | | ... | - dut_to_tg_if2_ip - DUT second interface IP address. Type: string
34 | | ... | - tg_to_dut_if1_ip - TG first interface IP address. Type: string
35 | | ... | - tg_to_dut_if2_ip - TG second interface IP address. Type: string
36 | | Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
37 | | ...                            | ${nodes['TG']}
38 | | Interfaces in 2-node path are up
39 | | Set Interface Address | ${dut_node} | ${dut_to_tg_if1}
40 | | ...                   | ${dut_to_tg_if1_ip4} | ${ip4_plen}
41 | | Set Interface Address | ${dut_node} | ${dut_to_tg_if2}
42 | | ...                   | ${dut_to_tg_if2_ip4} | ${ip4_plen}
43 | | dut1_v4.Set ARP | ${dut_to_tg_if2} | ${tg_to_dut_if2_ip4}
44 | | ...             | ${tg_to_dut_if2_mac}
45 | | Set Test Variable | ${dut_to_tg_if1_ip} | ${dut_to_tg_if1_ip4}
46 | | Set Test Variable | ${dut_to_tg_if2_ip} | ${dut_to_tg_if2_ip4}
47 | | Set Test Variable | ${tg_to_dut_if1_ip} | ${tg_to_dut_if1_ip4}
48 | | Set Test Variable | ${tg_to_dut_if2_ip} | ${tg_to_dut_if2_ip4}
49
50 | Setup Topology for IPv6 policer testing
51 | | [Documentation] | Setup topology for IPv6 policer testing.
52 | | ...
53 | | ... | _NOTE:_ This KW sets following test case variables:
54 | | ... | - dut_to_tg_if1_ip - DUT first interface IP address. Type: string
55 | | ... | - dut_to_tg_if2_ip - DUT second interface IP address. Type: string
56 | | ... | - tg_to_dut_if1_ip - TG first interface IP address. Type: string
57 | | ... | - tg_to_dut_if2_ip - TG second interface IP address. Type: string
58 | | Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
59 | | ...                            | ${nodes['TG']}
60 | | Interfaces in 2-node path are up
61 | | Vpp Set If IPv6 Addr | ${dut_node} | ${dut_to_tg_if1}
62 | | ...                  | ${dut_to_tg_if1_ip6} | ${ip6_plen}
63 | | Vpp Set If IPv6 Addr | ${dut_node} | ${dut_to_tg_if2}
64 | | ...                  | ${dut_to_tg_if2_ip6} | ${ip6_plen}
65 | | Add IP Neighbor | ${dut_node} | ${dut_to_tg_if2} | ${tg_to_dut_if2_ip6}
66 | | ...             | ${tg_to_dut_if2_mac}
67 | | Vpp All RA Suppress Link Layer | ${nodes}
68 | | Set Test Variable | ${dut_to_tg_if1_ip} | ${dut_to_tg_if1_ip6}
69 | | Set Test Variable | ${dut_to_tg_if2_ip} | ${dut_to_tg_if2_ip6}
70 | | Set Test Variable | ${tg_to_dut_if1_ip} | ${tg_to_dut_if1_ip6}
71 | | Set Test Variable | ${tg_to_dut_if2_ip} | ${tg_to_dut_if2_ip6}
72
73 | Send Packet and Verify Marking
74 | | [Documentation] | Send packet and verify DSCP of the received packet.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - node - TG node. Type: dictionary
78 | | ... | - tx_if - TG transmit interface. Type: string
79 | | ... | - rx_if - TG receive interface. Type: string
80 | | ... | - src_mac - Packet source MAC. Type: string
81 | | ... | - dst_mac - Packet destination MAC. Type: string
82 | | ... | - src_ip - Packet source IP address. Type: string
83 | | ... | - dst_ip - Packet destination IP address. Type: string
84 | | ... | - dscp - DSCP value to verify. Type: enum
85 | | ...
86 | | ... | *Example:*
87 | | ... | \| ${dscp}= \| DSCP AF22 \|
88 | | ... | \| Send Packet and Verify Marking \| ${nodes['TG']} \| eth1 \| eth2 \
89 | | ... | \| 08:00:27:87:4d:f7 \| 52:54:00:d4:d8:22 \| 192.168.122.2 \
90 | | ... | \| 192.168.122.1 \| ${dscp} \|
91 | | [Arguments] | ${node} | ${tx_if} | ${rx_if} | ${src_mac} | ${dst_mac}
92 | | ...         | ${src_ip} | ${dst_ip} | ${dscp}
93 | | ${tx_if_name}= | Get Interface Name | ${node} | ${tx_if}
94 | | ${rx_if_name}= | Get Interface Name | ${node} | ${rx_if}
95 | | ${args}= | Traffic Script Gen Arg | ${rx_if_name} | ${tx_if_name}
96 | | ...      | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
97 | | ${dscp_num}= | Get DSCP Num Value | ${dscp}
98 | | ${args}= | Set Variable | ${args} --dscp ${dscp_num}
99 | | Run Traffic Script On Node | policer.py | ${node} | ${args}