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