6 Library ../variables/Variables.py
7 Library RequestsLibrary
14 [Arguments] ${start} ${stop} ${step}
15 [Documentation] Will find out max switches starting from ${start} till reaching ${stop} and in steps defined by ${step}
16 ${max-switches} Set Variable ${0}
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 \ Start Mininet Linear ${switches}
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'
31 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 10s
32 \ ... Check No Switches ${switches}
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 Topology ${switches}
36 \ Exit For Loop If '${status}' == 'FAIL'
37 \ ${max-switches} Convert To String ${switches}
38 [Return] ${max-switches}
41 [Arguments] ${begin} ${stop} ${step}
42 [Documentation] Will find out max hosts starting from ${begin} till reaching ${stop} and in steps defined by ${step}
43 ${max-hosts} Set Variable ${0}
44 ${stop} Convert to Integer ${stop}
45 ${step} Convert to Integer ${step}
46 : FOR ${hosts} IN RANGE ${begin} ${stop+1} ${step}
47 \ Start Mininet With One Switch And ${hosts} hosts
48 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
49 \ ... Check Every Switch ${1}
50 \ Exit For Loop If '${status}' == 'FAIL'
51 \ @{host_list}= Get Mininet Hosts
52 \ ${status}= Ping All Hosts @{host_list}
53 \ Exit For Loop If ${status} != ${0}
54 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${CONTROLLER}
55 \ Exit For Loop If '${status}' == 'FAIL'
56 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
57 \ ... Check Number Of Hosts ${hosts}
58 \ Exit For Loop If '${status}' == 'FAIL'
60 \ ${status} ${result} Run Keyword And Ignore Error Check No Switches ${1}
61 \ Exit For Loop If '${status}' == 'FAIL'
62 \ ${status} ${result} Run Keyword And Ignore Error Check No Hosts
63 \ Exit For Loop If '${status}' == 'FAIL'
64 \ ${max-hosts} Convert To String ${hosts}
69 [Documentation] Get all the hosts from mininet
70 ${host_list}= Create List
72 ${out}= Read Until mininet>
73 @{words}= Split String ${out} ${SPACE}
74 :FOR ${item} IN @{words}
75 \ ${h}= Get Lines Matching Regexp ${item.rstrip()} .*h[0-9]*s.
76 \ Run Keyword If '${h}' != '${EMPTY}' Append To List ${host_list} ${h}
81 [Arguments] @{host_list}
82 [Documentation] Do one round of ping from one host to all other hosts in mininet
83 ${source}= Get From List ${host_list} ${0}
84 : FOR ${h} IN @{host_list}
85 \ ${status}= Ping Two Hosts ${source} ${h} 1
86 \ Exit For Loop If ${status}!=${0}
91 Start Mininet With One Switch And ${hosts} hosts
92 [Documentation] Start mininet with one switch and ${hosts} hosts
93 Log Starting mininet with one switch and ${hosts} hosts
94 Log To Console Starting mininet with one switch and ${hosts} hosts
95 ${mininet_conn_id}= Open Connection ${MININET} prompt=${linux_prompt} timeout=${hosts*3}
96 Set Suite Variable ${mininet_conn_id}
97 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
98 Write sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,1,${hosts} --switch ovsk,protocols=OpenFlow13
102 Check Number Of Hosts
104 [Documentation] Check number of hosts in inventory
105 ${resp} RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
106 Log Check number of hosts in inventory
107 Log To Console Check number of hosts in inventory
108 Should Be Equal As Strings ${resp.status_code} 200
109 ${count}= Get Count ${resp.content} "node-id":"host:
110 Should Be Equal As Integers ${count} ${hosts}
114 [Arguments] ${host1} ${host2} ${pingcount}=2 ${connection_index}=${EMPTY} ${connection_alias}=${EMPTY}
115 [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.
116 Run Keyword If '${connection_index}' != '${EMPTY}' Switch Connection ${connection_index}
117 Run Keyword If '${connection_alias}' != '${EMPTY}' Switch Connection ${connection_alias}
118 Write ${host1} ping -c ${pingcount} ${host2}
119 ${out}= Read Until mininet>
120 ${ret}= Get Lines Matching Regexp ${out} .*100% packet loss.*
121 ${len}= Get Length ${ret}
125 [Documentation] Check if all hosts are deleted from inventory
126 ${resp} RequestsLibrary.Get session ${OPERATIONAL_TOPO_API}
127 Log To Console Checking no hosts are present in operational database
128 Log Checking no hosts are present in operational database
129 Should Be Equal As Strings ${resp.status_code} 200
130 Should Not Contain ${resp.content} "node-id":"host:
136 [Arguments] ${switches}
137 [Documentation] Start mininet linear topology with ${switches} nodes
138 Log To Console Starting mininet linear ${switches}
139 ${mininet_conn_id}= Open Connection ${MININET} prompt=${linux_prompt} timeout=${switches*3}
140 Set Suite Variable ${mininet_conn_id}
141 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
142 Write sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,${switches} --switch ovsk,protocols=OpenFlow13
147 [Arguments] ${switches}
148 [Documentation] Check all switches and stats in operational inventory
149 : FOR ${switch} IN RANGE 1 ${switches+1}
150 \ ${resp} RequestsLibrary.Get session /restconf/operational/opendaylight-inventory:nodes/node/openflow:${switch}
151 \ Log To Console Checking Switch ${switch}
152 \ Should Be Equal As Strings ${resp.status_code} 200
153 \ Should Contain ${resp.content} flow-capable-node-connector-statistics
154 \ Should Contain ${resp.content} flow-table-statistics
156 Check Linear Topology
157 [Arguments] ${switches}
158 [Documentation] Check Linear topology given ${switches}
159 ${resp} RequestsLibrary.Get session /restconf/operational/network-topology:network-topology/
160 Log To Console Checking Topology
161 Should Be Equal As Strings ${resp.status_code} 200
162 : FOR ${switch} IN RANGE 1 ${switches+1}
163 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
164 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
165 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
166 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
167 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
168 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
169 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
170 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
171 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3"
174 [Arguments] ${switches}
175 [Documentation] Check no switch is in inventory
176 ${resp} RequestsLibrary.Get session /restconf/operational/opendaylight-inventory:nodes
177 Log To Console Checking No Switches
178 Should Be Equal As Strings ${resp.status_code} 200
179 : FOR ${switch} IN RANGE 1 ${switches+1}
180 \ Should Not Contain ${resp.content} openflow:${switch}
183 [Arguments] ${switches}
184 [Documentation] Check no switch is in topology
185 ${resp} RequestsLibrary.Get session /restconf/operational/network-topology:network-topology/
186 Log To Console Checking No Topology
187 Should Be Equal As Strings ${resp.status_code} 200
188 : FOR ${switch} IN RANGE 1 ${switches+1}
189 \ Should Not Contain ${resp.content} openflow:${switch}
192 [Documentation] Stop mininet
193 Log To Console Stopping Mininet
194 Switch Connection ${mininet_conn_id}
197 Read Until ${linux_prompt}
200 Scalability Suite Teardown