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