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