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