Add dot1q-l2[bd|xc]base-[ndrpdr|mrr] perf tests for 2-node topology
[csit.git] / resources / libraries / robot / l2 / tagging.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 | Documentation | Keywords for VLAN tests
16 | Resource | resources/libraries/robot/shared/default.robot
17 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
18 | Library | resources.libraries.python.L2Util
19 | Library | resources.libraries.python.InterfaceUtil
20 | Library | resources.libraries.python.NodePath
21
22 *** Keywords ***
23
24 | Initialize VLAN sub-interfaces in 3-node circular topology
25 | | [Arguments] | ${DUT1} | ${INT1} | ${DUT2} | ${INT2} | ${SUB_ID}
26 | | ... | ${OUTER_VLAN_ID} | ${INNER_VLAN_ID} | ${TYPE_SUBIF}
27 | | [Documentation] | Create two subinterfaces on DUTs.
28 | | ...
29 | | ... | *Arguments:*
30 | | ... | - DUT1 - Node to add sub-interface.
31 | | ... | - INT1 - Interface name on which create sub-interface.
32 | | ... | - DUT2 - Node to add sub-interface.
33 | | ... | - INT2 - Interface name on which create sub-interface.
34 | | ... | - SUB_ID - ID of the sub-interface to be created.
35 | | ... | - OUTER_VLAN_ID - Outer VLAN ID.
36 | | ... | - INNER_VLAN_ID - Inner VLAN ID.
37 | | ... | - TYPE_SUBIF - Type of sub-interface.
38 | | ...
39 | | ... | _Set testcase variables with name and index of created interfaces:_
40 | | ... | - subif_name_1
41 | | ... | - subif_index_1
42 | | ... | - subif_name_2
43 | | ... | - subif_index_2
44 | | ...
45 | | ${INT1_name}= | Get interface name | ${DUT1} | ${INT1}
46 | | ${subif_name_1} | ${subif_index_1}= | Create subinterface | ${DUT1}
47 | | ... | ${INT1_name} | ${SUB_ID} | ${OUTER_VLAN_ID} | ${INNER_VLAN_ID}
48 | | ... | ${TYPE_SUBIF}
49 | | ${INT2_name}= | Get interface name | ${DUT2} | ${INT2}
50 | | ${subif_name_2} | ${subif_index_2}= | Create subinterface | ${DUT2}
51 | | ... | ${INT2_name} | ${SUB_ID} | ${OUTER_VLAN_ID} | ${INNER_VLAN_ID}
52 | | ... | ${TYPE_SUBIF}
53 | | Set Interface State | ${DUT1} | ${subif_index_1} | up
54 | | Set Interface State | ${DUT2} | ${subif_index_2} | up
55 | | Set Test Variable | ${subif_name_1}
56 | | Set Test Variable | ${subif_index_1}
57 | | Set Test Variable | ${subif_name_2}
58 | | Set Test Variable | ${subif_index_2}
59
60 | Initialize VLAN dot1q sub-interfaces in circular topology
61 | | [Arguments] | ${DUT1} | ${INT1} | ${DUT2}=${None} | ${INT2}=${None}
62 | | ... | ${SUB_ID}=10
63 | | [Documentation] | Create two dot1q subinterfaces on DUTs.
64 | | ...
65 | | ... | *Arguments:*
66 | | ... | - DUT1 - Node to add sub-interface.
67 | | ... | - INT1 - Interface name on which create VLAN sub-interface.
68 | | ... | - DUT2 - Node to add sub-interface.
69 | | ... | - INT2 - Interface name on which create VLAN sub-interface.
70 | | ... | - SUB_ID - ID of the sub-interface to be created.
71 | | ...
72 | | ... | _Set testcase variables with name and index of created interfaces:_
73 | | ... | - subif_name_1
74 | | ... | - subif_index_1
75 | | ... | - subif_name_2
76 | | ... | - subif_index_2
77 | | ...
78 | | ... | *Example:*
79 | | ...
80 | | ... | \| Initialize VLAN dot1q sub-interfaces in circular topology \
81 | | ... | \| ${nodes['DUT1']} \| ${dut1_if2} \| ${nodes['DUT2']} \
82 | | ... | \| ${dut1_if2} \| 10 \|
83 | | ...
84 | | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
85 | | ${INT2_NAME}= | Run Keyword Unless | ${DUT2} == ${None}
86 | | ... | Get interface name | ${DUT2} | ${INT2}
87 | | ${subif_name_1} | ${subif_index_1}= | Create Vlan Subinterface
88 | | ... | ${DUT1} | ${INT1_NAME} | ${SUB_ID}
89 | | ${subif_name_2} | ${subif_index_2}=
90 | | ... | Run Keyword Unless | ${DUT2} == ${None}
91 | | ... | Create Vlan Subinterface | ${DUT2} | ${INT2_NAME} | ${SUB_ID}
92 | | Set Interface State | ${DUT1} | ${subif_index_1} | up
93 | | Run Keyword Unless | ${DUT2} == ${None}
94 | | ... | Set Interface State | ${DUT2} | ${subif_index_2} | up
95 | | Set Test Variable | ${subif_name_1}
96 | | Set Test Variable | ${subif_index_1}
97 | | Run Keyword Unless | ${DUT2} == ${None}
98 | | ... | Set Test Variable | ${subif_name_2}
99 | | Run Keyword Unless | ${DUT2} == ${None}
100 | | ... | Set Test Variable | ${subif_index_2}
101
102 | Configure L2 tag rewrite method on interfaces
103 | | [Arguments] | ${DUT1} | ${SUB_INT1} | ${DUT2}=${None} | ${SUB_INT2}=${None}
104 | | ... | ${TAG_REWRITE_METHOD}=${None}
105 | | [Documentation] | Setup tag rewrite on sub-interfaces on DUTs.
106 | | ...
107 | | ... | *Arguments:*
108 | | ... | - DUT1 - Node to rewrite tags.
109 | | ... | - SUB_INT1 - Interface on which rewrite tags.
110 | | ... | - DUT2 - Node to rewrite tags.
111 | | ... | - SUB_INT2 - Interface on which rewrite tags.
112 | | ... | - TAG_REWRITE_METHOD - Method of tag rewrite.
113 | | ...
114 | | L2 Vlan tag rewrite | ${DUT1} | ${SUB_INT1} | ${TAG_REWRITE_METHOD}
115 | | Run Keyword Unless | ${DUT2} == ${None}
116 | | ... | L2 Vlan tag rewrite | ${DUT2} | ${SUB_INT2} | ${TAG_REWRITE_METHOD}
117
118 | Connect interfaces and VLAN sub-interfaces using L2XC
119 | | [Arguments] | ${DUT1} | ${INT1} | ${SUB_INT1} | ${DUT2}=${None}
120 | | ... | ${INT2}=${None} | ${SUB_INT2}=${None}
121 | | [Documentation] | Add interface and subinterface to bidirectional
122 | | ... | L2-xconnect on DUTs.
123 | | ...
124 | | ... | *Arguments:*
125 | | ... | - DUT1 - Node to add bidirectional cross-connect.
126 | | ... | - INT1 - Interface to add to the cross-connect.
127 | | ... | - SUB_INT1 - Sub-interface to add to the cross-connect.
128 | | ... | - DUT2 - Node to add bidirectional cross-connect.
129 | | ... | - INT2 - Interface to add to the cross-connect.
130 | | ... | - SUB_INT2 - Sub-interface to add to the cross-connect.
131 | | ...
132 | | Configure L2XC | ${DUT1} | ${INT1} | ${SUB_INT1}
133 | | Run Keyword Unless | ${DUT2} == ${None}
134 | | ... | Configure L2XC | ${DUT2} | ${INT2} | ${SUB_INT2}
135
136 | Create vlan sub-interface
137 | | [Documentation] | Create VLAN sub-interface on DUT and set admin status up.
138 | | ...
139 | | ... | *Arguments:*
140 | | ... | - dut_node - Node to add VLAN sub-intreface. Type: dictionary
141 | | ... | - interface - Interface to create VLAN sub-interface. Type: string
142 | | ... | - vlan_id - VLAN ID. Type: integer
143 | | ...
144 | | ... | *Return:*
145 | | ... | - vlan_name - VLAN sub-interface name. Type: string
146 | | ... | - vlan_index - VLAN sub-interface SW index. Type: integer
147 | | ...
148 | | ... | *Example:*
149 | | ...
150 | | ... | \| Create vlan sub-interface \| ${nodes['DUT1']} \| port3 \| 100 \|
151 | | ...
152 | | [Arguments] | ${dut_node} | ${interface} | ${vlan_id}
153 | | [Return] | ${vlan_name} | ${vlan_index}
154 | | ${interface_name}= | Get interface name | ${dut_node} | ${interface}
155 | | ${vlan_name} | ${vlan_index}= | Create Vlan Subinterface
156 | | ... | ${dut_node} | ${interface_name} | ${vlan_id}
157 | | Set Interface State | ${dut_node} | ${vlan_index} | up
158
159 | Create tagged sub-interface
160 | | [Documentation] | Create tagged sub-interface on DUT. Type of tagged \
161 | | ... | sub-intreface depends on type_subif value:
162 | | ... | - one_tag -> VLAN
163 | | ... | - two_tags -> QinQ VLAN
164 | | ... | - two_tags dot1ad - DOT1AD
165 | | ...
166 | | ... | *Arguments:*
167 | | ... | - dut_node - Node to add VLAN sub-intreface. Type: dictionary
168 | | ... | - interface - Interface to create tagged sub-interface. Type: string
169 | | ... | - subif_id - Sub-interface ID. Type: integer
170 | | ... | - outer_vlan_id - VLAN (outer) ID (Optional). Type: integer
171 | | ... | - inner_vlan_id - VLAN inner ID (Optional). Type: integer
172 | | ... | - type_subif - Sub-interface type (Optional). Type: string
173 | | ...
174 | | ... | *Return:*
175 | | ... | - subif_name - Sub-interface name. Type: string
176 | | ... | - subif_index - Sub-interface SW index. Type: integer
177 | | ...
178 | | ... | *Example:*
179 | | ...
180 | | ... | \| Create tagged sub-interface \| ${nodes['DUT1']} \| port1 \| 10 \
181 | | ... | \| outer_vlan_id=100 \| inner_vlan_id=200 \
182 | | ... | \| type_subif=two_tags dot1ad \|
183 | | ...
184 | | [Arguments] | ${dut_node} | ${interface} | ${subif_id}
185 | | ... | ${outer_vlan_id}=${None} | ${inner_vlan_id}=${None}
186 | | ... | ${type_subif}=${None}
187 | | [Return] | ${subif_name} | ${subif_index}
188 | | ${interface_name}= | Get interface name | ${dut_node} | ${interface}
189 | | ${subif_name} | ${subif_index}= | Create Subinterface
190 | | ... | ${dut_node} | ${interface_name} | ${subif_id}
191 | | ... | outer_vlan_id=${outer_vlan_id} | inner_vlan_id=${inner_vlan_id}
192 | | ... | type_subif=${type_subif}
193
194 | Configure L2 tag rewrite method on interface
195 | | [Documentation] | Set L2 tag rewrite on (sub-)interface on DUT
196 | | ...
197 | | ... | *Arguments:*
198 | | ... | - dut_node - Node to set L2 tag rewrite method. Type: dictionary
199 | | ... | - interface - (Sub-)interface name or SW index to set L2 tag rewrite
200 | | ... | method. Type: string or integer
201 | | ... | - tag_rewrite_method - Tag rewrite method. Type: string
202 | | ... | - push_dot1q - True to push tags as Dot1q, False to push tags as
203 | | ... | Dot1ad (Optional). Type: boolean
204 | | ... | - tag1_id - VLAN tag1 ID (Optional). Type: integer
205 | | ... | - tag2_id - VLAN tag2 ID (Optional). Type: integer
206 | | ...
207 | | ... | *Return:*
208 | | ...
209 | | ... | - No value returned
210 | | ...
211 | | ... | *Example:*
212 | | ...
213 | | ... | \| Configure L2 tag rewrite method on interface \| ${nodes['DUT1']} \
214 | | ... | \| 9 \| pop-1 \|
215 | | ... | \| Configure L2 tag rewrite method on interface \| ${nodes['DUT2']} \
216 | | ... | \| 10 \| translate-1-2 \| push_dot1q=${False} \| tag1_id=10 \
217 | | ... | \| tag1_id=20 \|
218 | | ...
219 | | [Arguments] | ${dut_node} | ${interface} | ${tag_rewrite_method}
220 | | ... | ${push_dot1q}=${True} | ${tag1_id}=${None} | ${tag2_id}=${None}
221 | | ${result}= | Evaluate | isinstance($interface, int)
222 | | ${interface_name}= | Run Keyword If | ${result}
223 | | ... | Set Variable | ${interface}
224 | | ... | ELSE | Get interface name | ${dut_node} | ${interface}
225 | | L2 Vlan Tag Rewrite | ${dut_node} | ${interface_name}
226 | | ... | ${tag_rewrite_method} | push_dot1q=${push_dot1q} | tag1_id=${tag1_id}
227 | | ... | tag2_id=${tag2_id}