Fix up PrefixCounting warning
[integration/test.git] / csit / libraries / WorkflowsL2switch.robot
1 *** Settings ***
2 Documentation       Resource for L2switch workflows. TODO: Refactor KWs once this test works in public.
3
4 Library             RequestsLibrary
5 Resource            Utils.robot
6 Resource            FlowLib.robot
7 Resource            MininetKeywords.robot
8 Resource            ../variables/Variables.robot
9
10
11 *** Variables ***
12 ${log_level}    ERROR
13
14
15 *** Keywords ***
16 Workflow Single Switch Multiple Hosts
17     [Documentation]    Workflow to bring a Linear topology of ${switches} switches, push flows, hold for ${sustain_time} seconds, delete flows and stop topology.
18     ...    This KW returns workflow state (PASS/FAIL), error message and topology discover time.
19     [Arguments]    ${hosts}    ${sustain_time}=0
20     # Define required variables
21     ${error_message}    BuiltIn.Set Variable    Test has completed
22     ${host_discover_time}    BuiltIn.Set Variable    ${0}
23     # Workflow starts
24     BuiltIn.Log to console    ${\n}
25     BuiltIn.Log To Console    Starting mininet with one switch and ${hosts} hosts
26     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
27     ...    MininetKeywords.Start Mininet Multiple Hosts
28     ...    ${hosts}
29     ...    mininet_timeout=${hosts}
30     IF    '${status}' == 'FAIL'
31         RETURN    ${status}    Fail starting mininet    ${host_discover_time}
32     END
33     BuiltIn.Log To Console    Check 1 switch
34     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
35     ...    Wait Until Keyword Succeeds
36     ...    ${hosts}
37     ...    2s
38     ...    FlowLib.Check Switches In Inventory
39     ...    ${1}
40     IF    '${status}' == 'FAIL'
41         RETURN    ${status}    Fail checking switch    ${host_discover_time}
42     END
43     BuiltIn.Log To Console    Ping all hosts
44     @{host_list}    MininetKeywords.Get Mininet Hosts
45     ${start_time}    DateTime.Get Current Date    result_format=timestamp
46     ${status}    MininetKeywords.Ping All Hosts    @{host_list}
47     IF    ${status} != ${0}
48         RETURN    ${status}    Ping test fails    ${host_discover_time}
49     END
50     BuiltIn.Log To Console    Verify controller is OK
51     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
52     ...    Utils.Verify Controller Is Not Dead
53     ...    ${ODL_SYSTEM_IP}
54     IF    '${status}' == 'FAIL'
55         RETURN    ${status}    Controller is dead    ${host_discover_time}
56     END
57     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
58     ...    Utils.Verify Controller Has No Null Pointer Exceptions
59     ...    ${ODL_SYSTEM_IP}
60     IF    '${status}' == 'FAIL'
61         RETURN    ${status}    Controller has NPE    ${host_discover_time}
62     END
63     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
64     ...    Utils.Verify Controller Has No Runtime Exceptions
65     ...    ${ODL_SYSTEM_IP}
66     IF    '${status}' == 'FAIL'
67         RETURN    ${status}    Controller has RuntimeException    ${topology_discover_time}
68     END
69     Log To Console    Check number of hosts in topology is ${hosts}
70     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
71     ...    Wait Until Keyword Succeeds
72     ...    ${hosts}
73     ...    2s
74     ...    FlowLib.Check Number Of Hosts
75     ...    ${hosts}
76     IF    '${status}' == 'FAIL'
77         RETURN    ${status}    Fail checking hosts    ${host_discover_time}
78     END
79     ${end_time}    DateTime.Get Current Date    result_format=timestamp
80     ${host_discover_time}    DateTime.Subtract Date From Date    ${end_time}    ${start_time}
81     BuiltIn.Log To Console    Host Discovery Time = ${host_discover_time} seconds
82     BuiltIn.Log To Console    Sleep for ${sustain_time} seconds
83     BuiltIn.Sleep    ${sustain_time}
84     BuiltIn.Log To Console    Stopping Mininet
85     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error    MininetKeywords.Stop Mininet And Exit
86     IF    '${status}' == 'FAIL'
87         RETURN
88         ...    ${status}
89         ...    Fail stopping mininet
90         ...    ${host_discover_time}
91     END
92     BuiltIn.Log To Console    Checking No Switches
93     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
94     ...    Wait Until Keyword Succeeds
95     ...    5s
96     ...    1s
97     ...    FlowLib.Check No Switches In Inventory
98     ...    ${1}
99     IF    '${status}' == 'FAIL'
100         RETURN    ${status}    Fail checking no switch    ${host_discover_time}
101     END
102     BuiltIn.Log To Console    Checking no hosts are present in operational database
103     ${status}    ${result}    BuiltIn.Run Keyword And Ignore Error
104     ...    Wait Until Keyword Succeeds
105     ...    5s
106     ...    1s
107     ...    FlowLib.Check No Hosts
108     IF    '${status}' == 'FAIL'
109         RETURN    ${status}    Hosts are present    ${host_discover_time}
110     END
111     ${max-hosts}    BuiltIn.Convert To String    ${hosts}
112     RETURN    PASS    ${error_message}    ${host_discover_time}
113
114 Workflow Setup
115     RequestsLibrary.Create Session
116     ...    session
117     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
118     ...    auth=${AUTH}
119     ...    headers=${HEADERS_XML}
120     BuiltIn.Wait Until Keyword Succeeds
121     ...    3x
122     ...    1s
123     ...    KarafKeywords.Issue Command On Karaf Console
124     ...    log:set ${log_level}
125
126 Workflow Teardown
127     [Documentation]    Cleanup when workflow is interrupt
128     Utils.Clean Mininet System
129     RequestsLibrary.Delete All Sessions