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