CSIT-687: Directory structure reorganization
[csit.git] / resources / libraries / robot / honeycomb / policer.robot
1 # Copyright (c) 2017 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/shared/traffic.robot
16 | Library | resources.libraries.python.honeycomb.Routing.RoutingKeywords
17 | Variables | resources/test_data/honeycomb/policer_variables.py
18 | Documentation | Keywords used to test Policer using Honeycomb.
19
20 *** Keywords ***
21 | Honeycomb Configures Policer
22 | | [Documentation] | Uses Honeycomb API to configure Policer on the specified\
23 | | ... | interface.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - policer_data - data needed to configure Policer. Type: dictionary
28 | | ...
29 | | ... | *Example:*
30 | | ...
31 | | ... | \| Honeycomb Configures Policer \| ${node} \
32 | | ... | \| ${policer_data} \|
33 | | ...
34 | | [Arguments] | ${node} | ${policer_data}
35 | | Configure Policer
36 | | ... | ${node} | ${policer_data['name']} | ${policer_data}
37
38 | Policer Operational Data From Honeycomb Should Be
39 | | [Documentation] | Retrieves Policer operational data and verifies if\
40 | | ... | Policer is configured correctly.
41 | | ...
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - policer_data - data to compare configuration Policer with.\
45 | | ... | Type: dictionary
46 | | ...
47 | | ... | *Example:*
48 | | ...
49 | | ... | \| Policer Operational Data From Honeycomb Should Be \
50 | | ... | \| ${node} \| ${policer_data} \|
51 | | ...
52 | | [Arguments] | ${node} | ${policer_data}
53 | | ${data}= | Get Policer oper data | ${node} | ${policer_data['name']}
54 | | Compare data structures | ${data[0]} | ${policer_data}
55
56 | Policer Operational Data From Honeycomb Should Be empty
57 | | [Documentation] | Checks whether Policer configuration from Honeycomb \
58 | | ... | is empty.
59 | | ...
60 | | ... | *Arguments:*
61 | | ... | - node - Information about a DUT node. Type: dictionary
62 | | ...
63 | | ... | *Example:*
64 | | ...
65 | | ... | \| Policer Operational Data From Honeycomb Should Be empty \
66 | | ... | \| ${node} \|
67 | | ...
68 | | [Arguments] | ${node}
69 | | Run keyword and expect error | HoneycombError*404*
70 | | ... | Get Policer oper data | ${node} | ${policer_data['name']}
71
72 | Honeycomb removes Policer configuration
73 | | [Documentation] | Uses Honeycomb API to remove Policer configuration\
74 | | ... | from the specified interface.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - node - information about a DUT node. Type: dictionary
78 | | ...
79 | | ... | *Example:*
80 | | ...
81 | | ... | \| Honeycomb removes Policer configuration \
82 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
83 | | ...
84 | | [Arguments] | ${node}
85 | | Configure Policer | ${node} | ${policer_data['name']}
86
87 | Tear down policer test
88 | | [Documentation] | Uses Honeycomb API to remove Policer configuration\
89 | | ... | and reset interface state.
90 | | ...
91 | | ... | *Arguments:*
92 | | ... | - node - information about a DUT node. Type: dictionary
93 | | ...
94 | | ... | *Example:*
95 | | ...
96 | | ... | \| Honeycomb removes Policer configuration \
97 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
98 | | ...
99 | | [Arguments] | ${node}
100 | | Honeycomb removes Policer configuration | ${node}
101
102 | Honeycomb enables Policer on interface
103 | | [Documentation] | Uses Honeycomb API to enable Policer on an interface.
104 | | ...
105 | | ... | *Arguments:*
106 | | ... | - node - information about a DUT node. Type: dictionary
107 | | ... | - interface - name of an interface on the specified node. Type: string
108 | | ... | - table_name - name of an ACL table. Type: string
109 | | ...
110 | | ... | *Example:*
111 | | ...
112 | | ... | \| Honeycomb enables ACL on interface \| ${nodes['DUT1']} \
113 | | ... | \| GigabithEthernet0/8/0 \| table0 \|
114 | | ...
115 | | [Arguments] | ${node} | ${interface} | ${table_name}
116 | | Enable Policer on interface
117 | | ... | ${node} | ${interface} | ${table_name}
118
119 | Honeycomb disables Policer on interface
120 | | [Documentation] | Uses Honeycomb API to disable Policer on an interface.
121 | | ...
122 | | ... | *Arguments:*
123 | | ... | - node - information about a DUT node. Type: dictionary
124 | | ... | - interface - name of an interface on the specified node. Type: string
125 | | ...
126 | | ... | *Example:*
127 | | ...
128 | | ... | \| Honeycomb disables Policer on interface \| ${nodes['DUT1']} \
129 | | ... | \| GigabithEthernet0/8/0 \|
130 | | ...
131 | | [Arguments] | ${node} | ${interface}
132 | | Disable Policer on interface
133 | | ... | ${node} | ${interface}
134
135 | Honeycomb Send packet and verify marking
136 | | [Documentation] | Send packet and verify DSCP of the received packet.
137 | | ...
138 | | ... | *Arguments:*
139 | | ... | - node - TG node. Type: dictionary
140 | | ... | - tx_if - TG transmit interface. Type: string
141 | | ... | - rx_if - TG receive interface. Type: string
142 | | ... | - src_mac - Packet source MAC. Type: string
143 | | ... | - dst_mac - Packet destination MAC. Type: string
144 | | ... | - src_ip - Packet source IP address. Type: string
145 | | ... | - dst_ip - Packet destination IP address. Type: string
146 | | ... | - dscp_num - DSCP value to verify. Type: integer
147 | | ...
148 | | ... | *Example:*
149 | | ...
150 | | ... | \| ${dscp}= \| DSCP AF22 \|
151 | | ... | \| Send packet and verify marking \| ${nodes['TG']} \| eth1 \| eth2 \
152 | | ... | \| 08:00:27:87:4d:f7 \| 52:54:00:d4:d8:22 \| 192.168.122.2 \
153 | | ... | \| 192.168.122.1 \| ${dscp} \|
154 | | ...
155 | | [Arguments] | ${node} | ${tx_if} | ${rx_if} | ${src_mac} | ${dst_mac}
156 | | ...         | ${src_ip} | ${dst_ip} | ${dscp_num}
157 | | ${tx_if_name}= | Get Interface Name | ${node} | ${tx_if}
158 | | ${rx_if_name}= | Get Interface Name | ${node} | ${rx_if}
159 | | ${args}= | Traffic Script Gen Arg | ${rx_if_name} | ${tx_if_name}
160 | | ...      | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
161 | | ${args}= | Set Variable | ${args} --dscp ${dscp_num}
162 | | Run Traffic Script On Node | policer.py | ${node} | ${args}