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