Bridge domain tests and user keywords refactor.
[csit.git] / resources / libraries / robot / bridge_domain.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 | Library | resources.libraries.python.L2Util
16 | Library | resources.libraries.python.InterfaceUtil
17 | Library | resources.libraries.python.NodePath
18 | Resource | resources/libraries/robot/interfaces.robot
19 | Resource | resources/libraries/robot/l2_traffic.robot
20
21 *** Keywords ***
22 | Path for 2-node BD testing is set
23 | | [Documentation] | Compute path for bridge domain testing on two given nodes
24 | | ...             | and set corresponding test case variables.
25 | | ...
26 | | ... | *Arguments:*
27 | | ... | - ${tg_node} - TG node. Type: dictionary
28 | | ... | - ${dut_node} - DUT node. Type: dictionary
29 | | ...
30 | | ... | *Return:*
31 | | ... | - No value returned
32 | | ...
33 | | ... | _NOTE:_ This KW sets following test case variables:
34 | | ... | - ${tg_node} - TG node.
35 | | ... | - ${tg_to_dut_if1} - 1st TG interface towards DUT.
36 | | ... | - ${tg_to_dut_if2} - 2nd TG interface towards DUT.
37 | | ... | - ${dut_node} - DUT node.
38 | | ... | - ${dut_to_tg_if1} - 1st DUT interface towards TG.
39 | | ... | - ${dut_to_tg_if2} - 2nd DUT interface towards TG.
40 | | ...
41 | | ... | *Example:*
42 | | ...
43 | | ... | \| Given Path for 2-node BD testing is set \| ${nodes['TG']} \
44 | | ... | \| ${nodes['DUT1']} \|
45 | | [Arguments] | ${tg_node} | ${dut_node}
46 | | Append Nodes | ${tg_node} | ${dut_node} | ${tg_node}
47 | | Compute Path | always_same_link=${FALSE}
48 | | ${tg_to_dut_if1} | ${tmp}= | First Interface
49 | | ${tg_to_dut_if2} | ${tmp}= | Last Interface
50 | | ${dut_to_tg_if1} | ${tmp}= | First Ingress Interface
51 | | ${dut_to_tg_if2} | ${tmp}= | Last Egress Interface
52 | | Set Test Variable | ${tg_to_dut_if1}
53 | | Set Test Variable | ${tg_to_dut_if2}
54 | | Set Test Variable | ${dut_to_tg_if1}
55 | | Set Test Variable | ${dut_to_tg_if2}
56 | | Set Test Variable | ${tg_node}
57 | | Set Test Variable | ${dut_node}
58
59 | Path for 3-node BD testing is set
60 | | [Documentation] | Compute path for bridge domain testing on three given
61 | | ...             | nodes and set corresponding test case variables.
62 | | ...
63 | | ... | *Arguments:*
64 | | ... | - ${tg_node} - TG node. Type: dictionary
65 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
66 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
67 | | ...
68 | | ... | *Return:*
69 | | ... | - No value returned
70 | | ... |
71 | | ... | _NOTE:_ This KW sets following test case variables:
72 | | ... | - ${tg_node} - TG node.
73 | | ... | - ${tg_to_dut1} - TG interface towards DUT1.
74 | | ... | - ${tg_to_dut2} - TG interface towards DUT2.
75 | | ... | - ${dut1_node} - DUT1 node.
76 | | ... | - ${dut1_to_tg} - DUT1 interface towards TG.
77 | | ... | - ${dut1_to_dut2} - DUT1 interface towards DUT2.
78 | | ... | - ${dut2_node} - DUT2 node.
79 | | ... | - ${dut2_to_tg} - DUT2 interface towards TG.
80 | | ... | - ${dut2_to_dut1} - DUT2 interface towards DUT1.
81 | | ...
82 | | ... | *Example:*
83 | | ...
84 | | ... | \| Given Path for 3-node BD testing is set \| ${nodes['TG']} \
85 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \|
86 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node}
87 | | Append Nodes | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg_node}
88 | | Compute Path
89 | | ${tg_to_dut1} | ${tmp}= | Next Interface
90 | | ${dut1_to_tg} | ${tmp}= | Next Interface
91 | | ${dut1_to_dut2} | ${tmp}= | Next Interface
92 | | ${dut2_to_dut1} | ${tmp}= | Next Interface
93 | | ${dut2_to_tg} | ${tmp}= | Next Interface
94 | | ${tg_to_dut2} | ${tmp}= | Next Interface
95 | | Set Test Variable | ${tg_to_dut1}
96 | | Set Test Variable | ${dut1_to_tg}
97 | | Set Test Variable | ${tg_to_dut2}
98 | | Set Test Variable | ${dut2_to_tg}
99 | | Set Test Variable | ${dut1_to_dut2}
100 | | Set Test Variable | ${dut2_to_dut1}
101 | | Set Test Variable | ${tg_node}
102 | | Set Test Variable | ${dut1_node}
103 | | Set Test Variable | ${dut2_node}
104
105 | Bridge domain on DUT node is created
106 | | [Documentation] | Create bridge domain on given VPP node with defined
107 | | ...             | learning status.
108 | | ...
109 | | ... | *Arguments:*
110 | | ... | - ${dut_node} - DUT node. Type: dictionary
111 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
112 | | ... | - ${learn} - Enable/disable MAC learn. Type: boolean, \
113 | | ... | default value: ${TRUE}
114 | | ...
115 | | ... | *Return:*
116 | | ... | - No value returned
117 | | ...
118 | | ... | *Example:*
119 | | ...
120 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 2 \|
121 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 5 \
122 | | ... | \| learn=${FALSE} \|
123 | | [Arguments] | ${dut_node} | ${bd_id} | ${learn}=${TRUE}
124 | | ${learn} = | Set Variable If | ${learn} == ${TRUE} | ${1} | ${0}
125 | | Create L2 BD | ${dut_node} | ${bd_id} | learn=${learn}
126
127 | Interface is added to bridge domain
128 | | [Documentation] | Set given interface admin state to up and add this
129 | | ...             | interface to required L2 bridge domain on defined
130 | | ...             | VPP node.
131 | | ...
132 | | ... | *Arguments:*
133 | | ... | - ${dut_node} - DUT node. Type: dictionary
134 | | ... | - ${dut_if} - DUT node interface name. Type: string
135 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
136 | | ...
137 | | ... | *Return:*
138 | | ... | - No value returned
139 | | ...
140 | | ... | *Example:*
141 | | ...
142 | | ... | \| Interface is added to bridge domain \| ${nodes['DUT2']} \
143 | | ... | \| GigabitEthernet0/8/0 \| 3 \|
144 | | [Arguments] | ${dut_node} | ${dut_if} | ${bd_id}
145 | | Set Interface State | ${dut_node} | ${dut_if} | up
146 | | Add Interface To L2 BD | ${dut_node} | ${dut_if} | ${bd_id}
147
148 | Destination port is added to L2FIB on DUT node
149 | | [Documentation] | Create a static L2FIB entry for required destination port
150 | | ...             | on defined interface and bridge domain ID
151 | | ...             | of the given VPP node.
152 | | ...
153 | | ... | *Arguments:*
154 | | ... | - ${dest_node} - Destination node. Type: dictionary
155 | | ... | - ${dest_node_if} - Destination node interface name. Type: string
156 | | ... | - ${vpp_node} - DUT node to add L2FIB entry on. Type: dictionary
157 | | ... | - ${vpp_node_if} - DUT node interface name. Type: string
158 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
159 | | ...
160 | | ... | *Return:*
161 | | ... | - No value returned
162 | | ...
163 | | ... | *Example:*
164 | | ...
165 | | ... | \| Destination port is added to L2FIB on DUT node \| ${nodes['TG']} \
166 | | ... | \| eth1 \| ${nodes['DUT2']} \| GigabitEthernet0/8/0 \| 3 \|
167 | | [Arguments] | ${dest_node} | ${dest_node_if} | ${vpp_node}
168 | | ...         | ${vpp_node_if} | ${bd_id}
169 | | ${mac}= | Get Interface Mac | ${dest_node} | ${dest_node_if}
170 | | Vpp Add L2fib Entry | ${vpp_node} | ${mac} | ${vpp_node_if} | ${bd_id}