Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / netconf / clusteringscale / performance.robot
1 *** Settings ***
2 Documentation       netconf-restperfclient update performance test suite (clustered setup).
3 ...
4 ...                 Copyright (c) 2016 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 ...
11 ...                 Perform given count of update operations on device data mounted onto a
12 ...                 netconf connector (using the netconf-testtool-restperfclient tool) and
13 ...                 see how much time it took. More exactly, it sends the data to a restconf
14 ...                 mountpoint of the netconf connector belonging to the device, which turns
15 ...                 out to turn the first request sent to a "create" request and the
16 ...                 remaining requests to "update" requests (due to how the testtool device
17 ...                 behavior is implemented).
18 ...
19 ...                 The difference from the "single node" test suite (see
20 ...                 ../scale/performance.robot) is that the device is configured and the data
21 ...                 on it created using one node in the cluster and the update operations are
22 ...                 issued on a different node. This forces the cluster nodes to communicate
23 ...                 with each other about the data to be sent to the device.
24
25 Library             Collections
26 Library             RequestsLibrary
27 Library             OperatingSystem
28 Library             String
29 Library             SSHLibrary    timeout=10s
30 Resource            ${CURDIR}/../../../libraries/KarafKeywords.robot
31 Resource            ${CURDIR}/../../../libraries/NetconfKeywords.robot
32 Resource            ${CURDIR}/../../../libraries/NexusKeywords.robot
33 Resource            ${CURDIR}/../../../libraries/RestPerfClient.robot
34 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
35 Resource            ${CURDIR}/../../../libraries/Utils.robot
36 Variables           ${CURDIR}/../../../variables/Variables.py
37
38 Suite Setup         Setup_Everything
39 Suite Teardown      Teardown_Everything
40 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
41 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
42
43 Default Tags        1node    netconf    critical
44
45
46 *** Variables ***
47 ${DEVICE_NAME}                      ${FIRST_TESTTOOL_PORT}-sim-device
48 ${REQUEST_COUNT}                    16384
49 ${directory_with_crud_templates}    ${CURDIR}/../../../variables/netconf/CRUD
50 ${DEVICE_DATA_CONNECT_TIMEOUT}      60s
51
52
53 *** Test Cases ***
54 Start_Testtool
55     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
56     # Start test tool
57     SSHLibrary.Switch_Connection    ${testtool}
58     NetconfKeywords.Install_And_Start_Testtool
59     ...    device-count=1
60     ...    debug=false
61     ...    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
62
63 Configure_Device_On_Netconf
64     [Documentation]    Configure the testtool device on Netconf connector, using node 1.
65     NetconfKeywords.Configure_Device_In_Netconf
66     ...    ${DEVICE_NAME}
67     ...    device_type=configure-via-topology
68     ...    session=node1
69
70 Wait_For_Device_To_Become_Connected
71     [Documentation]    Wait until the device becomes available through Netconf on node 1.
72     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}    session=node1
73
74 Wait_For_Device_Data_To_Be_Seen
75     [Documentation]    Wait until the device data show up at node 2.
76     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_DATA_CONNECT_TIMEOUT}    1s    Check_Data_Present
77
78 Create_Device_Data
79     [Documentation]    Send some sample test data into the device through node 2 and check that the request went OK.
80     ${template_as_string}=    BuiltIn.Create_Dictionary    DEVICE_NAME=${device_name}
81     TemplatedRequests.Post_As_Xml_Templated
82     ...    ${directory_with_crud_templates}${/}cars
83     ...    ${template_as_string}
84     ...    session=node2
85
86 Run_Restperfclient
87     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the netconf connector of the device through node 3.
88     ...    The duration of this test case is the main performance metric.
89     ${url}=    BuiltIn.Set_Variable
90     ...    /rests/data/network-topology:network-topology/topology\=topology-netconf/node\=${DEVICE_NAME}/yang-ext:mount/car:cars
91     RestPerfClient.Invoke_Restperfclient    ${TESTTOOL_DEVICE_TIMEOUT}    ${url}    ip=${ODL_SYSTEM_3_IP}
92
93 Check_For_Failed_Requests
94     [Documentation]    Make sure there are no failed requests in the restperfclient log.
95     ...    This is a separate test case to distinguish between restperfclient
96     ...    failure and failed requests. Failed requests are rejected because
97     ...    we don't want to test performance of ODL rejecting our requests.
98     ...    If this test case fails, then the duration of Run_Restperfclient
99     ...    cannot be trusted to show the real performance of the cluster.
100     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
101     BuiltIn.Should_Be_Equal    '${result}'    ''
102     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
103     BuiltIn.Should_Be_Equal    '${result}'    ''
104     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
105     BuiltIn.Should_Be_Equal    '${result}'    ''
106
107 Cleanup_And_Collect
108     [Documentation]    Deconfigure the testtool device on Netconf connector using node 1.
109     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
110     RestPerfClient.Collect_From_Restperfclient
111     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}    session=node1
112
113
114 *** Keywords ***
115 Setup_Everything
116     [Documentation]    Setup everything needed for the test cases.
117     # Calculate and set the value of the timeout
118     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/10+20
119     Utils.Set_User_Configurable_Variable_Default    TESTTOOL_DEVICE_TIMEOUT    ${value} s
120     # Setup resources used by the suite.
121     SetupUtils.Setup_Utils_For_Setup_And_Teardown
122     NetconfKeywords.Setup_Netconf_Keywords
123     RestPerfClient.Setup_Restperfclient
124     # Connect to the tools system (testtool)
125     ${testtool}=    SSHKeywords.Open_Connection_To_Tools_System
126     BuiltIn.Set_Suite_Variable    ${testtool}    ${testtool}
127     # Create sessions
128     RequestsLibrary.Create_Session
129     ...    node1
130     ...    http://${ODL_SYSTEM_1_IP}:${RESTCONFPORT}
131     ...    headers=${HEADERS_XML}
132     ...    auth=${AUTH}
133     RequestsLibrary.Create_Session
134     ...    node2
135     ...    http://${ODL_SYSTEM_2_IP}:${RESTCONFPORT}
136     ...    headers=${HEADERS_XML}
137     ...    auth=${AUTH}
138
139 Check_Data_Present
140     ${url}=    Builtin.Set_Variable
141     ...    ${REST_API}/network-topology:network-topology/topology=topology-netconf/node=${DEVICE_NAME}/yang-ext:mount?content=config
142     ${data}=    TemplatedRequests.Get_As_Xml_From_Uri    ${url}    session=node2
143     BuiltIn.Should_Be_Equal_As_Strings    ${data}    <data xmlns="${ODL_NETCONF_NAMESPACE}"></data>
144
145 Teardown_Everything
146     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
147     RequestsLibrary.Delete_All_Sessions
148     RestPerfClient.Teardown_Restperfclient
149     SSHLibrary.Switch_Connection    ${testtool}
150     BuiltIn.Run_Keyword_And_Ignore_Error    NetconfKeywords.Stop_Testtool