Correctly space expected_status
[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-2017 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 ...                 TODO: Decide whether keyword names should contain spaces or underscores.
16
17 Library             RequestsLibrary
18 Library             SSHLibrary
19 Library             XML
20 Resource            ../../../libraries/RemoteBash.robot
21 Resource            ../../../libraries/SetupUtils.robot
22 Resource            ../../../libraries/SSHKeywords.robot
23 Resource            ../../../libraries/TemplatedRequests.robot
24 Resource            ../../../libraries/Utils.robot
25 Variables           ../../../variables/Variables.py
26
27 Suite Setup         Start Suite
28 Suite Teardown      Stop Suite
29 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
31
32
33 *** Variables ***
34 ${ITEM_COUNT}               ${10000}
35 ${ITEM_BATCH}               ${10000}
36 ${PROCEDURE_TIMEOUT}        11m
37 ${addcarcmd}
38 ...                         python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add --itemtype car --itemcount ${ITEM_COUNT} --ipr ${ITEM_BATCH}
39 ${addpeoplecmd}
40 ...                         python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add-rpc --itemtype people --itemcount ${ITEM_COUNT} --threads 5
41 ${purchasecmd}
42 ...                         python cluster_rest_script.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} add-rpc --itemtype car-people --itemcount ${ITEM_COUNT} --threads 5
43 ${carurl}                   /restconf/config/car:cars
44 ${peopleurl}                /restconf/config/people:people
45 ${carpeopleurl}             /restconf/config/car-people:car-people
46 ${CONTROLLER_LOG_LEVEL}     INFO
47 ${TOOL_OPTIONS}             ${EMPTY}
48
49
50 *** Test Cases ***
51 Add Cars
52     [Documentation]    Request to add ${ITEM_COUNT} cars (timeout in ${PROCEDURE_TIMEOUT}).
53     Start Tool    ${addcarcmd}    ${TOOL_OPTIONS}
54     ${output}=    Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
55     BuiltIn.Log    ${output}
56     BuiltIn.Should Not Contain    ${output}    ERROR
57
58 Verify Cars
59     [Documentation]    Store logs and verify result
60     Stop Tool
61     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_add_cars.log
62     ${rsp}=    RequestsLibrary.Get Request    session    ${carurl}    headers=${ACCEPT_XML}
63     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-entry
64     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
65
66 Add People
67     [Documentation]    Request to add ${ITEM_COUNT} people (timeout in ${PROCEDURE_TIMEOUT}).
68     Start Tool    ${addpeoplecmd}    ${TOOL_OPTIONS}
69     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
70
71 Verify People
72     [Documentation]    Store logs and verify result
73     Stop Tool
74     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_add_people.log
75     ${rsp}=    RequestsLibrary.Get Request    session    ${peopleurl}    headers=${ACCEPT_XML}
76     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=person
77     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
78
79 Purchase Cars
80     [Documentation]    Request to purchase ${ITEM_COUNT} cars (timeout in ${PROCEDURE_TIMEOUT}).
81     Start Tool    ${purchasecmd}    ${TOOL_OPTIONS}
82     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
83
84 Verify Purchases
85     [Documentation]    Store logs and verify result
86     Stop Tool
87     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_purchase_cars.log
88     Wait Until Keyword Succeeds    ${PROCEDURE_TIMEOUT}    1    Purchase Is Completed    ${ITEM_COUNT}
89
90 Delete Cars
91     [Documentation]    Remove cars from the datastore
92     ${rsp}=    RequestsLibrary.Delete Request    session    ${carurl}
93     Should Be Equal As Numbers    200    ${rsp.status_code}
94     ${rsp}=    RequestsLibrary.Get Request    session    ${carurl}
95     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
96
97 Delete People
98     [Documentation]    Remove people from the datastore
99     ${rsp}=    RequestsLibrary.Delete Request    session    ${peopleurl}
100     Should Be Equal As Numbers    200    ${rsp.status_code}
101     ${rsp}=    RequestsLibrary.Get Request    session    ${peopleurl}
102     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
103
104 Delete CarPeople
105     [Documentation]    Remove car-people entries from the datastore
106     ${rsp}=    RequestsLibrary.Delete Request    session    ${carpeopleurl}
107     Should Be Equal As Numbers    200    ${rsp.status_code}
108     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}
109     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
110
111
112 *** Keywords ***
113 Start Suite
114     [Documentation]    Suite setup keyword.
115     SetupUtils.Setup_Utils_For_Setup_And_Teardown
116     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_LOG_LEVEL}
117     ${mininet_conn_id}=    SSHLibrary.Open Connection
118     ...    ${TOOLS_SYSTEM_IP}
119     ...    prompt=${TOOLS_SYSTEM_PROMPT}
120     ...    timeout=6s
121     Builtin.Set Suite Variable    ${mininet_conn_id}
122     SSHKeywords.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
123     SSHLibrary.Put File    ${CURDIR}/../../../../tools/odl-mdsal-clustering-tests/scripts/cluster_rest_script.py    .
124     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    ls    return_stdout=True    return_stderr=True
125     ...    return_rc=True
126     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
127
128 Stop Suite
129     [Documentation]    Suite teardown keyword
130     SSHLibrary.Close All Connections
131     RequestsLibrary.Delete All Sessions
132
133 Start_Tool
134     [Documentation]    Start the tool ${command} ${tool_opt}
135     [Arguments]    ${command}    ${tool_opt}
136     BuiltIn.Log    ${command}
137     ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
138     BuiltIn.Log    ${output}
139
140 Wait_Until_Tool_Finish
141     [Documentation]    Wait ${timeout} for the tool exit, return the printed output.
142     [Arguments]    ${timeout}
143     BuiltIn.Run Keyword And Return
144     ...    BuiltIn.Wait Until Keyword Succeeds
145     ...    ${timeout}
146     ...    1s
147     ...    SSHLibrary.Read Until Prompt
148
149 Purchase Is Completed
150     [Documentation]    Check purchase of ${item_count} is completed.
151     [Arguments]    ${item_count}
152     ${rsp}=    RequestsLibrary.Get Request    session    ${carpeopleurl}    headers=${ACCEPT_XML}
153     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-person
154     Should Be Equal As Numbers    ${count}    ${item_count}
155
156 Stop_Tool
157     [Documentation]    Stop the tool if still running.
158     RemoteBash.Write_Bare_Ctrl_C
159     ${output}=    SSHLibrary.Read    delay=1s
160     BuiltIn.Log    ${output}
161
162 Store_File_To_Workspace
163     [Documentation]    Store the ${source_file_name} to the workspace as ${target_file_name}.
164     [Arguments]    ${source_file_name}    ${target_file_name}
165     ${output_log}=    SSHLibrary.Execute_Command    cat ${source_file_name}
166     BuiltIn.Log    ${output_log}
167     Create File    ${target_file_name}    ${output_log}