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