6 Variables ../variables/Variables.py
7 Library RequestsLibrary
8 Library SwitchClasses/BaseSwitch.py
12 [Arguments] ${start} ${stop} ${step}
13 [Documentation] Will find out max switches starting from ${start} till reaching ${stop} and in steps defined by ${step}
14 ${max-switches} Set Variable ${0}
15 ${start} Convert to Integer ${start}
16 ${stop} Convert to Integer ${stop}
17 ${step} Convert to Integer ${step}
18 : FOR ${switches} IN RANGE ${start} ${stop+1} ${step}
19 \ Start Mininet Linear ${switches}
20 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${CONTROLLER}
21 \ Exit For Loop If '${status}' == 'FAIL'
22 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
23 \ ... Check Every Switch ${switches}
24 \ Exit For Loop If '${status}' == 'FAIL'
25 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
26 \ ... Check Linear Topology ${switches}
27 \ Exit For Loop If '${status}' == 'FAIL'
28 \ Stop Mininet Simulation
29 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
30 \ ... Check No Switches ${switches}
31 \ Exit For Loop If '${status}' == 'FAIL'
32 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
33 \ ... Check No Topology ${switches}
34 \ Exit For Loop If '${status}' == 'FAIL'
35 \ ${max-switches} Convert To String ${switches}
36 [Return] ${max-switches}
39 [Arguments] ${begin} ${stop} ${step}
40 [Documentation] Will find out max switches in fully mesh topology starting from ${start} till reaching ${stop} and in steps defined by ${step}
41 ${max_switches} Set Variable ${0}
42 ${stop} Convert to Integer ${stop}
43 ${step} Convert to Integer ${step}
44 : FOR ${switches} IN RANGE ${begin} ${stop+1} ${step}
45 \ Start Mininet With Custom Topology ${CREATE_FULLYMESH_TOPOLOGY_FILE} ${switches} ${BASE_MAC_1} ${BASE_IP_1} ${0} ${switches*20}
46 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${CONTROLLER}
47 \ Exit For Loop If '${status}' == 'FAIL'
48 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Has No Null Pointer Exceptions ${CONTROLLER}
49 \ Exit For Loop If '${status}' == 'FAIL'
50 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
51 \ ... Check Every Switch ${switches} ${BASE_MAC_1}
52 \ Exit For Loop If '${status}' == 'FAIL'
53 \ ${max-links}= Evaluate ${switches}*${switches-1}
54 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
55 \ ... Check Number Of Links ${max-links}
56 \ Exit For Loop If '${status}' == 'FAIL'
57 \ Stop Mininet Simulation
58 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
59 \ ... Check No Switches ${switches}
60 \ Exit For Loop If '${status}' == 'FAIL'
61 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120 10s
62 \ ... Check No Topology ${switches}
63 \ Exit For Loop If '${status}' == 'FAIL'
64 \ ${max_switches} Set Variable ${switches}
65 ${max-links}= Evaluate ${max_switches}*${max_switches-1}
69 [Arguments] ${begin} ${stop} ${step}
70 [Documentation] Will find out max hosts starting from ${begin} till reaching ${stop} and in steps defined by ${step}
71 ${max-hosts} Set Variable ${0}
72 ${stop} Convert to Integer ${stop}
73 ${step} Convert to Integer ${step}
74 : FOR ${hosts} IN RANGE ${begin} ${stop+1} ${step}
75 \ Start Mininet With One Switch And ${hosts} hosts
76 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
77 \ ... Check Every Switch ${1}
78 \ Exit For Loop If '${status}' == 'FAIL'
79 \ @{host_list}= Get Mininet Hosts
80 \ ${status}= Ping All Hosts @{host_list}
81 \ Exit For Loop If ${status} != ${0}
82 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${CONTROLLER}
83 \ Exit For Loop If '${status}' == 'FAIL'
84 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
85 \ ... Check Number Of Hosts ${hosts}
86 \ Exit For Loop If '${status}' == 'FAIL'
87 \ Stop Mininet Simulation
88 \ ${status} ${result} Run Keyword And Ignore Error Check No Switches ${1}
89 \ Exit For Loop If '${status}' == 'FAIL'
90 \ ${status} ${result} Run Keyword And Ignore Error Check No Hosts
91 \ Exit For Loop If '${status}' == 'FAIL'
92 \ ${max-hosts} Convert To String ${hosts}
96 [Documentation] Get all the hosts from mininet
97 ${host_list}= Create List
99 ${out}= Read Until mininet>
100 @{words}= Split String ${out} ${SPACE}
101 :FOR ${item} IN @{words}
102 \ ${h}= Get Lines Matching Regexp ${item.rstrip()} .*h[0-9]*s.
103 \ Run Keyword If '${h}' != '${EMPTY}' Append To List ${host_list} ${h}
104 [Return] ${host_list}
107 [Arguments] @{host_list}
108 [Documentation] Do one round of ping from one host to all other hosts in mininet
109 ${source}= Get From List ${host_list} ${0}
110 : FOR ${h} IN @{host_list}
111 \ ${status}= Ping Two Hosts ${source} ${h} 1
112 \ Exit For Loop If ${status}!=${0}
115 Start Mininet With One Switch And ${hosts} hosts
116 [Documentation] Start mininet with one switch and ${hosts} hosts
117 Log Starting mininet with one switch and ${hosts} hosts
118 Log To Console Starting mininet with one switch and ${hosts} hosts
119 ${mininet_conn_id}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=${hosts*3}
120 Set Suite Variable ${mininet_conn_id}
121 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
122 Write sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,1,${hosts} --switch ovsk,protocols=OpenFlow13
125 Check Number Of Hosts
127 [Documentation] Check number of hosts in inventory
128 ${resp}= RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
129 Log Check number of hosts in inventory
130 Log To Console Check number of hosts in inventory
131 Should Be Equal As Strings ${resp.status_code} 200
132 ${count}= Get Count ${resp.content} "node-id":"host:
133 Should Be Equal As Integers ${count} ${hosts}
135 Check Number Of Links
137 [Documentation] Check number of links in inventory is ${links}
138 ${resp}= RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
139 Log Check number of links in inventory is ${links}
140 Log To Console Check number of links in inventory is ${links}
141 Should Be Equal As Strings ${resp.status_code} 200
142 ${count}= Get Count ${resp.content} "link-id":"openflow:
143 Should Be Equal As Integers ${count} ${links}
146 [Arguments] ${host1} ${host2} ${pingcount}=2 ${connection_index}=${EMPTY} ${connection_alias}=${EMPTY}
147 [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.
148 Run Keyword If '${connection_index}' != '${EMPTY}' Switch Connection ${connection_index}
149 Run Keyword If '${connection_alias}' != '${EMPTY}' Switch Connection ${connection_alias}
150 Write ${host1} ping -c ${pingcount} ${host2}
151 ${out}= Read Until mininet>
152 ${ret}= Get Lines Matching Regexp ${out} .*100% packet loss.*
153 ${len}= Get Length ${ret}
157 [Documentation] Check if all hosts are deleted from inventory
158 ${resp}= RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
159 Log To Console Checking no hosts are present in operational database
160 Log Checking no hosts are present in operational database
161 Should Be Equal As Strings ${resp.status_code} 200
162 Should Not Contain ${resp.content} "node-id":"host:
165 [Arguments] ${switches}
166 [Documentation] Start mininet linear topology with ${switches} nodes
167 Log To Console Starting mininet linear ${switches}
168 ${mininet_conn_id}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=${switches*3}
169 Set Suite Variable ${mininet_conn_id}
170 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
171 Write sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,${switches} --switch ovsk,protocols=OpenFlow13
175 Start Mininet With Custom Topology
176 [Arguments] ${topology_file} ${switches} ${base_mac}=00:00:00:00:00:00 ${base_ip}=1.1.1.1 ${hosts}=0 ${mininet_start_time}=100
177 [Documentation] Start a custom mininet topology.
178 Log To Console Start a custom mininet topology with ${switches} nodes
179 ${mininet_conn_id}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=${mininet_start_time}
180 Set Suite Variable ${mininet_conn_id}
181 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
182 Write python ${topology_file} ${switches} ${hosts} ${base_mac} ${base_ip}
183 Read Until ${DEFAULT_LINUX_PROMPT}
184 Write sudo mn --controller=remote,ip=${CONTROLLER} --custom switch.py --topo demotopo --switch ovsk,protocols=OpenFlow13
186 Write sh ovs-vsctl show
187 ${output}= Read Until mininet>
188 # Ovsdb connection is sometimes lost after mininet is started. Checking if the connection is alive before proceeding.
189 Should Not Contain ${output} database connection failed
190 Log To Console Mininet Started with ${switches} nodes
193 [Arguments] ${switches} ${base_mac}=00:00:00:00:00:00
194 [Documentation] Check all switches and stats in operational inventory
195 ${mac}= Replace String Using Regexp ${base_mac} : ${EMPTY}
196 ${mac}= Convert Hex To Decimal As String ${mac}
197 ${mac}= Convert To Integer ${mac}
198 : FOR ${switch} IN RANGE 1 ${switches+1}
199 \ ${dpid_decimal}= Evaluate ${mac}+${switch}
200 \ ${resp} RequestsLibrary.Get session ${OPERATIONAL_NODES_API}/node/openflow:${dpid_decimal}
201 \ Should Be Equal As Strings ${resp.status_code} 200
202 \ Log To Console Checking Switch ${switch}
203 \ Should Contain ${resp.content} flow-capable-node-connector-statistics
204 \ Should Contain ${resp.content} flow-table-statistics
206 Check Linear Topology
207 [Arguments] ${switches}
208 [Documentation] Check Linear topology given ${switches}
209 ${resp} RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
210 Log To Console Checking Topology
211 Should Be Equal As Strings ${resp.status_code} 200
212 : FOR ${switch} IN RANGE 1 ${switches+1}
213 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
214 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
215 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
216 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
217 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
218 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
219 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
220 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
221 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3"
224 [Arguments] ${switches}
225 [Documentation] Check no switch is in inventory
226 ${resp} RequestsLibrary.Get session ${OPERATIONAL_NODES_API}
227 Log To Console Checking No Switches
228 Should Be Equal As Strings ${resp.status_code} 200
229 : FOR ${switch} IN RANGE 1 ${switches+1}
230 \ Should Not Contain ${resp.content} openflow:${switch}
233 [Arguments] ${switches}
234 [Documentation] Check no switch is in topology
235 ${resp} RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
236 Log To Console Checking No Topology
237 Should Be Equal As Strings ${resp.status_code} 200
238 : FOR ${switch} IN RANGE 1 ${switches+1}
239 \ Should Not Contain ${resp.content} openflow:${switch}
241 Stop Mininet Simulation
242 [Documentation] Stop mininet
243 Log To Console Stopping Mininet
244 Switch Connection ${mininet_conn_id}
247 Read Until ${DEFAULT_LINUX_PROMPT}
250 Scalability Suite Teardown