Migrate Get Requests invocations(libraries)
[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 On Session    session    url=${RFC8040_NODES_API}    expected_status=204
96
97 Check No Flows In Operational Last
98     [Documentation]    Operational datastore to be without any flows
99     Inventory Change Reached    ${swnr}    0
100     [Teardown]    Log Switch Details
101
102 Stop Mininet End
103     Stop Switches
104
105
106 *** Keywords ***
107 Connect Switches
108     [Documentation]    Starts mininet with requested number of switches (${swnr})
109     Log    Starting mininet with ${swnr} switches
110     Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}    timeout=600
111     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
112     Execute Command    sudo ovs-vsctl set-manager ptcp:6644
113     Execute Command    sudo mn -c
114     Write    ${start_cmd}
115     Read Until    mininet>
116     Comment    Below line disables switch echos
117     Write
118     ...    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
119     Read Until    mininet>
120     Wait Until Keyword Succeeds    20s    1s    Are Switches Connected Topo
121
122 Create Http Session And Upload Files
123     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
124     Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}    timeout=600
125     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
126     Put File    ${CURDIR}/../../../../tools/odl-mdsal-clustering-tests/clustering-performance-test/ovs-scripts/*    ./
127     Close Connection
128
129 Stop Switches
130     [Documentation]    Stops mininet
131     Log    Stopping mininet
132     Read
133     Write    exit
134     Read Until    ${TOOLS_SYSTEM_PROMPT}
135     Close Connection
136
137 Delete Http Session And Store Plot Data
138     Delete All Sessions
139     ${initrate}=    Evaluate    (${flnr}/${inittime})
140     ${restartrate}=    Evaluate    (${flnr}/${restarttime})
141     Append To File    ${ratefile}    Initial,AfterMininetRestart\n
142     Append To File    ${ratefile}    ${initrate},${restartrate}\n
143     Append To File    ${timefile}    Initial,AfterMininetRestart\n
144     Append To File    ${timefile}    ${inittime},${restarttime}\n
145
146 Are Switches Connected Topo
147     [Documentation]    Checks wheather switches are connected to controller
148     ${resp}=    GET On Session    session    url=${RFC8040_OPERATIONAL_TOPO_FLOW1_API}    headers=${ACCEPT_XML}
149     Log    ${resp.content}
150     ${count}=    Get Element Count    ${resp.content}    xpath=node
151     Should Be Equal As Numbers    ${count}    ${swnr}
152
153 Check Flows Inventory
154     [Documentation]    Checks in inventory has required state
155     [Arguments]    ${rswitches}    ${rflows}
156     ${sw}    ${repf}    ${foundf}=    Flow Stats Collected    controller=${ODL_SYSTEM_IP}
157     Should Be Equal As Numbers    ${rswitches}    ${sw}
158     Should Be Equal As Numbers    ${rflows}    ${foundf}
159
160 Measure Setup Time
161     [Documentation]    This keyword is dedicated to save measured time for plotting
162     [Arguments]    ${rswitches}    ${rflows}    ${note}
163     ${starttime}=    Get Time    epoch
164     Log    Starting stats collection at time ${starttime}
165     Inventory Change Reached    ${rswitches}    ${rflows}
166     [Teardown]    Save Setup Time    ${note}    ${starttime}
167
168 Save Setup Time
169     [Documentation]    Count the difference and stores it
170     [Arguments]    ${note}    ${starttime}
171     ${endtime}=    Get Time    epoch
172     Log    Stats collection finished at time ${endtime}
173     ${res}=    Evaluate    int(${endtime})-int(${starttime})
174     ${inittime}=    Set Variable If    "${note}"=="inittime"    ${res}    ${inittime}
175     ${restarttime}=    Set Variable If    "${note}"=="restarttime"    ${res}    ${restarttime}
176     ${setuptime}=    Set Variable If    "${note}"=="setuptime"    ${res}    ${setuptime}
177     Set Suite Variable    ${inittime}
178     Set Suite Variable    ${restarttime}
179     Set Suite Variable    ${setuptime}
180
181 Inventory Change Reached
182     [Documentation]    This keywordwaits till inventory reaches required state
183     [Arguments]    ${rswitches}    ${rflows}
184     Wait Until Keyword Succeeds    ${ichange}    ${iperiod}    Check Flows Inventory    ${rswitches}    ${rflows}
185
186 Monitor Stable State
187     [Documentation]    This keywordwaits till inventory reaches required state
188     [Arguments]    ${rswitches}    ${rflows}
189     Verify Keyword Does Not Fail Within Timeout
190     ...    ${imonitor}
191     ...    ${iperiod}
192     ...    Check Flows Inventory
193     ...    ${rswitches}
194     ...    ${rflows}
195
196 Log Switch Details
197     Write    ${getf_cmd}
198     ${log}=    Read Until    mininet>
199     Log    ${log}
200     Write    ${getr_cmd}
201     ${log}=    Read Until    mininet>
202     Log    ${log}