Correctly space expected_status
[integration/test.git] / csit / suites / openflowplugin / Performance_Flow_Config / 070_Stats_Collection_100k_WithMininetRestart.robot
1 *** Settings ***
2 Documentation       Suite checks if StatMngr is able to collect flows correctly
3
4 Library             OperatingSystem
5 Library             XML
6 Library             SSHLibrary
7 Library             Collections
8 Variables           ../../../variables/Variables.py
9 Library             RequestsLibrary
10 Library             ../../../libraries/Common.py
11 Library             ../../../libraries/ScaleClient.py
12 Resource            ../../../libraries/WaitForFailure.robot
13 Resource            ../../../variables/openflowplugin/Variables.robot
14
15 Suite Setup         Create Http Session And Upload Files
16 Suite Teardown      Delete Http Session And Store Plot Data
17
18
19 *** Variables ***
20 ${swnr}             32
21 ${flnr}             100000
22 ${fpr}              200
23 ${nrthreads}        5
24 ${swspread}         linear
25 ${tabspread}        first
26 @{cntls}            ${ODL_SYSTEM_IP}
27 ${start_cmd}
28 ...                 sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo linear,${swnr} --switch ovsk,protocols=OpenFlow13
29 ${getf_cmd}         sh ./get-total-found.sh
30 ${getr_cmd}         sh ./get-total-reported.sh
31 ${iperiod}          1s
32 ${imonitor}         60s
33 ${ichange}          450s
34 ${ratefile}         stats_rate.csv
35 ${timefile}         stats_time.csv
36 ${setuptime}        0
37 ${inittime}         0
38 ${restarttime}      0
39
40
41 *** Test Cases ***
42 Connect Mininet
43     Connect Switches
44
45 Configure Flows
46     [Documentation]    Configuration of ${flnr} flows into config datastore
47     ${flows}    ${notes}=    Generate New Flow Details
48     ...    flows=${flnr}
49     ...    switches=${swnr}
50     ...    swspread=${swspread}
51     ...    tabspread=${tabspread}
52     Log    ${notes}
53     ${starttime}=    Get Time    epoch
54     ${res}=    Configure Flows Bulk
55     ...    flow_details=${flows}
56     ...    controllers=@{cntls}
57     ...    nrthreads=${nrthreads}
58     ...    fpr=${fpr}
59     Log    ${res}
60     Set Suite Variable    ${flows}
61     ${http201ok}=    Create List    ${201}
62     ${validation}=    Validate Responses    ${res}    ${http201ok}
63     Should Be True    ${validation}
64     [Teardown]    Save Setup Time    setuptime    ${starttime}
65
66 Wait Stats Collected
67     [Documentation]    Waits till ${flnr} flows are initially collected
68     Measure Setup Time    ${swnr}    ${flnr}    inittime
69     [Teardown]    Log Switch Details
70
71 Stable State Monitoring
72     [Documentation]    Inventory check if all ${flnr} flows are present for specified time frame
73     Monitor Stable State    ${swnr}    ${flnr}
74     [Teardown]    Log Switch Details
75
76 Stop Mininet
77     [Documentation]    Disconnect/Stop mininet
78     Stop Switches
79
80 Check No Flows In Operational After Disconnect
81     [Documentation]    With mininet stopped no switches in operational datastore sould be found
82     Inventory Change Reached    0    0
83
84 Connect Mininet Again
85     [Documentation]    Reconnection of the mininet
86     Connect Switches
87
88 Check Flows Are Operational Again
89     [Documentation]    All ${flnr} slows should be present in the operational datastore after mininet reconnection
90     Measure Setup Time    ${swnr}    ${flnr}    restarttime
91     [Teardown]    Log Switch Details
92
93 Deconfigure Flows
94     [Documentation]    Flows deconfiguration
95     ${resp}=    Delete Request    session    ${RFC8040_NODES_API}
96     Should Be Equal As Numbers    ${resp.status_code}    204
97
98 Check No Flows In Operational Last
99     [Documentation]    Operational datastore to be without any flows
100     Inventory Change Reached    ${swnr}    0
101     [Teardown]    Log Switch Details
102
103 Stop Mininet End
104     Stop Switches
105
106
107 *** Keywords ***
108 Connect Switches
109     [Documentation]    Starts mininet with requested number of switches (${swnr})
110     Log    Starting mininet with ${swnr} switches
111     Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}    timeout=600
112     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
113     Execute Command    sudo ovs-vsctl set-manager ptcp:6644
114     Execute Command    sudo mn -c
115     Write    ${start_cmd}
116     Read Until    mininet>
117     Comment    Below line disables switch echos
118     Write
119     ...    sh x=`sudo ovs-vsctl --columns=_uuid list Controller | awk '{print $NF}'`; for i in $x; do sudo ovs-vsctl set Controller $i inactivity_probe=0; done
120     Read Until    mininet>
121     Wait Until Keyword Succeeds    20s    1s    Are Switches Connected Topo
122
123 Create Http Session And Upload Files
124     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
125     Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}    timeout=600
126     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
127     Put File    ${CURDIR}/../../../../tools/odl-mdsal-clustering-tests/clustering-performance-test/ovs-scripts/*    ./
128     Close Connection
129
130 Stop Switches
131     [Documentation]    Stops mininet
132     Log    Stopping mininet
133     Read
134     Write    exit
135     Read Until    ${TOOLS_SYSTEM_PROMPT}
136     Close Connection
137
138 Delete Http Session And Store Plot Data
139     Delete All Sessions
140     ${initrate}=    Evaluate    (${flnr}/${inittime})
141     ${restartrate}=    Evaluate    (${flnr}/${restarttime})
142     Append To File    ${ratefile}    Initial,AfterMininetRestart\n
143     Append To File    ${ratefile}    ${initrate},${restartrate}\n
144     Append To File    ${timefile}    Initial,AfterMininetRestart\n
145     Append To File    ${timefile}    ${inittime},${restarttime}\n
146
147 Are Switches Connected Topo
148     [Documentation]    Checks wheather switches are connected to controller
149     ${resp}=    Get Request    session    ${RFC8040_OPERATIONAL_TOPO_FLOW1_API}    headers=${ACCEPT_XML}
150     Log    ${resp.content}
151     ${count}=    Get Element Count    ${resp.content}    xpath=node
152     Should Be Equal As Numbers    ${count}    ${swnr}
153
154 Check Flows Inventory
155     [Documentation]    Checks in inventory has required state
156     [Arguments]    ${rswitches}    ${rflows}
157     ${sw}    ${repf}    ${foundf}=    Flow Stats Collected    controller=${ODL_SYSTEM_IP}
158     Should Be Equal As Numbers    ${rswitches}    ${sw}
159     Should Be Equal As Numbers    ${rflows}    ${foundf}
160
161 Measure Setup Time
162     [Documentation]    This keyword is dedicated to save measured time for plotting
163     [Arguments]    ${rswitches}    ${rflows}    ${note}
164     ${starttime}=    Get Time    epoch
165     Log    Starting stats collection at time ${starttime}
166     Inventory Change Reached    ${rswitches}    ${rflows}
167     [Teardown]    Save Setup Time    ${note}    ${starttime}
168
169 Save Setup Time
170     [Documentation]    Count the difference and stores it
171     [Arguments]    ${note}    ${starttime}
172     ${endtime}=    Get Time    epoch
173     Log    Stats collection finished at time ${endtime}
174     ${res}=    Evaluate    int(${endtime})-int(${starttime})
175     ${inittime}=    Set Variable If    "${note}"=="inittime"    ${res}    ${inittime}
176     ${restarttime}=    Set Variable If    "${note}"=="restarttime"    ${res}    ${restarttime}
177     ${setuptime}=    Set Variable If    "${note}"=="setuptime"    ${res}    ${setuptime}
178     Set Suite Variable    ${inittime}
179     Set Suite Variable    ${restarttime}
180     Set Suite Variable    ${setuptime}
181
182 Inventory Change Reached
183     [Documentation]    This keywordwaits till inventory reaches required state
184     [Arguments]    ${rswitches}    ${rflows}
185     Wait Until Keyword Succeeds    ${ichange}    ${iperiod}    Check Flows Inventory    ${rswitches}    ${rflows}
186
187 Monitor Stable State
188     [Documentation]    This keywordwaits till inventory reaches required state
189     [Arguments]    ${rswitches}    ${rflows}
190     Verify Keyword Does Not Fail Within Timeout
191     ...    ${imonitor}
192     ...    ${iperiod}
193     ...    Check Flows Inventory
194     ...    ${rswitches}
195     ...    ${rflows}
196
197 Log Switch Details
198     Write    ${getf_cmd}
199     ${log}=    Read Until    mininet>
200     Log    ${log}
201     Write    ${getr_cmd}
202     ${log}=    Read Until    mininet>
203     Log    ${log}