Python3: resources and libraries
[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.Classify
16 | Library | resources.libraries.python.Policer
17 |
18 | Documentation | Policer keywords
19
20 *** Keywords ***
21 | Initialize IPv4 policer 2r3c-${t} in circular topology
22 | | [Documentation]
23 | | ... | Setup of 2r3c color-aware or color-blind policer with dst IPv4 match
24 | | ... | on all DUT nodes in 2-node / 3-node circular topology. Policer is
25 | | ... | applied on links TG - DUTx.
26 | |
27 | | ${policer_index}= | Policer Set Configuration | ${dut1} | policer1 | ${cir}
28 | | ... | ${eir} | ${cb} | ${eb} | pps | Closest | 2R3C_RFC_2698 | Transmit
29 | | ... | Mark_and_Transmit | Transmit | ${t} | exceed_dscp=${dscp}
30 | | ${table_idx} | ${skip_n} | ${match_n}= | Vpp Creates Classify Table L3
31 | | ... | ${dut1} | ip4 | dst | 255.255.255.255
32 | | ${pre_color}= | Policer Classify Get Precolor | exceed_color
33 | | Vpp Configures Classify Session L3 | ${dut1} | permit | ${table_idx}
34 | | ... | ${skip_n} | ${match_n} | ip4 | dst | 20.20.20.2
35 | | ... | hit_next_index=${policer_index} | opaque_index=${pre_color}
36 | | Policer Classify Set Interface | ${dut1} | ${dut1_if1}
37 | | ... | ip4_table_index=${table_idx}
38 | |
39 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
40 | | ... | Variable Should Exist | ${dut2}
41 | | ${dut}= | Run Keyword If | '${dut2_status}' == 'PASS'
42 | | ... | Set Variable | ${dut2}
43 | | ... | ELSE | Set Variable | ${dut1}
44 | | ${dut_if2}= | Run Keyword If | '${dut2_status}' == 'PASS'
45 | | ... | Set Variable | ${dut2_if2}
46 | | ... | ELSE | Set Variable | ${dut1_if2}
47 | |
48 | | ${policer_index}= | Run Keyword If | '${dut2_status}' == 'PASS'
49 | | ... | Policer Set Configuration | ${dut} | policer2 | ${cir}
50 | | ... | ${eir} | ${cb} | ${eb} | pps | Closest | 2R3C_RFC_2698 | Transmit
51 | | ... | Mark_and_Transmit | Transmit | ${t} | exceed_dscp=${dscp}
52 | | ... | ELSE | Set Variable | ${policer_index}
53 | | ${table_idx} | ${skip_n} | ${match_n}=
54 | | ... | Run Keyword If | '${dut2_status}' == 'PASS'
55 | | ... | Vpp Creates Classify Table L3 | ${dut} | ip4 | dst | 255.255.255.255
56 | | ... | ELSE | Set Variable | ${table_idx} | ${skip_n} | ${match_n}
57 | | Vpp Configures Classify Session L3 | ${dut} | permit | ${table_idx}
58 | | ... | ${skip_n} | ${match_n} | ip4 | dst | 10.10.10.2
59 | | ... | hit_next_index=${policer_index} | opaque_index=${pre_color}
60 | | Policer Classify Set Interface | ${dut} | ${dut_if2}
61 | | ... | ip4_table_index=${table_idx}
62
63 | Initialize IPv6 policer 2r3c-${t} in circular topology
64 | | [Documentation]
65 | | ... | Setup of 2r3c color-aware or color-blind policer with dst IPv6 match
66 | | ... | on all DUT nodes in 2-node / 3-node circular topology. Policer is
67 | | ... | applied on links TG - DUTx.
68 | |
69 | | ${policer_index}= | Policer Set Configuration | ${dut1} | policer1 | ${cir}
70 | | ... | ${eir} | ${cb} | ${eb} | pps | Closest | 2R3C_RFC_2698 | Transmit
71 | | ... | Mark_and_Transmit | Transmit | ${t} | exceed_dscp=${dscp}
72 | | ${table_idx} | ${skip_n} | ${match_n}= | Vpp Creates Classify Table L3
73 | | ... | ${dut1} | ip6 | dst | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
74 | | ${pre_color}= | Policer Classify Get Precolor | exceed_color
75 | | Vpp Configures Classify Session L3 | ${dut1} | permit | ${table_idx}
76 | | ... | ${skip_n} | ${match_n} | ip6 | dst | 2001:2::2
77 | | ... | hit_next_index=${policer_index} | opaque_index=${pre_color}
78 | | Policer Classify Set Interface | ${dut1} | ${dut1_if1}
79 | | ... | ip6_table_index=${table_idx}
80 | |
81 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
82 | | ... | Variable Should Exist | ${dut2}
83 | | ${dut}= | Run Keyword If | '${dut2_status}' == 'PASS'
84 | | ... | Set Variable | ${dut2}
85 | | ... | ELSE | Set Variable | ${dut1}
86 | | ${dut_if2}= | Run Keyword If | '${dut2_status}' == 'PASS'
87 | | ... | Set Variable | ${dut2_if2}
88 | | ... | ELSE | Set Variable | ${dut1_if2}
89 | |
90 | | ${policer_index}= | Run Keyword If | '${dut2_status}' == 'PASS'
91 | | ... | Policer Set Configuration | ${dut} | policer2 | ${cir}
92 | | ... | ${eir} | ${cb} | ${eb} | pps | Closest | 2R3C_RFC_2698 | Transmit
93 | | ... | Mark_and_Transmit | Transmit | ${t} | exceed_dscp=${dscp}
94 | | ... | ELSE | Set Variable | ${policer_index}
95 | | ${table_idx} | ${skip_n} | ${match_n}=
96 | | ... | Run Keyword If | '${dut2_status}' == 'PASS'
97 | | ... | Vpp Creates Classify Table L3
98 | | ... | ${dut} | ip6 | dst | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
99 | | ... | ELSE | Set Variable | ${table_idx} | ${skip_n} | ${match_n}
100 | | Vpp Configures Classify Session L3 | ${dut} | permit | ${table_idx}
101 | | ... | ${skip_n} | ${match_n} | ip6 | dst | 2001:1::2
102 | | ... | hit_next_index=${policer_index} | opaque_index=${pre_color}
103 | | Policer Classify Set Interface | ${dut} | ${dut_if2}
104 | | ... | ip6_table_index=${table_idx}
105
106 | Show Classify Tables Verbose on all DUTs
107 | | [Documentation] | Show classify tables verbose on all DUT nodes in topology.
108 | |
109 | | ... | *Arguments:*
110 | | ... | - nodes - Topology. Type: dictionary
111 | |
112 | | ... | *Example:*
113 | |
114 | | ... | \| Show Classify Tables Verbose on all DUTs \| ${nodes} \|
115 | |
116 | | [Arguments] | ${nodes}
117 | |
118 | | ${duts}= | Get Matches | ${nodes} | DUT*
119 | | FOR | ${dut} | IN | @{duts}
120 | | | Show Classify Tables Verbose | ${nodes['${dut}']}
121 | | END