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