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