Update Robot Framework format - step 10
[integration/test.git] / csit / suites / netconf / restperfclient / performance.robot
1 *** Settings ***
2 Documentation       netconf-restperfclient Update performance test suite.
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 Library             Collections
20 Library             RequestsLibrary
21 Library             OperatingSystem
22 Library             String
23 Library             SSHLibrary    timeout=10s
24 Resource            ${CURDIR}/../../../libraries/KarafKeywords.robot
25 Resource            ${CURDIR}/../../../libraries/NetconfKeywords.robot
26 Resource            ${CURDIR}/../../../libraries/NexusKeywords.robot
27 Resource            ${CURDIR}/../../../libraries/RestPerfClient.robot
28 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
29 Resource            ${CURDIR}/../../../libraries/TemplatedRequests.robot
30 Resource            ${CURDIR}/../../../libraries/Utils.robot
31 Variables           ${CURDIR}/../../../variables/Variables.py
32
33 Suite Setup         Setup_Everything
34 Suite Teardown      Teardown_Everything
35 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
36 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
37
38
39 *** Variables ***
40 ${DEVICE_NAME}                      ${FIRST_TESTTOOL_PORT}-sim-device
41 ${REQUEST_COUNT}                    16384
42 ${directory_with_crud_templates}    ${CURDIR}/../../../variables/netconf/CRUD
43 ${device_type}                      full-uri-device
44
45
46 *** Test Cases ***
47 Start_Testtool
48     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
49     # Start test tool
50     SSHLibrary.Switch_Connection    ${testtool}
51     IF    '${IS_KARAF_APPL}' == 'True'
52         NetconfKeywords.Install_And_Start_Testtool
53         ...    device-count=1
54         ...    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
55         ...    debug=false
56     ELSE
57         NetconfKeywords.Start_Testtool
58         ...    ${NETCONF_FILENAME}
59         ...    device-count=1
60         ...    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
61         ...    debug=false
62     END
63
64 Configure_Device_On_Netconf
65     [Documentation]    Configure the testtool device on Netconf connector.
66     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}    device_type=${device_type}
67
68 Wait_For_Device_To_Become_Connected
69     [Documentation]    Wait until the device becomes available through Netconf.
70     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
71
72 Create_Device_Data
73     [Documentation]    Send some sample test data into the device and check that the request went OK.
74     ${template_as_string}=    BuiltIn.Create_Dictionary    DEVICE_NAME=${device_name}
75     TemplatedRequests.Post_As_Xml_Templated    ${directory_with_crud_templates}${/}cars    ${template_as_string}
76
77 Run_Restperfclient
78     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the netconf connector of the device.
79     ${url}=    BuiltIn.Set_Variable
80     ...    /rests/data/network-topology:network-topology/topology\=topology-netconf/node\=${DEVICE_NAME}/yang-ext:mount/car:cars
81     RestPerfClient.Invoke_Restperfclient    ${TESTTOOL_DEVICE_TIMEOUT}    ${url}    async=false
82
83 Check_For_Failed_Requests
84     [Documentation]    Make sure there are no failed requests in the restperfclient log.
85     ...    This is a separate test case to distinguish between restperfclient
86     ...    failure and failed requests. Failed requests are rejected because
87     ...    we don't want to test performance of ODL rejecting our requests.
88     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
89     BuiltIn.Should_Be_Equal    '${result}'    ''
90     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
91     BuiltIn.Should_Be_Equal    '${result}'    ''
92     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
93     BuiltIn.Should_Be_Equal    '${result}'    ''
94
95 Cleanup_And_Collect
96     [Documentation]    Deconfigure the testtool device on Netconf connector.
97     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
98     RestPerfClient.Collect_From_Restperfclient
99     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}
100
101
102 *** Keywords ***
103 Setup_Everything
104     [Documentation]    Setup everything needed for the test cases.
105     # Calculate and set the value of the timeout
106     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/10+20
107     Utils.Set_User_Configurable_Variable_Default    TESTTOOL_DEVICE_TIMEOUT    ${value} s
108     # Setup resources used by the suite.
109     SetupUtils.Setup_Utils_For_Setup_And_Teardown
110     NetconfKeywords.Setup_Netconf_Keywords
111     IF    '${IS_KARAF_APPL}' == 'False'
112         RestPerfClient.Setup_Restperfclient
113         ...    build_version=${NETCONF_TESTTOOL_VERSION}
114         ...    build_location=org/opendaylight/netconf
115     ELSE
116         RestPerfClient.Setup_Restperfclient
117     END
118     # Connect to the tools system (testtool)
119     ${testtool}=    SSHKeywords.Open_Connection_To_Tools_System
120     BuiltIn.Set_Suite_Variable    ${testtool}    ${testtool}
121     ${device_type}=    BuiltIn.Set_Variable_If    ${USE_NETCONF_CONNECTOR}==${True}    default    ${device_type}
122     BuiltIn.Set_Suite_Variable    ${device_type}
123
124 Teardown_Everything
125     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
126     RequestsLibrary.Delete_All_Sessions
127     RestPerfClient.Teardown_Restperfclient
128     SSHLibrary.Switch_Connection    ${testtool}
129     BuiltIn.Run_Keyword_And_Ignore_Error    NetconfKeywords.Stop_Testtool