2 Documentation Resource for L2switch workflows. TODO: Refactor KWs once this test works in public.
3 Library RequestsLibrary
6 Resource MininetKeywords.robot
7 Resource ../variables/Variables.robot
10 Workflow Single Switch Multiple Hosts
11 [Arguments] ${hosts} ${sustain_time}=0
12 [Documentation] Workflow to bring a Linear topology of ${switches} switches, push flows, hold for ${sustain_time} seconds, delete flows and stop topology.
13 ... This KW returns workflow state (PASS/FAIL), error message and topology discover time.
14 # Define required variables
15 ${error_message}= BuiltIn.Set Variable Test has completed
16 ${host_discover_time}= BuiltIn.Set Variable ${0}
18 BuiltIn.Log to console ${\n}
19 BuiltIn.Log To Console Starting mininet with one switch and ${hosts} hosts
20 ${status} ${result} BuiltIn.Run Keyword And Ignore Error MininetKeywords.Start Mininet Multiple Hosts ${hosts} mininet_timeout=${hosts}
21 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Fail starting mininet ${host_discover_time}
22 BuiltIn.Log To Console Check 1 switch
23 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Wait Until Keyword Succeeds ${hosts} 2s FlowLib.Check Switches In Inventory
25 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking switch ${host_discover_time}
26 BuiltIn.Log To Console Ping all hosts
27 @{host_list}= MininetKeywords.Get Mininet Hosts
28 ${start_time}= DateTime.Get Current Date result_format=timestamp
29 ${status}= MininetKeywords.Ping All Hosts @{host_list}
30 BuiltIn.Return From Keyword If ${status} != ${0} ${status} Ping test fails ${host_discover_time}
31 BuiltIn.Log To Console Verify controller is OK
32 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Utils.Verify Controller Is Not Dead ${ODL_SYSTEM_IP}
33 Return From Keyword If '${status}' == 'FAIL' ${status} Controller is dead ${host_discover_time}
34 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Utils.Verify Controller Has No Null Pointer Exceptions ${ODL_SYSTEM_IP}
35 Return From Keyword If '${status}' == 'FAIL' ${status} Controller has NPE ${host_discover_time}
36 Log To Console Check number of hosts in topology is ${hosts}
37 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Wait Until Keyword Succeeds ${hosts} 2s FlowLib.Check Number Of Hosts
39 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking hosts ${host_discover_time}
40 ${end_time}= DateTime.Get Current Date result_format=timestamp
41 ${host_discover_time}= DateTime.Subtract Date From Date ${end_time} ${start_time}
42 BuiltIn.Log To Console Host Discovery Time = ${host_discover_time} seconds
43 BuiltIn.Log To Console Sleep for ${sustain_time} seconds
44 BuiltIn.Sleep ${sustain_time}
45 BuiltIn.Log To Console Stopping Mininet
46 ${status} ${result} BuiltIn.Run Keyword And Ignore Error MininetKeywords.Stop Mininet And Exit
47 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Fail stopping mininet ${host_discover_time}
48 BuiltIn.Log To Console Checking No Switches
49 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Wait Until Keyword Succeeds 5s 1s FlowLib.Check No Switches In Inventory
51 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Fail checking no switch ${host_discover_time}
52 BuiltIn.Log To Console Checking no hosts are present in operational database
53 ${status} ${result} BuiltIn.Run Keyword And Ignore Error Wait Until Keyword Succeeds 5s 1s FlowLib.Check No Hosts
54 BuiltIn.Return From Keyword If '${status}' == 'FAIL' ${status} Hosts are present ${host_discover_time}
55 ${max-hosts} BuiltIn.Convert To String ${hosts}
56 [Return] PASS ${error_message} ${host_discover_time}
59 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
60 BuiltIn.Wait Until Keyword Succeeds 3x 1s KarafKeywords.Issue Command On Karaf Console log:set ERROR
63 [Documentation] Cleanup when workflow is interrupt
64 Utils.Clean Mininet System
65 RequestsLibrary.Delete All Sessions