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