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