273384c5cc814a445c3cc896d438d2ae9a1eea9f
[csit.git] / resources / libraries / robot / l2 / tagging.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.L2Util
16 | Library | resources.libraries.python.InterfaceUtil
17 | Library | resources.libraries.python.NodePath
18 |
19 | Documentation | Keywords for VLAN tests
20
21 *** Keywords ***
22 | Initialize VLAN sub-interfaces in 3-node circular topology
23 | | [Arguments] | ${DUT1} | ${INT1} | ${DUT2} | ${INT2} | ${SUB_ID}
24 | | ... | ${OUTER_VLAN_ID} | ${INNER_VLAN_ID} | ${TYPE_SUBIF}
25 | | [Documentation] | Create two subinterfaces on DUTs.
26 | |
27 | | ... | *Arguments:*
28 | | ... | - DUT1 - Node to add sub-interface.
29 | | ... | - INT1 - Interface key on which create sub-interface.
30 | | ... | - DUT2 - Node to add sub-interface.
31 | | ... | - INT2 - Interface key on which create sub-interface.
32 | | ... | - SUB_ID - ID of the sub-interface to be created.
33 | | ... | - OUTER_VLAN_ID - Outer VLAN ID.
34 | | ... | - INNER_VLAN_ID - Inner VLAN ID.
35 | | ... | - TYPE_SUBIF - Type of sub-interface.
36 | |
37 | | ... | _Set testcase variables with name and index of created interfaces:_
38 | | ... | - subif_name_1
39 | | ... | - subif_index_1
40 | | ... | - subif_name_2
41 | | ... | - subif_index_2
42 | |
43 | | Set Interface State | ${DUT1} | ${INT1} | up
44 | | Set Interface State | ${DUT2} | ${INT2} | up
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 key on which create VLAN sub-interface.
68 | | ... | - DUT2 - Node to add sub-interface.
69 | | ... | - INT2 - Interface key 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 | | Set Interface State | ${DUT1} | ${INT1} | up
85 | | Run Keyword Unless | ${DUT2} == ${None}
86 | | ... | Set Interface State | ${DUT2} | ${INT2} | up
87 | | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
88 | | ${INT2_NAME}= | Run Keyword Unless | ${DUT2} == ${None}
89 | | ... | Get interface name | ${DUT2} | ${INT2}
90 | | ${subif_name_1} | ${subif_index_1}= | Create Vlan Subinterface
91 | | ... | ${DUT1} | ${INT1_NAME} | ${SUB_ID}
92 | | ${subif_name_2} | ${subif_index_2}=
93 | | ... | Run Keyword Unless | ${DUT2} == ${None}
94 | | ... | Create Vlan Subinterface | ${DUT2} | ${INT2_NAME} | ${SUB_ID}
95 | | Set Interface State | ${DUT1} | ${subif_index_1} | up
96 | | Run Keyword Unless | ${DUT2} == ${None}
97 | | ... | Set Interface State | ${DUT2} | ${subif_index_2} | up
98 | | Set Test Variable | ${subif_name_1}
99 | | Set Test Variable | ${subif_index_1}
100 | | Run Keyword Unless | ${DUT2} == ${None}
101 | | ... | Set Test Variable | ${subif_name_2}
102 | | Run Keyword Unless | ${DUT2} == ${None}
103 | | ... | Set Test Variable | ${subif_index_2}
104
105 | Configure L2 tag rewrite method on interfaces
106 | | [Arguments] | ${DUT1} | ${SUB_INT1} | ${DUT2}=${None} | ${SUB_INT2}=${None}
107 | | ... | ${TAG_REWRITE_METHOD}=${None}
108 | | [Documentation] | Setup tag rewrite on sub-interfaces on DUTs.
109 | |
110 | | ... | *Arguments:*
111 | | ... | - DUT1 - Node to rewrite tags.
112 | | ... | - SUB_INT1 - Interface on which rewrite tags.
113 | | ... | - DUT2 - Node to rewrite tags.
114 | | ... | - SUB_INT2 - Interface on which rewrite tags.
115 | | ... | - TAG_REWRITE_METHOD - Method of tag rewrite.
116 | |
117 | | L2 Vlan tag rewrite | ${DUT1} | ${SUB_INT1} | ${TAG_REWRITE_METHOD}
118 | | Run Keyword Unless | ${DUT2} == ${None}
119 | | ... | L2 Vlan tag rewrite | ${DUT2} | ${SUB_INT2} | ${TAG_REWRITE_METHOD}
120
121 | Configure L2 tag rewrite method on interface
122 | | [Documentation] | Set L2 tag rewrite on (sub-)interface on DUT
123 | |
124 | | ... | *Arguments:*
125 | | ... | - dut_node - Node to set L2 tag rewrite method. Type: dictionary
126 | | ... | - interface - (Sub-)interface name or SW index to set L2 tag rewrite
127 | | ... | method. Type: string or integer
128 | | ... | - tag_rewrite_method - Tag rewrite method. Type: string
129 | | ... | - push_dot1q - True to push tags as Dot1q, False to push tags as
130 | | ... | Dot1ad (Optional). Type: boolean
131 | | ... | - tag1_id - VLAN tag1 ID (Optional). Type: integer
132 | | ... | - tag2_id - VLAN tag2 ID (Optional). Type: integer
133 | |
134 | | ... | *Return:*
135 | |
136 | | ... | - No value returned
137 | |
138 | | ... | *Example:*
139 | |
140 | | ... | \| Configure L2 tag rewrite method on interface \| ${nodes['DUT1']} \
141 | | ... | \| 9 \| pop-1 \|
142 | | ... | \| Configure L2 tag rewrite method on interface \| ${nodes['DUT2']} \
143 | | ... | \| 10 \| translate-1-2 \| push_dot1q=${False} \| tag1_id=10 \
144 | | ... | \| tag1_id=20 \|
145 | |
146 | | [Arguments] | ${dut_node} | ${interface} | ${tag_rewrite_method}
147 | | ... | ${push_dot1q}=${True} | ${tag1_id}=${None} | ${tag2_id}=${None}
148 | |
149 | | ${result}= | Evaluate | isinstance($interface, int)
150 | | ${interface_name}= | Run Keyword If | ${result}
151 | | ... | Set Variable | ${interface}
152 | | ... | ELSE | Get interface name | ${dut_node} | ${interface}
153 | | L2 Vlan Tag Rewrite | ${dut_node} | ${interface_name}
154 | | ... | ${tag_rewrite_method} | push_dot1q=${push_dot1q} | tag1_id=${tag1_id}
155 | | ... | tag2_id=${tag2_id}