6 Variables ../variables/Variables.py
7 Library RequestsLibrary
8 Library SwitchClasses/BaseSwitch.py
12 [Arguments] ${start} ${stop} ${step} ${sustain_time}=0
13 [Documentation] Will find out max switches starting from ${start} till reaching ${stop} and in steps defined by ${step}.
14 ... The network is hold for ${sustain_time} seconds after everything is checked successful.
15 ${max-switches} Set Variable ${0}
16 Set Suite Variable ${max-switches}
17 ${start} Convert to Integer ${start}
18 ${stop} Convert to Integer ${stop}
19 ${step} Convert to Integer ${step}
20 : FOR ${switches} IN RANGE ${start} ${stop+1} ${step}
21 \ ${status} ${result} Run Keyword And Ignore Error Start Mininet Linear ${switches}
22 \ Exit For Loop If '${status}' == 'FAIL'
23 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
24 \ Exit For Loop If '${status}' == 'FAIL'
25 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
26 \ ... Check Every Switch ${switches}
27 \ Exit For Loop If '${status}' == 'FAIL'
28 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
29 \ ... Check Linear Topology ${switches}
30 \ Exit For Loop If '${status}' == 'FAIL'
31 \ Sleep ${sustain_time}
32 \ ${status} ${result} Run Keyword And Ignore Error Stop Mininet Simulation
33 \ Exit For Loop If '${status}' == 'FAIL'
34 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
35 \ ... Check No Switches ${switches}
36 \ Exit For Loop If '${status}' == 'FAIL'
37 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
38 \ ... Check No Topology ${switches}
39 \ Exit For Loop If '${status}' == 'FAIL'
40 \ ${max-switches} Convert To String ${switches}
41 \ Sleep ${sustain_time}
42 [Return] ${max-switches}
45 [Arguments] ${begin} ${stop} ${step} ${sustain_time}=5
46 [Documentation] Will find out max switches in fully mesh topology starting from ${start} till reaching ${stop} and in steps defined by ${step}.
47 ... The network is hold for ${sustain_time} seconds after everything is checked successful.
48 ${max_switches} Set Variable ${0}
49 ${stop} Convert to Integer ${stop}
50 ${step} Convert to Integer ${step}
51 : FOR ${switches} IN RANGE ${begin} ${stop+1} ${step}
52 \ ${status} ${result} Run Keyword And Ignore Error Start Mininet With Custom Topology ${CREATE_FULLYMESH_TOPOLOGY_FILE} ${switches}
53 \ ... ${BASE_MAC_1} ${BASE_IP_1} ${0} ${switches*20}
54 \ Exit For Loop If '${status}' == 'FAIL'
55 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
56 \ Exit For Loop If '${status}' == 'FAIL'
57 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Has No Null Pointer Exceptions ${ODL_SYSTEM_IP}
58 \ Exit For Loop If '${status}' == 'FAIL'
59 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
60 \ ... Check Every Switch ${switches} ${BASE_MAC_1}
61 \ Exit For Loop If '${status}' == 'FAIL'
62 \ ${max-links}= Evaluate ${switches}*${switches-1}
63 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
64 \ ... Check Number Of Links ${max-links}
65 \ Exit For Loop If '${status}' == 'FAIL'
66 \ Sleep ${sustain_time}
67 \ ${status} ${result} Run Keyword And Ignore Error Stop Mininet Simulation
68 \ Exit For Loop If '${status}' == 'FAIL'
69 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
70 \ ... Check No Switches ${switches}
71 \ Exit For Loop If '${status}' == 'FAIL'
72 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
73 \ ... Check No Topology ${switches}
74 \ Exit For Loop If '${status}' == 'FAIL'
75 \ ${max_switches} Set Variable ${switches}
76 \ Sleep ${sustain_time}
77 ${max-links}= Evaluate ${max_switches}*${max_switches-1}
81 [Arguments] ${begin} ${stop} ${step} ${sustain_time}=5
82 [Documentation] Will find out max hosts starting from ${begin} till reaching ${stop} and in steps defined by ${step}.
83 ... The network is hold for ${sustain_time} seconds after everything is checked successful.
84 ${max-hosts} Set Variable ${0}
85 ${stop} Convert to Integer ${stop}
86 ${step} Convert to Integer ${step}
87 : FOR ${hosts} IN RANGE ${begin} ${stop+1} ${step}
88 \ ${status} ${result} Run Keyword And Ignore Error Start Mininet With One Switch And ${hosts} hosts
89 \ Exit For Loop If '${status}' == 'FAIL'
90 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
91 \ ... Check Every Switch ${1}
92 \ Exit For Loop If '${status}' == 'FAIL'
93 \ @{host_list}= Get Mininet Hosts
94 \ ${status}= Ping All Hosts @{host_list}
95 \ Exit For Loop If ${status} != ${0}
96 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
97 \ Exit For Loop If '${status}' == 'FAIL'
98 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
99 \ ... Check Number Of Hosts ${hosts}
100 \ Exit For Loop If '${status}' == 'FAIL'
101 \ Sleep ${sustain_time}
102 \ ${status} ${result} Run Keyword And Ignore Error Stop Mininet Simulation
103 \ Exit For Loop If '${status}' == 'FAIL'
104 \ ${status} ${result} Run Keyword And Ignore Error Check No Switches ${1}
105 \ Exit For Loop If '${status}' == 'FAIL'
106 \ ${status} ${result} Run Keyword And Ignore Error Check No Hosts
107 \ Exit For Loop If '${status}' == 'FAIL'
108 \ ${max-hosts} Convert To String ${hosts}
109 \ Sleep ${sustain_time}
110 [Return] ${max-hosts}
113 [Documentation] Get all the hosts from mininet
114 ${host_list}= Create List
116 ${out}= Read Until mininet>
117 @{words}= Split String ${out} ${SPACE}
118 : FOR ${item} IN @{words}
119 \ ${h}= Get Lines Matching Regexp ${item.rstrip()} .*h[0-9]*s.
120 \ Run Keyword If '${h}' != '${EMPTY}' Append To List ${host_list} ${h}
121 [Return] ${host_list}
124 [Arguments] @{host_list}
125 [Documentation] Do one round of ping from one host to all other hosts in mininet
126 ${source}= Get From List ${host_list} ${0}
127 : FOR ${h} IN @{host_list}
128 \ ${status}= Ping Two Hosts ${source} ${h} 1
129 \ Exit For Loop If ${status}!=${0}
132 Start Mininet With One Switch And ${hosts} hosts
133 [Documentation] Start mininet with one switch and ${hosts} hosts
134 Log Starting mininet with one switch and ${hosts} hosts
135 Log To Console Starting mininet with one switch and ${hosts} hosts
136 ${mininet_conn_id}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=${hosts*3}
137 Set Suite Variable ${mininet_conn_id}
138 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
139 Write sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo linear,1,${hosts} --switch ovsk,protocols=OpenFlow13
142 Check Number Of Hosts
144 [Documentation] Check number of hosts in inventory
145 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
146 Log Check number of hosts in inventory
147 Log To Console Check number of hosts in inventory
148 Should Be Equal As Strings ${resp.status_code} 200
149 ${count}= Get Count ${resp.content} "node-id":"host:
150 Should Be Equal As Integers ${count} ${hosts}
152 Check Number Of Links
154 [Documentation] Check number of links in inventory is ${links}
155 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
156 Log Check number of links in inventory is ${links}
157 Log To Console Check number of links in inventory is ${links}
158 Should Be Equal As Strings ${resp.status_code} 200
159 ${count}= Get Count ${resp.content} "link-id":"openflow:
160 Should Be Equal As Integers ${count} ${links}
163 [Arguments] ${host1} ${host2} ${pingcount}=2 ${connection_index}=${EMPTY} ${connection_alias}=${EMPTY}
164 [Documentation] Ping between mininet hosts. Must be used only after a mininet session is in place.Returns non zero value if there is 100% packet loss.
165 Run Keyword If '${connection_index}' != '${EMPTY}' Switch Connection ${connection_index}
166 Run Keyword If '${connection_alias}' != '${EMPTY}' Switch Connection ${connection_alias}
167 Write ${host1} ping -c ${pingcount} ${host2}
168 ${out}= Read Until mininet>
169 ${ret}= Get Lines Matching Regexp ${out} .*100% packet loss.*
170 ${len}= Get Length ${ret}
174 [Documentation] Check if all hosts are deleted from inventory
175 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
176 Log To Console Checking no hosts are present in operational database
177 Log Checking no hosts are present in operational database
178 Should Be Equal As Strings ${resp.status_code} 200
179 Should Not Contain ${resp.content} "node-id":"host:
182 [Arguments] ${switches}
183 [Documentation] Start mininet linear topology with ${switches} nodes
184 Log To Console Starting mininet linear ${switches}
185 ${mininet_conn_id}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=${switches*3}
186 Set Suite Variable ${mininet_conn_id}
187 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
188 Write sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo linear,${switches} --switch ovsk,protocols=OpenFlow13
191 Start Mininet With Custom Topology
192 [Arguments] ${topology_file} ${switches} ${base_mac}=00:00:00:00:00:00 ${base_ip}=1.1.1.1 ${hosts}=0 ${mininet_start_time}=100
193 [Documentation] Start a custom mininet topology.
194 Log To Console Start a custom mininet topology with ${switches} nodes
195 ${mininet_conn_id}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=${mininet_start_time}
196 Set Suite Variable ${mininet_conn_id}
197 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
198 Write python ${topology_file} ${switches} ${hosts} ${base_mac} ${base_ip}
199 Read Until ${DEFAULT_LINUX_PROMPT}
200 Write sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom switch.py --topo demotopo --switch ovsk,protocols=OpenFlow13
202 Write sh ovs-vsctl show
203 ${output}= Read Until mininet>
204 # Ovsdb connection is sometimes lost after mininet is started. Checking if the connection is alive before proceeding.
205 Should Not Contain ${output} database connection failed
206 Log To Console Mininet Started with ${switches} nodes
209 [Arguments] ${switches} ${base_mac}=00:00:00:00:00:00
210 [Documentation] Check all switches and stats in operational inventory
211 ${mac}= Replace String Using Regexp ${base_mac} : ${EMPTY}
212 ${mac}= Convert Hex To Decimal As String ${mac}
213 ${mac}= Convert To Integer ${mac}
214 : FOR ${switch} IN RANGE 1 ${switches+1}
215 \ ${dpid_decimal}= Evaluate ${mac}+${switch}
216 \ ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}/node/openflow:${dpid_decimal}
217 \ Should Be Equal As Strings ${resp.status_code} 200
218 \ Log To Console Checking Switch ${switch}
219 \ Should Contain ${resp.content} flow-capable-node-connector-statistics
220 \ Should Contain ${resp.content} flow-table-statistics
222 Check Linear Topology
223 [Arguments] ${switches}
224 [Documentation] Check Linear topology given ${switches}
225 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
226 Log To Console Checking Topology
227 Should Be Equal As Strings ${resp.status_code} 200
228 : FOR ${switch} IN RANGE 1 ${switches+1}
229 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
230 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
231 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
232 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
233 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
234 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
235 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
236 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
237 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3"
240 [Arguments] ${switches}
241 [Documentation] Check no switch is in inventory
242 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}
243 Log To Console Checking No Switches
244 Should Be Equal As Strings ${resp.status_code} 200
245 : FOR ${switch} IN RANGE 1 ${switches+1}
246 \ Should Not Contain ${resp.content} openflow:${switch}
249 [Arguments] ${switches}
250 [Documentation] Check no switch is in topology
251 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
252 Log To Console Checking No Topology
253 Should Be Equal As Strings ${resp.status_code} 200
254 : FOR ${switch} IN RANGE 1 ${switches+1}
255 \ Should Not Contain ${resp.content} openflow:${switch}
257 Stop Mininet Simulation
258 [Documentation] Stop mininet
259 Log To Console Stopping Mininet
260 Switch Connection ${mininet_conn_id}
263 Read Until ${DEFAULT_LINUX_PROMPT}
266 Scalability Suite Teardown