Fix car-people performance test
[integration/test.git] / csit / suites / controller / OneNode_Datastore / 010_crud_mdsal_perf.robot
1 *** Settings ***
2 Documentation     Test for measuring execution time of MD-SAL DataStore operations.
3 ...
4 ...               Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This test suite requires odl-restconf and odl-clustering-test-app modules.
11 ...               The script cluster_rest_script.py is used for generating requests for
12 ...               operations on people, car and car-people DataStore test models.
13 ...               (see the https://wiki.opendaylight.org/view/MD-SAL_Clustering_Test_Plan)
14 ...
15 ...               Reported bugs:
16 ...               https://bugs.opendaylight.org/show_bug.cgi?id=4220
17 Suite Setup       Start Suite
18 Suite Teardown    Stop Suite
19 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Library           RequestsLibrary
21 Library           SSHLibrary
22 Library           XML
23 Variables         ../../../variables/Variables.py
24 Resource          ../../../libraries/Utils.robot
25 Resource          ../../../libraries/SetupUtils.robot
26
27 *** Variables ***
28 ${ITEM_COUNT}     ${10000}
29 ${ITEM_BATCH}     ${10000}
30 ${PROCEDURE_TIMEOUT}    5m
31 ${addcarcmd}      python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add --itemtype car --itemcount ${ITEM_COUNT} --ipr ${ITEM_BATCH}
32 ${addpeoplecmd}    python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add-rpc --itemtype people --itemcount ${ITEM_COUNT} --threads 5
33 ${purchasecmd}    python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add-rpc --itemtype car-people --itemcount ${ITEM_COUNT} --threads 5
34 ${carurl}         /restconf/config/car:cars
35 ${peopleurl}      /restconf/config/people:people
36 ${carpeopleurl}    /restconf/config/car-people:car-people
37 ${CONTROLLER_LOG_LEVEL}    INFO
38 ${TOOL_OPTIONS}    ${EMPTY}
39
40 *** Test Cases ***
41 Add Cars
42     [Documentation]    Request to add ${ITEM_COUNT} cars (timeout in ${PROCEDURE_TIMEOUT}).
43     Start Tool    ${addcarcmd}    ${TOOL_OPTIONS}
44     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
45
46 Verify Cars
47     [Documentation]    Store logs and verify result
48     Stop Tool
49     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_add_cars.log
50     ${rsp}=    RequestsLibrary.Get Request    session    ${carurl}    headers=${ACCEPT_XML}
51     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-entry
52     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
53
54 Add People
55     [Documentation]    Request to add ${ITEM_COUNT} people (timeout in ${PROCEDURE_TIMEOUT}).
56     Start Tool    ${addpeoplecmd}    ${TOOL_OPTIONS}
57     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
58
59 Verify People
60     [Documentation]    Store logs and verify result
61     Stop Tool
62     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_add_people.log
63     ${rsp}=    RequestsLibrary.Get Request    session    ${peopleurl}    headers=${ACCEPT_XML}
64     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=person
65     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
66
67 Purchase Cars
68     [Documentation]    Request to purchase ${ITEM_COUNT} cars (timeout in ${PROCEDURE_TIMEOUT}).
69     Start Tool    ${purchasecmd}    ${TOOL_OPTIONS}
70     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
71
72 Verify Purchases
73     [Documentation]    Store logs and verify result
74     Stop Tool
75     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_purchase_cars.log
76     Wait Until Keyword Succeeds    ${PROCEDURE_TIMEOUT}    1    Purchase Is Completed    ${ITEM_COUNT}
77
78 Delete Cars
79     [Documentation]    Remove cars from the datastore
80     ${rsp}=    RequestsLibrary.Delete Request    session    ${carurl}
81     Should Be Equal As Numbers    200    ${rsp.status_code}
82     ${rsp}=    RequestsLibrary.Get Request    session    ${carurl}
83     Should Be Equal As Numbers    404    ${rsp.status_code}
84
85 Delete People
86     [Documentation]    Remove people from the datastore
87     ${rsp}=    RequestsLibrary.Delete Request    session    ${peopleurl}
88     Should Be Equal As Numbers    200    ${rsp.status_code}
89     ${rsp}=    RequestsLibrary.Get Request    session    ${peopleurl}
90     Should Be Equal As Numbers    404    ${rsp.status_code}
91
92 Delete CarPeople
93     [Documentation]    Remove car-people entries from the datastore
94     ${rsp}=    RequestsLibrary.Delete Request    session    ${carpeopleurl}
95     Should Be Equal As Numbers    200    ${rsp.status_code}
96     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}
97     Should Be Equal As Numbers    404    ${rsp.status_code}
98
99 *** Keywords ***
100 Start Suite
101     [Documentation]    Suite setup keyword
102     SetupUtils.Setup_Utils_For_Setup_And_Teardown
103     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_LOG_LEVEL}
104     ${mininet_conn_id}=    SSHLibrary.Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
105     Builtin.Set Suite Variable    ${mininet_conn_id}
106     Utils.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
107     SSHLibrary.Put File    ${CURDIR}/../../../../tools/odl-mdsal-clustering-tests/scripts/cluster_rest_script.py    .
108     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    ls    return_stdout=True    return_stderr=True
109     ...    return_rc=True
110     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
111
112 Stop Suite
113     [Documentation]    Suite teardown keyword
114     SSHLibrary.Close All Connections
115     RequestsLibrary.Delete All Sessions
116
117 Start_Tool
118     [Arguments]    ${command}    ${tool_opt}
119     [Documentation]    Start the tool ${command} ${tool_opt}
120     BuiltIn.Log    ${command}
121     ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
122     BuiltIn.Log    ${output}
123
124 Wait_Until_Tool_Finish
125     [Arguments]    ${timeout}
126     [Documentation]    Wait ${timeout} for the tool exit.
127     BuiltIn.Wait Until Keyword Succeeds    ${timeout}    1s    SSHLibrary.Read Until Prompt
128
129 Purchase Is Completed
130     [Arguments]    ${item_count}
131     [Documentation]    Check purchase of ${item_count} is completed.
132     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}    headers=${ACCEPT_XML}
133     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-person
134     Should Be Equal As Numbers    ${count}    ${item_count}
135
136 Stop_Tool
137     [Documentation]    Stop the tool if still running.
138     Utils.Write_Bare_Ctrl_C
139     ${output}=    SSHLibrary.Read    delay=1s
140     BuiltIn.Log    ${output}
141
142 Store_File_To_Workspace
143     [Arguments]    ${source_file_name}    ${target_file_name}
144     [Documentation]    Store the ${source_file_name} to the workspace as ${target_file_name}.
145     ${output_log}=    SSHLibrary.Execute_Command    cat ${source_file_name}
146     BuiltIn.Log    ${output_log}
147     Create File    ${target_file_name}    ${output_log}