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