2 Documentation Library containing Keywords used for SXP testing
4 Library RequestsLibrary
8 Resource KarafKeywords.robot
9 Variables ../variables/Variables.py
12 ${REST_CONTEXT} /restconf/operations/sxp-controller
16 [Arguments] ${version} ${mode} ${ip} ${port} ${node}=127.0.0.1 ${password}=none
17 ... ${session}=session
18 [Documentation] Add connection via RPC to node
19 ${DATA} Add Connection Xml ${version} ${mode} ${ip} ${port} ${node}
21 ${resp} Post Request ${session} ${REST_CONTEXT}:add-connection data=${DATA} headers=${HEADERS_XML}
23 Should be Equal As Strings ${resp.status_code} 200
26 [Arguments] ${node}=127.0.0.1 ${session}=session
27 [Documentation] Gets all connections via RPC from node
28 ${DATA} Get Connections From Node Xml ${node}
29 ${resp} Post Request ${session} ${REST_CONTEXT}:get-connections data=${DATA} headers=${HEADERS_XML}
30 Should be Equal As Strings ${resp.status_code} 200
31 [Return] ${resp.content}
34 [Arguments] ${ip} ${port} ${node}=127.0.0.1 ${session}=session
35 [Documentation] Delete connection via RPC from node
36 ${DATA} Delete Connections Xml ${ip} ${port} ${node}
37 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-connection data=${DATA} headers=${HEADERS_XML}
38 Should be Equal As Strings ${resp.status_code} 200
41 [Arguments] ${node}=127.0.0.1 ${session}=session
42 [Documentation] Delete all connections via RPC from node
43 ${resp} Get Connections ${node} ${session}
44 @{connections} Parse Connections ${resp}
45 : FOR ${connection} IN @{connections}
46 \ delete connections ${connection['peer-address']} ${connection['tcp-port']} ${node} ${session}
49 [Arguments] ${version} ${mode} ${ip} ${port}=64999 ${node}=127.0.0.1 ${state}=on
50 [Documentation] Verify that connection is ON
51 ${resp} Get Connections ${node}
52 Should Contain Connection ${resp} ${ip} ${port} ${mode} ${version} ${state}
55 [Arguments] ${sgt} ${prefix} ${node}=127.0.0.1 ${session}=session
56 [Documentation] Add binding via RPC to Master DB of node
57 ${DATA} Add Entry Xml ${sgt} ${prefix} ${node}
58 ${resp} Post Request ${session} ${REST_CONTEXT}:add-entry data=${DATA} headers=${HEADERS_XML}
60 Should be Equal As Strings ${resp.status_code} 200
63 [Arguments] ${node}=127.0.0.1 ${session}=session
64 [Documentation] Gets all binding via RPC from Master DB of node
65 ${DATA} Get Bindings From Node Xml ${node}
66 ${resp} Post Request ${session} ${REST_CONTEXT}:get-node-bindings data=${DATA} headers=${HEADERS_XML}
67 Should be Equal As Strings ${resp.status_code} 200
68 [Return] ${resp.content}
71 [Arguments] ${node}=127.0.0.1 ${session}=session
72 [Documentation] Delete all bindings via RPC from Master DB of node
73 ${resp} Get Bindings Master Database ${node} ${session}
74 @{prefixes} Parse Prefix Groups ${resp} local
75 : FOR ${prefix} IN @{prefixes}
76 \ Clean Binding ${prefix} ${prefix['binding']} ${node} ${session}
79 [Arguments] ${prefix} ${bindings} ${node} ${session}
80 [Documentation] Used for nester FOR loop
81 : FOR ${binding} IN @{bindings}
82 \ Delete Binding ${prefix['sgt']} ${binding['ip-prefix']} ${node} ${session}
84 Get Bindings Master Database
85 [Arguments] ${node}=127.0.0.1 ${session}=session
86 [Documentation] Gets content of Master DB from node
87 ${resp} Get Request ${session} /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/master-database/ headers=${HEADERS_XML}
88 Should be Equal As Strings ${resp.status_code} 200
89 [Return] ${resp.content}
92 [Arguments] ${sgtOld} ${prefixOld} ${sgtNew} ${prefixNew} ${node}=127.0.0.1 ${session}=session
93 [Documentation] Updates value of binding via RPC in Master DB of node
94 ${DATA} Update Binding Xml ${sgtOld} ${prefixOld} ${sgtNew} ${prefixNew} ${node}
95 ${resp} Post Request ${session} ${REST_CONTEXT}:update-entry data=${DATA} headers=${HEADERS_XML}
96 Should be Equal As Strings ${resp.status_code} 200
99 [Arguments] ${sgt} ${prefix} ${node}=127.0.0.1 ${session}=session
100 [Documentation] Delete binding via RPC from Master DB of node
101 ${DATA} Delete Binding Xml ${sgt} ${prefix} ${node}
102 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-entry data=${DATA} headers=${HEADERS_XML}
103 Should be Equal As Strings ${resp.status_code} 200
106 [Arguments] ${name} ${peers}= ${node}=127.0.0.1 ${session}=session
107 [Documentation] Adds new PeerGroup via RPC to Node
108 ${DATA} Add Peer Group Xml ${name} ${peers} ${node}
110 ${resp} Post Request ${session} ${REST_CONTEXT}:add-peer-group data=${DATA} headers=${HEADERS_XML}
111 Should be Equal As Strings ${resp.status_code} 200
114 [Arguments] ${name} ${node}=127.0.0.1 ${session}=session
115 [Documentation] Delete PeerGroup via RPC from Node
116 ${DATA} Delete Peer Group Xml ${name} ${node}
117 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-peer-group data=${DATA} headers=${HEADERS_XML}
118 Should be Equal As Strings ${resp.status_code} 200
121 [Arguments] ${node}=127.0.0.1 ${session}=session
122 [Documentation] Gets all PeerGroups via RPC from node
123 ${DATA} Get Peer Groups From Node Xml ${node}
124 ${resp} Post Request ${session} ${REST_CONTEXT}:get-peer-groups data=${DATA} headers=${HEADERS_XML}
125 Should be Equal As Strings ${resp.status_code} 200
126 [Return] ${resp.content}
129 [Arguments] ${node}=127.0.0.1 ${session}=session
130 [Documentation] Delete all PeerGroups via RPC from node
131 ${resp} Get Peer Groups ${node} ${session}
132 @{prefixes} Parse Peer Groups ${resp}
133 : FOR ${group} IN @{prefixes}
134 \ Delete Peer Group ${group['name']} ${node} ${session}
137 [Arguments] ${name} ${type} ${entries} ${node}=127.0.0.1 ${session}=session
138 [Documentation] Add Filter via RPC from Node
139 ${DATA} Add Filter Xml ${name} ${type} ${entries} ${node}
140 ${resp} Post Request ${session} ${REST_CONTEXT}:add-filter data=${DATA} headers=${HEADERS_XML}
141 Should be Equal As Strings ${resp.status_code} 200
144 [Arguments] ${name} ${type} ${node}=127.0.0.1 ${session}=session
145 [Documentation] Delete Filter via RPC from Node
146 ${DATA} Delete Filter Xml ${name} ${type} ${node}
147 ${resp} Post Request ${session} ${REST_CONTEXT}:delete-filter data=${DATA} headers=${HEADERS_XML}
148 Should be Equal As Strings ${resp.status_code} 200
150 Should Contain Binding
151 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=local
152 [Documentation] Tests if data contains specified binding
153 ${out} Find Binding ${resp} ${sgt} ${prefix} ${db_source} add
154 Should Be True ${out} Doesn't have ${sgt} ${prefix}
155 ${out} Find Binding ${resp} ${sgt} ${prefix} ${db_source} delete
156 Should Not Be True ${out} Should't have ${sgt} ${prefix}
158 Should Not Contain Binding
159 [Arguments] ${resp} ${sgt} ${prefix} ${db_source}=local
160 [Documentation] Tests if data doesn't contains specified binding
161 ${out} Find Binding ${resp} ${sgt} ${prefix} ${db_source} add
162 Should Not Be True ${out} Should't have ${sgt} ${prefix}
164 Should Contain Binding With Peer Sequence
165 [Arguments] ${resp} ${sgt} ${prefix} ${source} ${seq}=0 ${db_source}=local
166 [Documentation] Tests if data contains specified binding with peer sequence
167 ${out} Find Binding With Peer Sequence ${resp} ${sgt} ${prefix} ${db_source} add
169 Should Be True ${out} Doesn't have ${sgt} ${prefix} ${source} ${seq} ${db_source}
171 Should Not Contain Binding With Peer Sequence
172 [Arguments] ${resp} ${sgt} ${prefix} ${source} ${seq}=0 ${db_source}=local
173 [Documentation] Tests if data doesn't contains specified binding with peer sequence
174 ${out} Find Binding With Peer Sequence ${resp} ${sgt} ${prefix} ${db_source} add
176 Should Not Be True ${out} Should't have ${sgt} ${prefix} ${source} ${seq} ${db_source}
178 Should Contain Connection
179 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
180 [Documentation] Test if data contains specified connection
181 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
183 Should Be True ${out} Doesn't have ${ip}:${port} ${mode} ${version}
185 Should Not Contain Connection
186 [Arguments] ${resp} ${ip} ${port} ${mode} ${version} ${state}=none
187 [Documentation] Test if data doesn't contains specified connection
188 ${out} Find Connection ${resp} ${version} ${mode} ${ip} ${port}
190 Should Not Be True ${out} Shouldn't have ${ip}:${port} ${mode} ${version}
192 Setup Topology Complex
193 [Arguments] ${version}=version4 ${PASSWORD}=none
194 : FOR ${node} IN RANGE 2 6
195 \ Add Connection ${version} both 127.0.0.1 64999 127.0.0.${node}
197 \ Add Connection ${version} both 127.0.0.${node} 64999 127.0.0.1
199 \ Wait Until Keyword Succeeds 15 4 Verify Connection ${version} both
200 \ ... 127.0.0.${node}
201 \ Add Binding ${node}0 10.10.10.${node}0/32 127.0.0.${node}
202 \ Add Binding ${node}0 10.10.${node}0.0/24 127.0.0.${node}
203 \ Add Binding ${node}0 10.${node}0.0.0/16 127.0.0.${node}
204 \ Add Binding ${node}0 ${node}0.0.0.0/8 127.0.0.${node}
205 Add Binding 10 10.10.10.10/32 127.0.0.1
206 Add Binding 10 10.10.10.0/24 127.0.0.1
207 Add Binding 10 10.10.0.0/16 127.0.0.1
208 Add Binding 10 10.0.0.0/8 127.0.0.1
210 Setup SXP Environment
211 [Documentation] Create session to Controller
212 Verify Feature Is Installed odl-sxp-all
213 Create Session session url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
214 Wait Until Keyword Succeeds 15 3 Get Bindings Master Database
216 Clean SXP Environment
217 [Documentation] Destroy created sessions