2 Documentation Library containing Keywords used for SXP testing
4 Library RequestsLibrary
8 Resource CompareStream.robot
9 Resource KarafKeywords.robot
11 Resource TemplatedRequests.robot
12 Variables ../variables/Variables.py
15 ${REST_CONTEXT} /restconf/operations/sxp-controller
19 [Arguments] ${session} ${path} ${DATA} ${rest_context}=${REST_CONTEXT}
20 [Documentation] Post request to Controller and checks response
21 ${resp} Post Request ${session} ${rest_context}:${path} data=${DATA} headers=${HEADERS_XML}
26 Should be Equal As Strings ${resp.status_code} 200
27 ${content} Evaluate json.loads('''${resp.content}''') json
28 ${output} Get From Dictionary ${content} output
29 ${result} Get From Dictionary ${output} result
30 Should Be True ${result} RPC result is False
33 [Arguments] ${node} ${password}=${EMPTY} ${version}=version4 ${port}=64999 ${session}=session ${ip}=${EMPTY}
34 ... ${ssl_stores}=${EMPTY} ${retry_open_timer}=1
35 [Documentation] Add node via RPC to ODL
36 ${DATA} Add Node Xml ${node} ${port} ${password} ${version} ${ip}
37 ... keystores=${ssl_stores} retry_open_timer=${retry_open_timer}
38 Post To Controller ${session} add-node ${DATA}
41 [Arguments] ${node} ${session}=session
42 [Documentation] Delete connection via RPC from node
43 ${DATA} Delete Node Xml ${node}
44 Post To Controller ${session} delete-node ${DATA}
47 [Arguments] ${version} ${mode} ${ip} ${port} ${node}=127.0.0.1 ${password}=${EMPTY}
48 ... ${session}=session ${domain}=global ${security_mode}=${EMPTY}
49 [Documentation] Add connection via RPC to node
50 ${DATA} Add Connection Xml ${version} ${mode} ${ip} ${port} ${node}
51 ... ${password} ${domain} security_mode=${security_mode}
52 Post To Controller ${session} add-connection ${DATA}
55 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
56 [Documentation] Gets all connections via RPC from node
57 ${DATA} Get Connections From Node Xml ${node} ${domain}
58 ${resp} Post Request ${session} ${REST_CONTEXT}:get-connections data=${DATA} headers=${HEADERS_XML}
59 Should be Equal As Strings ${resp.status_code} 200
60 [Return] ${resp.content}
63 [Arguments] ${ip} ${port} ${node}=127.0.0.1 ${session}=session ${domain}=global
64 [Documentation] Delete connection via RPC from node
65 ${DATA} Delete Connections Xml ${ip} ${port} ${node} ${domain}
66 Post To Controller ${session} delete-connection ${DATA}
69 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
70 [Documentation] Delete all connections via RPC from node
71 ${resp} Get Connections ${node} ${session} ${domain}
72 @{connections} Parse Connections ${resp}
73 : FOR ${connection} IN @{connections}
74 \ Delete Connections ${connection['peer-address']} ${connection['tcp-port']} ${node} ${session} ${domain}
77 [Arguments] ${version} ${mode} ${ip} ${port}=64999 ${node}=127.0.0.1 ${state}=on
78 ... ${session}=session ${domain}=global
79 [Documentation] Verify that connection is ON
80 ${resp} Get Connections ${node} ${session} ${domain}
81 Should Contain Connection ${resp} ${ip} ${port} ${mode} ${version} ${state}
84 [Arguments] ${sgt} ${prefixes} ${origin}=LOCAL ${node}=127.0.0.1 ${session}=session ${domain}=global
85 [Documentation] Add/Update one or more bindings via RPC to Master DB of the node
86 ${DATA} Add Bindings Xml ${node} ${domain} ${sgt} ${prefixes} ${origin}
87 Post To Controller ${session} add-bindings ${DATA}
90 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global ${scope}=all
91 [Documentation] Gets all binding via RPC from Master DB of node
92 ${DATA} Get Bindings From Node Xml ${node} ${scope} ${domain}
93 ${resp} TemplatedRequests.Post_To_Uri ${REST_CONTEXT}:get-node-bindings data=${DATA} accept=${ACCEPT_JSON} content_type=${HEADERS_XML} session=${session}
97 [Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global ${scope}=local
98 [Documentation] Delete all bindings via RPC from Master DB of node
99 ${resp} Get Bindings ${node} ${session} ${domain} ${scope}
100 @{bindings} Parse Bindings ${resp}
101 : FOR ${binding} IN @{bindings}
102 \ Delete Bindings ${binding['sgt']} ${binding['ip-prefix']} ${node} ${domain} ${session}
105 [Arguments] ${sgt} ${prefixes} ${node}=127.0.0.1 ${domain}=global ${session}=session
106 [Documentation] Delete one or more bindings via RPC from Master DB of node
107 ${DATA} Delete Bindings Xml ${node} ${domain} ${sgt} @{prefixes}
108 Post To Controller ${session} delete-bindings ${DATA}
111 [Arguments] ${name} ${peers}= ${node}=127.0.0.1 ${session}=session
112 [Documentation] Adds new PeerGroup via RPC to Node
113 ${DATA} Add Peer Group Xml ${name} ${peers} ${node}
114 Post To Controller ${session} add-peer-group ${DATA}
117 [Arguments] ${name} ${node}=127.0.0.1 ${session}=session
118 [Documentation] Delete PeerGroup via RPC from Node
119 ${DATA} Delete Peer Group Xml ${name} ${node}
120 Post To Controller ${session} delete-peer-group ${DATA}
123 [Arguments] ${node}=127.0.0.1 ${session}=session
124 [Documentation] Gets all PeerGroups via RPC from node
125 ${DATA} Get Peer Groups From Node Xml ${node}
126 ${resp} Post Request ${session} ${REST_CONTEXT}:get-peer-groups data=${DATA} headers=${HEADERS_XML}
127 Should be Equal As Strings ${resp.status_code} 200
128 [Return] ${resp.content}
131 [Arguments] ${node}=127.0.0.1 ${session}=session
132 [Documentation] Delete all PeerGroups via RPC from node
133 ${resp} Get Peer Groups ${node} ${session}
134 @{prefixes} Parse Peer Groups ${resp}
135 : FOR ${group} IN @{prefixes}
136 \ Delete Peer Group ${group['name']} ${node} ${session}
139 [Arguments] ${name} ${type} ${entries} ${node}=127.0.0.1 ${session}=session ${policy}=auto-update
140 [Documentation] Add Filter via RPC from Node
141 ${DATA} Run_Keyword_If_At_Least_Else carbon Add Filter Xml ${name} ${type} ${entries}
142 ... ${node} ${policy}
143 ... ELSE Add Filter Xml ${name} ${type} ${entries} ${node}
144 Post To Controller ${session} add-filter ${DATA}
147 [Arguments] ${name} ${domains} ${entries} ${node}=127.0.0.1 ${filter_name}=base-domain-filter ${session}=session
148 [Documentation] Add Domain Filter via RPC from Node
149 ${DATA} Add Domain Filter Xml ${name} ${domains} ${entries} ${node} ${filter_name}
150 Post To Controller ${session} add-domain-filter ${DATA}
153 [Arguments] ${name} ${type} ${node}=127.0.0.1 ${session}=session
154 [Documentation] Delete Filter via RPC from Node
155 ${DATA} Delete Filter Xml ${name} ${type} ${node}
156 Post To Controller ${session} delete-filter ${DATA}
159 [Arguments] ${name} ${node}=127.0.0.1 ${filter_name}=base-domain-filter ${session}=session
160 [Documentation] Delete Filter via RPC from Node
161 ${DATA} Delete Domain Filter Xml ${name} ${node} ${filter_name}
162 Post To Controller ${session} delete-domain-filter ${DATA}
164 Should Contain Binding
165 [Arguments] ${resp} ${sgt} ${prefix}
166 [Documentation] Tests if data contains specified binding
167 ${out} Find Binding ${resp} ${sgt} ${prefix}
168 Should Be True ${out} Doesn't have ${sgt} ${prefix}
170 Should Not Contain Binding
171 [Arguments] ${resp} ${sgt} ${prefix}
172 [Documentation] Tests if data doesn't contains specified binding
173 ${out} Find Binding ${resp} ${sgt} ${prefix}
174 Should Not Be True ${out} Should't have ${sgt} ${prefix}
176 Should Contain Connection
177 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
178 [Documentation] Test if data contains specified connection
179 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
181 Should Be True ${out} Doesn't have ${ip}:${port} ${mode} ${version}
183 Should Not Contain Connection
184 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
185 [Documentation] Test if data doesn't contains specified connection
186 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
188 Should Not Be True ${out} Shouldn't have ${ip}:${port} ${mode} ${version}
190 Bindings Should Contain
191 [Arguments] ${sgt} ${prefix} ${domain}=global ${scope}=all
192 [Documentation] Retrieves bindings and verifies they contain given binding
193 ${resp} Get Bindings domain=${domain} scope=${scope}
194 Should Contain Binding ${resp} ${sgt} ${prefix}
196 Bindings Should Not Contain
197 [Arguments] ${sgt} ${prefix} ${domain}=global ${scope}=all
198 [Documentation] Retrieves bindings and verifies they do not contain given binding
199 ${resp} Get Bindings domain=${domain} scope=${scope}
200 Should Not Contain Binding ${resp} ${sgt} ${prefix}
202 Connections Should Contain
203 [Arguments] ${ip} ${port} ${mode} ${version} ${state}=none
204 [Documentation] Retrieves connections and verifies they contain given connection
205 ${resp} Get Connections
206 Should Contain Connection ${resp} ${ip} ${port} ${mode} ${version} ${state}
208 Connections Should Not Contain
209 [Arguments] ${ip} ${port} ${mode} ${version} ${state}=none
210 [Documentation] Retrieves connections and verifies they do not contain given connection
211 ${resp} Get Connections
212 Should Not Contain Connection ${resp} ${ip} ${port} ${mode} ${version} ${state}
214 Setup Topology Complex
215 [Arguments] ${version}=version4 ${PASSWORD}=none
216 : FOR ${node} IN RANGE 2 6
217 \ Add Connection ${version} both 127.0.0.1 64999 127.0.0.${node}
219 \ Add Connection ${version} both 127.0.0.${node} 64999 127.0.0.1
221 \ Wait Until Keyword Succeeds 15 1 Verify Connection ${version} both
222 \ ... 127.0.0.${node}
223 \ Add Bindings ${node}0 10.10.10.${node}0/32 127.0.0.${node}
224 \ Add Bindings ${node}0 10.10.${node}0.0/24 127.0.0.${node}
225 \ Add Bindings ${node}0 10.${node}0.0.0/16 127.0.0.${node}
226 \ Add Bindings ${node}0 ${node}0.0.0.0/8 127.0.0.${node}
227 Add Bindings 10 10.10.10.10/32 127.0.0.1
228 Add Bindings 10 10.10.10.0/24 127.0.0.1
229 Add Bindings 10 10.10.0.0/16 127.0.0.1
230 Add Bindings 10 10.0.0.0/8 127.0.0.1
232 Verify Snapshot Was Pushed
233 [Arguments] ${snapshot_string}=22-sxp-controller-one-node.xml
234 [Documentation] Will succeed if the ${snapshot_string} is found in the karaf logs
235 ${output} Run Command On Controller ${ODL_SYSTEM_IP} cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log* | grep -c 'Successfully pushed configuration snapshot.*${snapshot_string}'
236 Should Not Be Equal As Strings ${output} 0
238 Prepare SSH Keys On Karaf
239 [Arguments] ${system}=${ODL_SYSTEM_IP} ${user}=${ODL_SYSTEM_USER} ${passwd}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT} ${system_workspace}=${WORKSPACE}
240 [Documentation] Executes client login on karaf VM in so that SSH keys will be generated by defualt karaf callback,
241 ... expecting echo affter succesfull login. TODO: test on multiple runs if this aproach reduce SSHExceptions in robotframework
242 ${stdout} Run Command On Remote System ${system} ${system_workspace}${/}${BUNDLEFOLDER}/bin/client echo READY ${user} ${passwd} prompt=${prompt}
243 Should Match "${stdout}" "*READY"
246 [Arguments] ${session}=session ${controller}=${ODL_SYSTEM_IP}
247 [Documentation] Create session to Controller
248 Verify Feature Is Installed odl-sxp-controller ${controller}
249 Create Session ${session} url=http://${controller}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
250 ${resp} RequestsLibrary.Get Request ${session} ${MODULES_API}
251 Should Be Equal As Strings ${resp.status_code} 200
252 Should Contain ${resp.content} ietf-restconf
255 [Documentation] Destroy created sessions
259 [Arguments] ${domain_name} ${sgt}=None ${prefixes}='' ${origin}=LOCAL ${node}=127.0.0.1 ${session}=session
260 [Documentation] Add Domain with bindings via RPC
261 ${DATA} Add Domain Xml ${node} ${domain_name} ${sgt} ${prefixes} ${origin}
262 Post To Controller ${session} add-domain ${DATA}
265 [Arguments] ${domain_name} ${node}=127.0.0.1 ${session}=session
266 [Documentation] Delete Domain via RPC
267 ${DATA} Delete Domain Xml ${node} ${domain_name}
268 Post To Controller ${session} delete-domain ${DATA}
271 [Arguments] ${sgt} ${start} ${size} ${node}=127.0.0.1
272 [Documentation] Add Bindings to Node specified by range
273 ${prefixes} Prefix Range ${start} ${size}
274 Add Bindings ${sgt} ${prefixes} ${node}
276 Delete Bindings Range
277 [Arguments] ${sgt} ${start} ${size} ${node}=127.0.0.1
278 [Documentation] Delete Bindings to Node specified by range
279 ${prefixes} Prefix Range ${start} ${size}
280 Delete Bindings ${sgt} ${prefixes} ${node}
283 [Arguments] ${sgt} ${start} ${end} ${node}=127.0.0.1
284 [Documentation] Check if Node contains Bindings specified by range
285 ${resp} Get Bindings ${node}
286 : FOR ${num} IN RANGE ${start} ${end}
287 \ ${ip} Get Ip From Number ${num}
288 \ Should Contain Binding ${resp} ${sgt} ${ip}/32
290 Check Binding Range Negative
291 [Arguments] ${sgt} ${start} ${end} ${node}=127.0.0.1
292 [Documentation] Check if Node does not contains Bindings specified by range
293 ${resp} Get Bindings ${node}
294 : FOR ${num} IN RANGE ${start} ${end}
295 \ ${ip} Get Ip From Number ${num}
296 \ Should Not Contain Binding ${resp} ${sgt} ${ip}/32
298 Setup SXP Environment
299 [Arguments] ${node_range}=2
300 [Documentation] Create session to Controller, node_range parameter specifies number of nodes to be created plus one
302 : FOR ${num} IN RANGE 1 ${node_range}
303 \ ${ip} Get Ip From Number ${num}
304 \ ${rnd_retry_time} = Evaluate random.randint(1, 10) modules=random
305 \ Add Node ${ip} retry_open_timer=${rnd_retry_time}
306 \ Wait Until Keyword Succeeds 20 1 Check Node Started ${ip}
309 [Arguments] ${node} ${port}=64999 ${system}=${ODL_SYSTEM_IP} ${session}=session ${ip}=${node}
310 [Documentation] Verify that SxpNode has data writed to Operational datastore
311 ${resp} RequestsLibrary.Get Request ${session} /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
312 Should Be Equal As Strings ${resp.status_code} 200
313 ${rc} Run Command On Remote System ${system} netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1 ${ODL_SYSTEM_USER} ${ODL_SYSTEM_PASSWORD} prompt=${ODL_SYSTEM_PROMPT}
314 Should Be Equal As Strings ${rc} 0
316 Clean SXP Environment
317 [Arguments] ${node_range}=2
318 [Documentation] Destroy created sessions
319 : FOR ${num} IN RANGE 1 ${node_range}
320 \ ${ip} Get Ip From Number ${num}
324 Get Routing Configuration From Controller
325 [Arguments] ${session}
326 [Documentation] Get Routing configuration from config DS
327 ${resp} RequestsLibrary.Get Request ${session} /restconf/config/sxp-cluster-route:sxp-cluster-route/ headers=${ACCEPT_XML}
328 ${data} Set Variable If "${resp.status_code}" == "200" ${resp.content} ${EMPTY}
331 Put Routing Configuration To Controller
332 [Arguments] ${DATA} ${session}
333 [Documentation] Put Routing configuration to Config DS
334 ${resp} RequestsLibrary.Put Request ${session} /restconf/config/sxp-cluster-route:sxp-cluster-route/ data=${DATA} headers=${HEADERS_XML}
335 Should Match "${resp.status_code}" "20?"
337 Clean Routing Configuration To Controller
338 [Arguments] ${session}
339 [Documentation] Delete Routing configuration from Config DS
340 ${resp} RequestsLibrary.Get Request ${session} /restconf/config/sxp-cluster-route:sxp-cluster-route/ headers=${ACCEPT_XML}
341 Run Keyword If "${resp.status_code}" == "200" RequestsLibrary.Delete Request ${session} /restconf/config/sxp-cluster-route:sxp-cluster-route/