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