2 Documentation Resource for L2switch workflows. TODO: Refactor KWs once this test works in public.
4 Library RequestsLibrary
7 Library SwitchClasses/BaseSwitch.py
9 Variables ../variables/Variables.py
13 [Arguments] ${begin} ${stop} ${step} ${sustain_time}=0
14 [Documentation] Will find out max hosts starting from ${begin} till reaching ${stop} and in steps defined by ${step}.
15 ... The network is hold for ${sustain_time} seconds after everything is checked successful.
16 ${max-hosts} Set Variable ${0}
17 ${stop} Convert to Integer ${stop}
18 ${step} Convert to Integer ${step}
19 : FOR ${hosts} IN RANGE ${begin} ${stop+1} ${step}
20 \ Log To Console Starting mininet with one switch and ${hosts} hosts
21 \ ${status} ${result} Run Keyword And Ignore Error Start Mininet With One Switch And ${hosts} hosts
22 \ Exit For Loop If '${status}' == 'FAIL'
23 \ Log To Console Checking ${switches} switches
24 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
25 \ ... Check Every Switch ${1}
26 \ Exit For Loop If '${status}' == 'FAIL'
27 \ Log To Console Ping all hosts
28 \ @{host_list}= Get Mininet Hosts
29 \ ${status}= Ping All Hosts @{host_list}
30 \ Exit For Loop If ${status} != ${0}
31 \ Log To Console Verify controller is OK
32 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
33 \ Exit For Loop If '${status}' == 'FAIL'
34 \ ${status} ${result} Run Keyword And Ignore Error Verify Controller Has No Null Pointer Exceptions ${ODL_SYSTEM_IP}
35 \ Exit For Loop If '${status}' == 'FAIL'
36 \ Log To Console Check number of hosts in inventory is ${hosts}
37 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 30s
38 \ ... Check Number Of Hosts ${hosts}
39 \ Exit For Loop If '${status}' == 'FAIL'
40 \ Log To Console Sleep for ${sustain_time} seconds
41 \ Sleep ${sustain_time}
42 \ Log To Console Stopping Mininet
43 \ ${status} ${result} Run Keyword And Ignore Error Stop Mininet Simulation
44 \ Exit For Loop If '${status}' == 'FAIL'
45 \ Log To Console Checking No Switches
46 \ ${status} ${result} Run Keyword And Ignore Error Check No Switches
47 \ Exit For Loop If '${status}' == 'FAIL'
48 \ Log To Console Checking no hosts are present in operational database
49 \ ${status} ${result} Run Keyword And Ignore Error Check No Hosts
50 \ Exit For Loop If '${status}' == 'FAIL'
51 \ ${max-hosts} Convert To String ${hosts}
55 [Documentation] Get all the hosts from mininet
56 ${host_list}= Create List
58 ${out}= Read Until mininet>
59 @{words}= Split String ${out} ${SPACE}
60 : FOR ${item} IN @{words}
61 \ ${h}= Get Lines Matching Regexp ${item.rstrip()} .*h[0-9]*s.
62 \ Run Keyword If '${h}' != '${EMPTY}' Append To List ${host_list} ${h}
66 [Arguments] @{host_list}
67 [Documentation] Do one round of ping from one host to all other hosts in mininet
68 ${source}= Get From List ${host_list} ${0}
69 : FOR ${h} IN @{host_list}
70 \ ${status}= Ping Two Hosts ${source} ${h} 1
71 \ Exit For Loop If ${status}!=${0}
74 Start Mininet With One Switch And ${hosts} hosts
75 [Documentation] Start mininet with one switch and ${hosts} hosts
76 Log Starting mininet with one switch and ${hosts} hosts
77 ${mininet_conn_id}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=${hosts*3}
78 Set Suite Variable ${mininet_conn_id}
79 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
80 Write sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo linear,1,${hosts} --switch ovsk,protocols=OpenFlow13
85 [Documentation] Check number of hosts in inventory
86 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
87 Log Check number of hosts in inventory is ${hosts}
88 Should Be Equal As Strings ${resp.status_code} 200
89 ${count}= Get Count ${resp.content} "node-id":"host:
90 Should Be Equal As Integers ${count} ${hosts}
93 [Arguments] ${host1} ${host2} ${pingcount}=2 ${connection_index}=${EMPTY} ${connection_alias}=${EMPTY}
94 [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.
95 Run Keyword If '${connection_index}' != '${EMPTY}' Switch Connection ${connection_index}
96 Run Keyword If '${connection_alias}' != '${EMPTY}' Switch Connection ${connection_alias}
97 Write ${host1} ping -c ${pingcount} ${host2}
98 ${out}= Read Until mininet>
99 ${ret}= Get Lines Matching Regexp ${out} .*100% packet loss.*
100 ${len}= Get Length ${ret}
104 [Documentation] Check if all hosts are deleted from inventory
105 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
106 Log Checking no hosts are present in operational database
107 Should Be Equal As Strings ${resp.status_code} 200
108 Should Not Contain ${resp.content} "node-id":"host:
111 [Arguments] ${switches}
112 [Documentation] Check no switch is in inventory
113 ${resp} RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}
114 Should Be Equal As Strings ${resp.status_code} 200
115 : FOR ${switch} IN RANGE 1 ${switches+1}
116 \ Should Not Contain ${resp.content} "openflow:${switch}"
118 Stop Mininet Simulation
119 [Documentation] Stop mininet
120 Switch Connection ${mininet_conn_id}
123 Read Until ${DEFAULT_LINUX_PROMPT}
126 Scalability Suite Teardown
127 Run Keyword And Ignore Error RequestsLibrary.Delete Request session ${CONFIG_NODES_API}