Find PDR using binary search
[csit.git] / resources / libraries / robot / honeycomb / 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.honeycomb.HcAPIKwBridgeDomain.BridgeDomainKeywords
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ...     | WITH NAME | InterfaceAPI
19
20 *** Keywords ***
21 | Honeycomb creates first L2 bridge domain
22 | | [Documentation] | Uses Honeycomb API to create a bridge domain on the \
23 | | ... | VPP node. Any other bridge domains will be removed in the process.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - bd_name - name of the created bridge domain. Type: string
28 | | ... | - settings - settings for the created bridge domain. Type: dictionary
29 | | ...
30 | | ... | *Example:*
31 | | ...
32 | | ... | \| Honeycomb creates first L2 bridge domain \| ${nodes['DUT1']} \
33 | | ... | \| bd-04 \| ${{flood:True, learn:False}} \|
34 | | [Arguments] | ${node} | ${bd_name} | ${settings}
35 | | Add first BD | ${node} | ${bd_name} | &{settings}
36
37 | Honeycomb creates L2 bridge domain
38 | | [Documentation] | Uses Honeycomb API to create a bridge domain on the \
39 | | ... | VPP node.
40 | | ...
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
43 | | ... | - bd_name - name of the created bridge domain. Type: string
44 | | ... | - settings - settings for the created bridge domain. Type: dictionary
45 | | ...
46 | | ... | *Example:*
47 | | ...
48 | | ... | \| Honeycomb creates L2 bridge domain \| ${nodes['DUT1']} \
49 | | ... | \| bd-04 \| ${{flood:True, learn:False}} \|
50 | | [Arguments] | ${node} | ${bd_name} | ${settings}
51 | | Add BD | ${node} | ${bd_name} | &{settings}
52
53 | Bridge domain configuration from Honeycomb should be
54 | | [Documentation] | Uses Honeycomb API to verify bridge domain settings\
55 | | ... | against provided values.
56 | | ...
57 | | ... | *Arguments:*
58 | | ... | - node - information about a DUT node. Type: dictionary
59 | | ... | - bd_name - name of the bridge domain. Type: string
60 | | ... | - settings - expected settings for the bridge domain. Type: dictionary
61 | | ...
62 | | ... | *Example:*
63 | | ...
64 | | ... | \| Bridge domain configuration from Honeycomb should be \
65 | | ... | \| ${nodes['DUT1']} \| bd-04 \| ${{flood:True,learn:False}} \|
66 | | [Arguments] | ${node} | ${bd_name} | ${settings}
67 | | ${api_data}= | Get bd cfg data | ${node} | ${bd_name}
68 | | :FOR | ${key} | IN | @{settings.keys()}
69 | | | Should be equal | ${settings['${key}']} | ${api_data['${key}']}
70
71 | Bridge domain configuration from VAT should be
72 | | [Documentation] | Uses VAT to verify bridge domain settings\
73 | | ... | against provided values.
74 | | ...
75 | | ... | *Arguments:*
76 | | ... | - node - information about a DUT node. Type: dictionary
77 | | ... | - bd_name - name of the bridge domain. Type: string
78 | | ... | - settings - expected settings for the bridge domain. Type: dictionary
79 | | ...
80 | | ... | *Example:*
81 | | ...
82 | | ... | \| Bridge domain configuration from VAT should be \
83 | | ... | \| ${nodes['DUT1']} \| bd-04 \| ${{flood:True,learn:False}} \|
84 | | [Arguments] | ${node} | ${bd_index} | ${settings}
85 | | ${vat_data}= | VPP get bridge domain data | ${node}
86 | | ${vat_data}= | Set Variable | ${vat_data[${bd_index}]}
87 | | :FOR | ${key} | IN | @{settings.keys()}
88 | | | Run keyword if | $key in $vat_data.keys()
89 | | | ... | Should be equal | ${settings['${key}']} | ${vat_data['${key}']}
90
91 | Honeycomb adds interfaces to bridge domain
92 | | [Documentation] | Uses Honeycomb API to assign interfaces to a bridge\
93 | | ... | domain.
94 | | ...
95 | | ... | *Arguments:*
96 | | ... | - node - information about a DUT node. Type: dictionary
97 | | ... | - interface1, interface2 - names of interfaces to assign to bridge\
98 | | ... | domain. Type: string
99 | | ... | - bd_name - name of the bridge domain. Type: string
100 | | ... | - settings - bridge domain specific interface settings.\
101 | | ... | Type: dictionary
102 | | ...
103 | | ... | *Example:*
104 | | ...
105 | | ... | \| Honeycomb adds interfaces to bridge domain \| ${nodes['DUT1']} \
106 | | ... | \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \| bd-04 \
107 | | ... | \| ${{split_horizon_group:2, bvi:False}} \|
108 | | [Arguments] | ${node} | ${interface1} | ${interface2} | ${bd_name}
109 | | ... | ${settings}
110 | | interfaceAPI.Add bridge domain to interface
111 | | ... | ${node} | ${interface1} | ${bd_name} | &{settings}
112 | | interfaceAPI.Add bridge domain to interface
113 | | ... | ${node} | ${interface2} | ${bd_name} | &{settings}
114
115 | Honeycomb should show interfaces assigned to bridge domain
116 | | [Documentation] | Uses Honeycomb API to verify interface assignment to\
117 | | ... | bridge domain.
118 | | ...
119 | | ... | *Arguments:*
120 | | ... | - node - information about a DUT node. Type: dictionary
121 | | ... | - interface1, interface2 - names of interfaces to assign to bridge\
122 | | ... | domain. Type: string
123 | | ... | - bd_name - name of the bridge domain. Type: string
124 | | ... | - settings - bridge domain specific interface settings.\
125 | | ... | Type: dictionary
126 | | ...
127 | | ... | *Example:*
128 | | ...
129 | | ... | \| Honeycomb should show interfaces assigned to bridge domain \
130 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \
131 | | ... | \| bd-04 \| ${{split_horizon_group:2, bvi:False}} \|
132 | | [Arguments] | ${node} | ${interface1} | ${interface2} | ${bd_name}
133 | | ... | ${settings}
134 | | ${if1_data}= | interfaceAPI.Get interface oper data
135 | | ... | ${node} | ${interface1}
136 | | ${if2_data}= | interfaceAPI.Get interface oper data
137 | | ... | ${node} | ${interface2}
138 | | Should be equal | ${if1_data['v3po:l2']['bridge-domain']}
139 | | ... | ${if1_data['v3po:l2']['bridge-domain']} | ${bd_name}
140 | | :FOR | ${key} | IN | @{settings.keys()}
141 | | | Should be equal | ${if1_data['v3po:l2']['${key}']}
142 | | | ... | ${if2_data['v3po:l2']['${key}']} | ${settings['${key}']}
143
144 | VAT should show interfaces assigned to bridge domain
145 | | [Documentation] | Uses VAT to verify interface assignment to\
146 | | ... | bridge domain.
147 | | ...
148 | | ... | *Arguments:*
149 | | ... | - node - information about a DUT node. Type: dictionary
150 | | ... | - index - index of bridge domains on VPP node. Starts from 0,\
151 | | ... | new BDs reuse numbers after a bridge domain is removed. Type: int
152 | | ... | - interface1, interface2 - names of interfaces to assign to bridge\
153 | | ... | domain. Type: string
154 | | ... | - settings - bridge domain specific interface settings.\
155 | | ... | Type: dictionary
156 | | ...
157 | | ... | *Example:*
158 | | ...
159 | | ... | \| VAT should show interfaces assigned to bridge domain \
160 | | ... | \| ${nodes['DUT1']} \| ${4} \| GigabitEthernet0/8/0 \
161 | | ... | \| GigabitEthernet0/9/0 \| ${{split_horizon_group:2, bvi:False}} \|
162 | | [Arguments] | ${node} | ${index} | ${interface1} | ${interface2}
163 | | ... | ${settings}
164 | | ${if1_index}= | Get interface sw index | ${node} | ${interface1}
165 | | ${if2_index}= | Get interface sw index | ${node} | ${interface2}
166 | | ${if_indices}= | Create list | ${if1_index} | ${if2_index}
167 | | ${bd_data}= | VPP get bridge domain data | ${node}
168 | | ${bd_interfaces}= | Set Variable | ${bd_data[${index}]['sw_if']}
169 | | @{bd_interfaces}= | Create List | ${bd_interfaces[0]} | ${bd_interfaces[1]}
170 | | :FOR | ${interface} | IN | @{bd_interfaces}
171 | | | Should contain | ${if_indices} | ${interface['sw_if_index']}
172 | | | Should be equal | ${interface['shg']} | ${settings['split_horizon_group']}
173
174 | Honeycomb removes all bridge domains
175 | | [Documentation] | Uses Honeycomb API to remove all bridge domains from the \
176 | | ... | VPP node.
177 | | ...
178 | | ... | *Arguments:*
179 | | ... | - node - information about a DUT node. Type: dictionary
180 | | ...
181 | | ... | *Example:*
182 | | ...
183 | | ... | \| Honeycomb removes all bridge domains \| ${nodes['DUT1']} \|
184 | | [Arguments] | ${node}
185 | | Remove all bds | ${node}
186
187 | Honeycomb should show no bridge domains
188 | | [Documentation] | Uses Honeycomb API to verify the removal of all\
189 | | ... | bridge domains.
190 | | ...
191 | | ... | *Arguments:*
192 | | ... | - node - information about a DUT node. Type: dictionary
193 | | ...
194 | | ... | *Example:*
195 | | ...
196 | | ... | \| Honeycomb should show no bridge domains \| ${nodes['DUT1']} \|
197 | | [Arguments] | ${node}
198 | | ${bd_data} | Get all BDs cfg data | ${node}
199 | | Should be empty | ${bd_data}
200
201 | VAT should show no bridge domains
202 | | [Documentation] | Uses VAT to verify the removal of all bridge domains.
203 | | ...
204 | | ... | *Arguments:*
205 | | ... | - node - information about a DUT node. Type: dictionary
206 | | ...
207 | | ... | *Example:*
208 | | ...
209 | | ... | \| VAT should show no bridge domains \| ${nodes['DUT1']} \|
210 | | [Arguments] | ${node}
211 | | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
212 | | ... | VPP get bridge domain data | ${node}