crud performance test for car-people entries on 1 node cluster
[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 ${CONTROLLER} --port ${RESTCONFPORT} add --itemtype car --itemcount ${ITEM_COUNT} --ipr ${ITEM_BATCH}
32 ${addpeoplecmd}    python cluster_rest_script.py --host ${CONTROLLER} --port ${RESTCONFPORT} add --itemtype people --itemcount ${ITEM_COUNT} --ipr ${ITEM_BATCH}
33 ${purchasecmd}    python cluster_rest_script.py --host ${CONTROLLER} --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     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}    headers=${ACCEPT_XML}
77     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-person
78     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
79     [Teardown]    Report_Failure_Due_To_Bug    4220
80
81 Delete Cars
82     [Documentation]    Remove cars from the datastore
83     ${rsp}=    RequestsLibrary.Delete    session    ${carurl}
84     Should Be Equal As Numbers    200    ${rsp.status_code}
85     ${rsp}=    RequestsLibrary.Get Request    session    ${carurl}
86     Should Be Equal As Numbers    404    ${rsp.status_code}
87
88 Delete People
89     [Documentation]    Remove people from the datastore
90     ${rsp}=    RequestsLibrary.Delete    session    ${peopleurl}
91     Should Be Equal As Numbers    200    ${rsp.status_code}
92     ${rsp}=    RequestsLibrary.Get Request    session    ${peopleurl}
93     Should Be Equal As Numbers    404    ${rsp.status_code}
94
95 Delete CarPeople
96     [Documentation]    Remove car-people entries from the datastore
97     ${rsp}=    RequestsLibrary.Delete    session    ${carpeopleurl}
98     Should Be Equal As Numbers    200    ${rsp.status_code}
99     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}
100     Should Be Equal As Numbers    404    ${rsp.status_code}
101
102 *** Keywords ***
103 Start Suite
104     [Documentation]    Suite setup keyword
105     SetupUtils.Setup_Utils_For_Setup_And_Teardown
106     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_LOG_LEVEL}
107     ${mininet_conn_id}=    SSHLibrary.Open Connection    ${MININET}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
108     Builtin.Set Suite Variable    ${mininet_conn_id}
109     Utils.Flexible Mininet Login    ${MININET_USER}
110     SSHLibrary.Put File    ${CURDIR}/../../../../tools/odl-mdsal-clustering-tests/scripts/cluster_rest_script.py    .
111     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    ls    return_stdout=True    return_stderr=True
112     ...    return_rc=True
113     RequestsLibrary.Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}
114
115 Stop Suite
116     [Documentation]    Suite teardown keyword
117     SSHLibrary.Close All Connections
118     RequestsLibrary.Delete All Sessions
119
120 Start_Tool
121     [Arguments]    ${command}    ${tool_opt}
122     [Documentation]    Start the tool ${command} ${tool_opt}
123     BuiltIn.Log    ${command}
124     ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
125     BuiltIn.Log    ${output}
126
127 Wait_Until_Tool_Finish
128     [Arguments]    ${timeout}
129     [Documentation]    Wait ${timeout} for the tool exit.
130     BuiltIn.Wait Until Keyword Succeeds    ${timeout}    1s    SSHLibrary.Read Until Prompt
131
132 Stop_Tool
133     [Documentation]    Stop the tool if still running.
134     Utils.Write_Bare_Ctrl_C
135     ${output}=    SSHLibrary.Read    delay=1s
136     BuiltIn.Log    ${output}
137
138 Store_File_To_Workspace
139     [Arguments]    ${source_file_name}    ${target_file_name}
140     [Documentation]    Store the ${source_file_name} to the workspace as ${target_file_name}.
141     ${output_log}=    SSHLibrary.Execute_Command    cat ${source_file_name}
142     BuiltIn.Log    ${output_log}
143     Create File    ${target_file_name}    ${output_log}