2 Documentation Library containing Keywords used for SXP testing
4 Library RequestsLibrary
8 Resource KarafKeywords.robot
10 Variables ../variables/Variables.py
13 ${REST_CONTEXT} /restconf/operations/sxp-controller
17 [Arguments] ${node} ${password}=password ${version}=version4 ${port}=64999 ${session}=session
18 [Documentation] Add node via RPC to ODL
19 ${DATA} Add Node Xml ${node} ${port} ${password} ${version}
20 ${resp} Post Request ${session} ${REST_CONTEXT}:add-node data=${DATA} headers=${HEADERS_XML}
21 Should be Equal As Strings ${resp.status_code} 200
24 [Arguments] ${node} ${session}=session
25 [Documentation] Delete connection via RPC from node
26 ${DATA} Delete Node Xml ${node}
27 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-node data=${DATA} headers=${HEADERS_XML}
28 Should be Equal As Strings ${resp.status_code} 200
31 [Arguments] ${version} ${mode} ${ip} ${port} ${node}=127.0.0.1 ${password}=none
32 ... ${session}=session ${domain}=global
33 [Documentation] Add connection via RPC to node
34 ${DATA} Add Connection Xml ${version} ${mode} ${ip} ${port} ${node}
35 ... ${password} ${domain}
36 ${resp} Post Request ${session} ${REST_CONTEXT}:add-connection data=${DATA} headers=${HEADERS_XML}
37 Should be Equal As Strings ${resp.status_code} 200
40 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
41 [Documentation] Gets all connections via RPC from node
42 ${DATA} Get Connections From Node Xml ${node} ${domain}
43 ${resp} Post Request ${session} ${REST_CONTEXT}:get-connections data=${DATA} headers=${HEADERS_XML}
44 Should be Equal As Strings ${resp.status_code} 200
45 [Return] ${resp.content}
48 [Arguments] ${ip} ${port} ${node}=127.0.0.1 ${session}=session ${domain}=global
49 [Documentation] Delete connection via RPC from node
50 ${DATA} Delete Connections Xml ${ip} ${port} ${node} ${domain}
51 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-connection data=${DATA} headers=${HEADERS_XML}
52 Should be Equal As Strings ${resp.status_code} 200
55 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
56 [Documentation] Delete all connections via RPC from node
57 ${resp} Get Connections ${node} ${session} ${domain}
58 @{connections} Parse Connections ${resp}
59 : FOR ${connection} IN @{connections}
60 \ delete connections ${connection['peer-address']} ${connection['tcp-port']} ${node} ${session}
63 [Arguments] ${version} ${mode} ${ip} ${port}=64999 ${node}=127.0.0.1 ${state}=on
64 ... ${session}=session ${domain}=global
65 [Documentation] Verify that connection is ON
66 ${resp} Get Connections ${node} ${session} ${domain}
67 Should Contain Connection ${resp} ${ip} ${port} ${mode} ${version} ${state}
70 [Arguments] ${sgt} ${prefix} ${node}=127.0.0.1 ${domain}=global ${session}=session
71 [Documentation] Add binding via RPC to Master DB of node
72 ${DATA} Add Entry Xml ${sgt} ${prefix} ${node} ${domain}
73 ${resp} Post Request ${session} ${REST_CONTEXT}:add-entry data=${DATA} headers=${HEADERS_XML}
74 Should be Equal As Strings ${resp.status_code} 200
77 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
78 [Documentation] Gets all binding via RPC from Master DB of node
79 ${DATA} Get Bindings From Node Xml ${node} all ${domain}
80 ${resp} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Post Request ${session} ${REST_CONTEXT}:get-node-bindings data=${DATA}
81 ... headers=${HEADERS_XML}
82 ... ELSE Get Request ${session} /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/master-database/ headers=${HEADERS_XML}
83 Should be Equal As Strings ${resp.status_code} 200
84 [Return] ${resp.content}
87 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
88 [Documentation] Delete all bindings via RPC from Master DB of node
89 ${resp} Get Bindings ${node} ${session} ${domain}
90 @{bindings} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Parse Bindings ${resp}
91 ... ELSE Parse Prefix Groups ${resp} local
92 : FOR ${binding} IN @{bindings}
93 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Clean Binding ${binding['sgt']} ${binding['ip-prefix']} ${node}
94 \ ... ${session} ${domain}
95 \ ... ELSE Clean Binding ${binding} ${binding['binding']} ${node}
96 \ ... ${session} ${domain}
99 [Arguments] ${sgt} ${prefixes} ${node} ${session} ${domain}=global
100 [Documentation] Used for nester FOR loop
101 : FOR ${prefix} IN @{prefixes}
102 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Delete Binding ${sgt} ${prefix} ${node}
103 \ ... ${domain} ${session}
104 \ ... ELSE Delete Binding ${sgt['sgt']} ${prefix['ip-prefix']} ${node}
105 \ ... ${domain} ${session}
108 [Arguments] ${sgtOld} ${prefixOld} ${sgtNew} ${prefixNew} ${node}=127.0.0.1 ${session}=session
110 [Documentation] Updates value of binding via RPC in Master DB of node
111 ${DATA} Update Binding Xml ${sgtOld} ${prefixOld} ${sgtNew} ${prefixNew} ${node}
113 ${resp} Post Request ${session} ${REST_CONTEXT}:update-entry data=${DATA} headers=${HEADERS_XML}
114 Should be Equal As Strings ${resp.status_code} 200
117 [Arguments] ${sgt} ${prefix} ${node}=127.0.0.1 ${domain}=global ${session}=session
118 [Documentation] Delete binding via RPC from Master DB of node
119 ${DATA} Delete Binding Xml ${sgt} ${prefix} ${node} ${domain}
120 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-entry data=${DATA} headers=${HEADERS_XML}
121 Should be Equal As Strings ${resp.status_code} 200
124 [Arguments] ${name} ${peers}= ${node}=127.0.0.1 ${session}=session
125 [Documentation] Adds new PeerGroup via RPC to Node
126 ${DATA} Add Peer Group Xml ${name} ${peers} ${node}
127 ${resp} Post Request ${session} ${REST_CONTEXT}:add-peer-group data=${DATA} headers=${HEADERS_XML}
128 Should be Equal As Strings ${resp.status_code} 200
131 [Arguments] ${name} ${node}=127.0.0.1 ${session}=session
132 [Documentation] Delete PeerGroup via RPC from Node
133 ${DATA} Delete Peer Group Xml ${name} ${node}
134 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-peer-group data=${DATA} headers=${HEADERS_XML}
135 Should be Equal As Strings ${resp.status_code} 200
138 [Arguments] ${node}=127.0.0.1 ${session}=session
139 [Documentation] Gets all PeerGroups via RPC from node
140 ${DATA} Get Peer Groups From Node Xml ${node}
141 ${resp} Post Request ${session} ${REST_CONTEXT}:get-peer-groups data=${DATA} headers=${HEADERS_XML}
142 Should be Equal As Strings ${resp.status_code} 200
143 [Return] ${resp.content}
146 [Arguments] ${node}=127.0.0.1 ${session}=session
147 [Documentation] Delete all PeerGroups via RPC from node
148 ${resp} Get Peer Groups ${node} ${session}
149 @{prefixes} Parse Peer Groups ${resp}
150 : FOR ${group} IN @{prefixes}
151 \ Delete Peer Group ${group['name']} ${node} ${session}
154 [Arguments] ${name} ${type} ${entries} ${node}=127.0.0.1 ${session}=session
155 [Documentation] Add Filter via RPC from Node
156 ${DATA} Add Filter Xml ${name} ${type} ${entries} ${node}
157 ${resp} Post Request ${session} ${REST_CONTEXT}:add-filter data=${DATA} headers=${HEADERS_XML}
158 Should be Equal As Strings ${resp.status_code} 200
161 [Arguments] ${name} ${domains} ${entries} ${node}=127.0.0.1 ${filter_name}=base-domain-filter ${session}=session
162 [Documentation] Add Domain Filter via RPC from Node
163 ${DATA} Add Domain Filter Xml ${name} ${domains} ${entries} ${node} ${filter_name}
164 ${resp} Post Request ${session} ${REST_CONTEXT}:add-domain-filter data=${DATA} headers=${HEADERS_XML}
165 Should be Equal As Strings ${resp.status_code} 200
168 [Arguments] ${name} ${type} ${node}=127.0.0.1 ${session}=session
169 [Documentation] Delete Filter via RPC from Node
170 ${DATA} Delete Filter Xml ${name} ${type} ${node}
171 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-filter data=${DATA} headers=${HEADERS_XML}
172 Should be Equal As Strings ${resp.status_code} 200
175 [Arguments] ${name} ${node}=127.0.0.1 ${filter_name}=base-domain-filter ${session}=session
176 [Documentation] Delete Filter via RPC from Node
177 ${DATA} Delete Domain Filter Xml ${name} ${node} ${filter_name}
178 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-domain-filter data=${DATA} headers=${HEADERS_XML}
179 Should be Equal As Strings ${resp.status_code} 200
181 Should Contain Binding
182 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
183 [Documentation] Tests if data contains specified binding
184 ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
185 ... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
187 Should Be True ${out} Doesn't have ${sgt} ${prefix}
189 Should Not Contain Binding
190 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
191 [Documentation] Tests if data doesn't contains specified binding
192 ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
193 ... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
195 Should Not Be True ${out} Should't have ${sgt} ${prefix}
197 Should Contain Connection
198 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
199 [Documentation] Test if data contains specified connection
200 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
202 Should Be True ${out} Doesn't have ${ip}:${port} ${mode} ${version}
204 Should Not Contain Connection
205 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
206 [Documentation] Test if data doesn't contains specified connection
207 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
209 Should Not Be True ${out} Shouldn't have ${ip}:${port} ${mode} ${version}
211 Setup Topology Complex
212 [Arguments] ${version}=version4 ${PASSWORD}=none
213 : FOR ${node} IN RANGE 2 6
214 \ Add Connection ${version} both 127.0.0.1 64999 127.0.0.${node}
216 \ Add Connection ${version} both 127.0.0.${node} 64999 127.0.0.1
218 \ Wait Until Keyword Succeeds 15 1 Verify Connection ${version} both
219 \ ... 127.0.0.${node}
220 \ Add Binding ${node}0 10.10.10.${node}0/32 127.0.0.${node}
221 \ Add Binding ${node}0 10.10.${node}0.0/24 127.0.0.${node}
222 \ Add Binding ${node}0 10.${node}0.0.0/16 127.0.0.${node}
223 \ Add Binding ${node}0 ${node}0.0.0.0/8 127.0.0.${node}
224 Add Binding 10 10.10.10.10/32 127.0.0.1
225 Add Binding 10 10.10.10.0/24 127.0.0.1
226 Add Binding 10 10.10.0.0/16 127.0.0.1
227 Add Binding 10 10.0.0.0/8 127.0.0.1
229 Verify Snapshot Was Pushed
230 [Arguments] ${snapshot_string}=22-sxp-controller-one-node.xml
231 [Documentation] Will succeed if the ${snapshot_string} is found in the karaf logs
232 ${output} Run Command On Controller ${ODL_SYSTEM_IP} cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log* | grep -c 'Successfully pushed configuration snapshot.*${snapshot_string}'
233 Should Not Be Equal As Strings ${output} 0
236 [Documentation] Create session to Controller
237 Verify Feature Is Installed odl-sxp-controller
238 Wait Until Keyword Succeeds 20 10 Verify Snapshot Was Pushed
239 Create Session session url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
240 ${resp} RequestsLibrary.Get Request session ${MODULES_API}
241 Should Be Equal As Strings ${resp.status_code} 200
242 Should Contain ${resp.content} ietf-restconf
245 [Documentation] Destroy created sessions
249 [Arguments] ${domain_name} ${node}=127.0.0.1 ${session}=session
250 [Documentation] Add Domain via RPC
251 ${DATA} Add Domain Xml ${node} ${domain_name}
252 ${resp} Post Request ${session} ${REST_CONTEXT}:add-domain data=${DATA} headers=${HEADERS_XML}
253 Should be Equal As Strings ${resp.status_code} 200
256 [Arguments] ${domain_name} ${node}=127.0.0.1 ${session}=session
257 [Documentation] Delete Domain via RPC
258 ${DATA} Delete Domain Xml ${node} ${domain_name}
259 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-domain data=${DATA} headers=${HEADERS_XML}
260 Should be Equal As Strings ${resp.status_code} 200
263 [Arguments] ${sgt} ${prefixes} ${node}=127.0.0.1 ${session}=session ${domain}=global
264 [Documentation] Add bindings via RPC to Master DB of node
265 ${DATA} Add Bindings Xml ${node} ${domain} ${sgt} ${prefixes}
266 ${resp} Post Request ${session} ${REST_CONTEXT}:add-bindings data=${DATA} headers=${HEADERS_XML}
267 Should be Equal As Strings ${resp.status_code} 200
270 [Arguments] ${sgt} ${prefixes} ${node}=127.0.0.1 ${session}=session ${domain}=global
271 [Documentation] Delete bindings via RPC from Master DB of node
272 ${DATA} Delete Bindings Xml ${node} ${domain} ${sgt} ${prefixes}
273 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-bindings data=${DATA} headers=${HEADERS_XML}
274 Should be Equal As Strings ${resp.status_code} 200
277 [Arguments] ${sgt} ${start} ${size} ${node}
278 [Documentation] Add Bindings to Node specified by range
279 ${prefixes} Prefix Range ${start} ${size}
280 Add Bindings ${sgt} ${prefixes} ${node}
282 Delete Bindings Range
283 [Arguments] ${sgt} ${start} ${size} ${node}
284 [Documentation] Delete Bindings to Node specified by range
285 ${prefixes} Prefix Range ${start} ${size}
286 Delete Bindings ${sgt} ${prefixes} ${node}
289 [Arguments] ${sgt} ${start} ${end} ${node}
290 [Documentation] Check if Node contains Bindings specified by range
291 ${resp} Get Bindings ${node}
292 : FOR ${num} IN RANGE ${start} ${end}
293 \ ${ip} Get Ip From Number ${num}
294 \ Should Contain Binding ${resp} ${sgt} ${ip}/32
296 Check Binding Range Negative
297 [Arguments] ${sgt} ${start} ${end} ${node}
298 [Documentation] Check if Node does not contains Bindings specified by range
299 ${resp} Get Bindings ${node}
300 : FOR ${num} IN RANGE ${start} ${end}
301 \ ${ip} Get Ip From Number ${num}
302 \ Should Not Contain Binding ${resp} ${sgt} ${ip}/32
304 Setup SXP Environment
305 [Arguments] ${node_range}=2
306 [Documentation] Create session to Controller, node_range parameter specifies number of nodes to be created plus one
308 : FOR ${num} IN RANGE 1 ${node_range}
309 \ ${ip} Get Ip From Number ${num}
310 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Add Node ${ip}
311 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Wait Until Keyword Succeeds 20 1 Check Node Started
315 [Arguments] ${node} ${port}=64999 ${system}=${ODL_SYSTEM_IP}
316 [Documentation] Verify that SxpNode has data writed to Operational datastore
317 ${resp} RequestsLibrary.Get Request session /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
318 Should Be Equal As Strings ${resp.status_code} 200
319 ${rc} Run Command On Remote System ${system} netstat -tln | grep -q ${node}:${port} && echo 0 || echo 1 ${ODL_SYSTEM_USER} ${ODL_SYSTEM_PASSWORD} prompt=${ODL_SYSTEM_PROMPT}
320 Should Be Equal As Strings ${rc} 0
322 Clean SXP Environment
323 [Arguments] ${node_range}=2
324 [Documentation] Destroy created sessions
325 : FOR ${num} IN RANGE 1 ${node_range}
326 \ ${ip} Get Ip From Number ${num}
327 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Delete Node ${ip}