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 ${session}=session ${domain}=global
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 \ ... ${session} ${domain}
104 \ ... ELSE Delete Binding ${sgt['sgt']} ${prefix['ip-prefix']} ${node}
105 \ ... ${session} ${domain}
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 ${session}=session ${domain}=global
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} ${type} ${node}=127.0.0.1 ${session}=session
162 [Documentation] Delete Filter via RPC from Node
163 ${DATA} Delete Filter Xml ${name} ${type} ${node}
164 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-filter data=${DATA} headers=${HEADERS_XML}
165 Should be Equal As Strings ${resp.status_code} 200
167 Should Contain Binding
168 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
169 [Documentation] Tests if data contains specified binding
170 ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
171 ... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
173 Should Be True ${out} Doesn't have ${sgt} ${prefix}
175 Should Not Contain Binding
176 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
177 [Documentation] Tests if data doesn't contains specified binding
178 ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
179 ... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
181 Should Not Be True ${out} Should't have ${sgt} ${prefix}
183 Should Contain Connection
184 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
185 [Documentation] Test if data contains specified connection
186 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
188 Should Be True ${out} Doesn't have ${ip}:${port} ${mode} ${version}
190 Should Not Contain Connection
191 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
192 [Documentation] Test if data doesn't contains specified connection
193 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
195 Should Not Be True ${out} Shouldn't have ${ip}:${port} ${mode} ${version}
197 Setup Topology Complex
198 [Arguments] ${version}=version4 ${PASSWORD}=none
199 : FOR ${node} IN RANGE 2 6
200 \ Add Connection ${version} both 127.0.0.1 64999 127.0.0.${node}
202 \ Add Connection ${version} both 127.0.0.${node} 64999 127.0.0.1
204 \ Wait Until Keyword Succeeds 15 1 Verify Connection ${version} both
205 \ ... 127.0.0.${node}
206 \ Add Binding ${node}0 10.10.10.${node}0/32 127.0.0.${node}
207 \ Add Binding ${node}0 10.10.${node}0.0/24 127.0.0.${node}
208 \ Add Binding ${node}0 10.${node}0.0.0/16 127.0.0.${node}
209 \ Add Binding ${node}0 ${node}0.0.0.0/8 127.0.0.${node}
210 Add Binding 10 10.10.10.10/32 127.0.0.1
211 Add Binding 10 10.10.10.0/24 127.0.0.1
212 Add Binding 10 10.10.0.0/16 127.0.0.1
213 Add Binding 10 10.0.0.0/8 127.0.0.1
216 [Documentation] Create session to Controller
217 Verify Feature Is Installed odl-sxp-controller
218 Wait Until Keyword Succeeds 20 10 Check Karaf Log Has Messages Successfully pushed configuration snapshot 22-sxp-controller-one-node.xml
219 Create Session session url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
220 ${resp} RequestsLibrary.Get Request session ${MODULES_API}
221 Should Be Equal As Strings ${resp.status_code} 200
222 Should Contain ${resp.content} ietf-restconf
225 [Documentation] Destroy created sessions
229 [Arguments] ${domain_name} ${node}=127.0.0.1 ${session}=session
230 [Documentation] Add Domain via RPC
231 ${DATA} Add Domain Xml ${node} ${domain_name}
232 ${resp} Post Request ${session} ${REST_CONTEXT}:add-domain data=${DATA} headers=${HEADERS_XML}
233 Should be Equal As Strings ${resp.status_code} 200
236 [Arguments] ${domain_name} ${node}=127.0.0.1 ${session}=session
237 [Documentation] Delete Domain via RPC
238 ${DATA} Delete Domain Xml ${node} ${domain_name}
239 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-domain data=${DATA} headers=${HEADERS_XML}
240 Should be Equal As Strings ${resp.status_code} 200
243 [Arguments] ${sgt} ${prefixes} ${node}=127.0.0.1 ${session}=session ${domain}=global
244 [Documentation] Add bindings via RPC to Master DB of node
245 ${DATA} Add Bindings Xml ${node} ${domain} ${sgt} ${prefixes}
246 ${resp} Post Request ${session} ${REST_CONTEXT}:add-bindings data=${DATA} headers=${HEADERS_XML}
247 Should be Equal As Strings ${resp.status_code} 200
250 [Arguments] ${sgt} ${prefixes} ${node}=127.0.0.1 ${session}=session ${domain}=global
251 [Documentation] Delete bindings via RPC from Master DB of node
252 ${DATA} Delete Bindings Xml ${node} ${domain} ${sgt} ${prefixes}
253 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-bindings data=${DATA} headers=${HEADERS_XML}
254 Should be Equal As Strings ${resp.status_code} 200
257 [Arguments] ${sgt} ${start} ${size} ${node}
258 [Documentation] Add Bindings to Node specified by range
259 ${prefixes} Prefix Range ${start} ${size}
260 Add Bindings ${sgt} ${prefixes} ${node}
262 Delete Bindings Range
263 [Arguments] ${sgt} ${start} ${size} ${node}
264 [Documentation] Delete Bindings to Node specified by range
265 ${prefixes} Prefix Range ${start} ${size}
266 Delete Bindings ${sgt} ${prefixes} ${node}
269 [Arguments] ${sgt} ${start} ${end} ${node}
270 [Documentation] Check if Node contains Bindings specified by range
271 ${resp} Get Bindings ${node}
272 : FOR ${num} IN RANGE ${start} ${end}
273 \ ${ip} Get Ip From Number ${num}
274 \ Should Contain Binding ${resp} ${sgt} ${ip}/32
276 Check Binding Range Negative
277 [Arguments] ${sgt} ${start} ${end} ${node}
278 [Documentation] Check if Node does not contains Bindings specified by range
279 ${resp} Get Bindings ${node}
280 : FOR ${num} IN RANGE ${start} ${end}
281 \ ${ip} Get Ip From Number ${num}
282 \ Should Not Contain Binding ${resp} ${sgt} ${ip}/32
284 Setup SXP Environment
285 [Arguments] ${node_range}=2
286 [Documentation] Create session to Controller, node_range parameter specifies number of nodes to be created plus one
288 : FOR ${num} IN RANGE 1 ${node_range}
289 \ ${ip} Get Ip From Number ${num}
290 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Add Node ${ip}
291 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Wait Until Keyword Succeeds 20 1 Check Node Started
295 [Arguments] ${node} ${port}=64999 ${system}=${ODL_SYSTEM_IP}
296 [Documentation] Verify that SxpNode has data writed to Operational datastore
297 ${resp} RequestsLibrary.Get Request session /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
298 Should Be Equal As Strings ${resp.status_code} 200
299 ${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}
300 Should Be Equal As Strings ${rc} 0
302 Clean SXP Environment
303 [Arguments] ${node_range}=2
304 [Documentation] Destroy created sessions
305 : FOR ${num} IN RANGE 1 ${node_range}
306 \ ${ip} Get Ip From Number ${num}
307 \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Delete Node ${ip}