Fix tox errors
[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 Resource          ../../../libraries/CarPeople.robot
24 Resource          ../../../libraries/ClusterManagement.robot
25 Resource          ../../../libraries/RemoteBash.robot
26 Resource          ../../../libraries/SetupUtils.robot
27 Resource          ../../../libraries/SSHKeywords.robot
28 Resource          ../../../libraries/TemplatedRequests.robot
29 Resource          ../../../libraries/Utils.robot
30 Variables         ../../../variables/Variables.py
31
32 *** Variables ***
33 ${ITEM_COUNT}     ${10000}
34 ${ITEM_BATCH}     ${10000}
35 ${PROCEDURE_TIMEOUT}    5m
36 ${threads}        6    # threads are assigned to cluster nodes in round robin way
37 ${addcarcmd}      python cluster_rest_script.py --port ${RESTCONFPORT} add --itemtype car --itemcount ${ITEM_COUNT} --ipr ${ITEM_BATCH}
38 ${addpeoplecmd}    python cluster_rest_script.py --port ${RESTCONFPORT} add-rpc --itemtype people --itemcount ${ITEM_COUNT} --threads 6
39 ${purchasecmd}    python cluster_rest_script.py --port ${RESTCONFPORT} add-rpc --itemtype car-people --itemcount ${ITEM_COUNT} --threads 6
40 ${carurl}         /restconf/config/car:cars
41 ${peopleurl}      /restconf/config/people:people
42 ${carpeopleurl}    /restconf/config/car-people:car-people
43 ${CONTROLLER_LOG_LEVEL}    INFO
44 ${TOOL_OPTIONS}    ${EMPTY}
45
46 *** Test Cases ***
47 Add Cars
48     [Documentation]    Request to add ${ITEM_COUNT} cars (timeout in ${PROCEDURE_TIMEOUT}).
49     ${car_leader_ip}=    ClusterManagement.Resolve_IP_Address_For_Member    member_index=${car_leader_index}
50     Start Tool    ${addcarcmd}    --host ${car_leader_ip} ${TOOL_OPTIONS}
51     Wait Until Tool Finish    ${PROCEDURE_TIMEOUT}
52
53 Verify Cars
54     [Documentation]    Store logs and verify result
55     Stop Tool
56     Store File To Workspace    cluster_rest_script.log    cluster_rest_script_add_cars.log
57     ${rsp}=    RequestsLibrary.Get Request    ${car_leader_session}    ${carurl}    headers=${ACCEPT_XML}
58     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-entry
59     Should Be Equal As Numbers    ${count}    ${ITEM_COUNT}
60
61 Add People
62     [Documentation]    Request to add ${ITEM_COUNT} people (timeout in ${PROCEDURE_TIMEOUT}).
63     Start Tool    ${addpeoplecmd}    --host ${ODL_SYSTEM_1_IP},${ODL_SYSTEM_2_IP},${ODL_SYSTEM_3_IP} ${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    ${car_leader_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     ${target_file}=    Utils.Get_Log_File_Name    cluster_rest_script.log
83     Store File To Workspace    cluster_rest_script.log    ${target_file}
84     Wait Until Keyword Succeeds    ${PROCEDURE_TIMEOUT}    1    Purchase Is Completed    ${ITEM_COUNT}
85
86 Delete Cars
87     [Documentation]    Remove cars from the datastore
88     ${rsp}=    RequestsLibrary.Delete Request    ${car_leader_session}    ${carurl}
89     Should Be Equal As Numbers    200    ${rsp.status_code}
90     ${rsp}=    RequestsLibrary.Get Request    ${car_leader_session}    ${carurl}
91     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
92
93 Delete People
94     [Documentation]    Remove people from the datastore
95     ${rsp}=    RequestsLibrary.Delete Request    ${car_leader_session}    ${peopleurl}
96     Should Be Equal As Numbers    200    ${rsp.status_code}
97     ${rsp}=    RequestsLibrary.Get Request    ${car_leader_session}    ${peopleurl}
98     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
99
100 Delete CarPeople
101     [Documentation]    Remove car-people entries from the datastore
102     ${rsp}=    RequestsLibrary.Delete Request    ${car_leader_session}    ${carpeopleurl}
103     Should Be Equal As Numbers    200    ${rsp.status_code}
104     ${rsp}=    RequestsLibrary.Get Request    ${car_leader_session}    ${carpeopleurl}
105     Should Contain    ${DELETED_STATUS_CODES}    ${rsp.status_code}
106
107 *** Keywords ***
108 Start Suite
109     [Documentation]    Suite setup keyword
110     SetupUtils.Setup_Utils_For_Setup_And_Teardown
111     ClusterManagement.ClusterManagement_Setup
112     CarPeople.Set_Variables_For_Shard    shard_name=car
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     SSHKeywords.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
121 Stop Suite
122     [Documentation]    Suite teardown keyword
123     SSHLibrary.Close All Connections
124     RequestsLibrary.Delete All Sessions
125
126 Start_Tool
127     [Arguments]    ${command}    ${tool_opt}
128     [Documentation]    Start the tool ${command} ${tool_opt}
129     BuiltIn.Log    ${command}
130     ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
131     BuiltIn.Log    ${output}
132
133 Wait_Until_Tool_Finish
134     [Arguments]    ${timeout}
135     [Documentation]    Wait ${timeout} for the tool exit.
136     BuiltIn.Wait Until Keyword Succeeds    ${timeout}    1s    SSHLibrary.Read Until Prompt
137
138 Purchase Is Completed
139     [Arguments]    ${item_count}
140     [Documentation]    Check purchase of ${item_count} is completed.
141     ${rsp}=    RequestsLibrary.Get Request    ${car_leader_session}    ${carpeopleurl}    headers=${ACCEPT_XML}
142     ${count}=    XML.Get Element Count    ${rsp.content}    xpath=car-person
143     Should Be Equal As Numbers    ${count}    ${item_count}
144
145 Stop_Tool
146     [Documentation]    Stop the tool if still running.
147     RemoteBash.Write_Bare_Ctrl_C
148     ${output}=    SSHLibrary.Read    delay=1s
149     BuiltIn.Log    ${output}
150
151 Store_File_To_Workspace
152     [Arguments]    ${source_file_name}    ${target_file_name}
153     [Documentation]    Store the ${source_file_name} to the workspace as ${target_file_name}.
154     ${output_log}=    SSHLibrary.Execute_Command    cat ${source_file_name}
155     BuiltIn.Log    ${output_log}
156     Create File    ${target_file_name}    ${output_log}