Refactor performance suites to use keyword timeouts
[integration/test.git] / csit / suites / netconf / restperfclient / mdsal.robot
1 *** Settings ***
2 Documentation     netconf-restperfclient MDSAL 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 ODL MDSAL. In first half the
12 ...               requests are directed directly to MDSAL via Restconf and in the second
13 ...               half the MDSAL is mounted onto a netconf connector and the reqursts are
14 ...               directed to that connector. In both cases the netconf-testtool-restperfclient
15 ...               tool is used to generate and send the requests and the requests are sent
16 ...               synchronously as the netconf connector mounted MDSAL does not support
17 ...               asynchronous requests. The restperfclient is used to generate the "update"
18 ...               requests, the "create" request is issued in a sepate test case.
19 Suite Setup       Setup_Everything
20 Suite Teardown    Teardown_Everything
21 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
22 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
23 Library           RequestsLibrary
24 Library           OperatingSystem
25 Library           SSHLibrary    timeout=10s
26 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
27 Resource          ${CURDIR}/../../../libraries/NetconfViaRestconf.robot
28 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
29 Resource          ${CURDIR}/../../../libraries/RestPerfClient.robot
30 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
31 Resource          ${CURDIR}/../../../libraries/Utils.robot
32 Variables         ${CURDIR}/../../../variables/Variables.py
33
34 *** Variables ***
35 ${DIRECTORY_WITH_TEMPLATE_FOLDERS}    ${CURDIR}/../../../variables/netconf/RestPerfClient
36 ${REQUEST_COUNT}    65536
37
38 *** Test Cases ***
39 Create_Test_Data_For_Direct_Access
40     [Documentation]    Send some sample test data into the device and check that the request went OK.
41     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars    {}
42
43 Run_RestPerfClient_Directly_On_MDSAL
44     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the MDSAL via Restconf.
45     ${url}=    BuiltIn.Set_Variable    /restconf/config/car:cars
46     RestPerfClient.Invoke_Restperfclient    ${DIRECT_MDSAL_TIMEOUT}    ${url}    testcase=direct
47
48 Check_For_Failed_Direct_MDSAL_Requests
49     [Documentation]    Make sure there are no failed requests in the restperfclient log.
50     ...    This is a separate test case to distinguish between restperfclient
51     ...    failure and failed requests. Failed requests are rejected because
52     ...    we don't want to test performance of ODL rejecting our requests.
53     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
54     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
55     BuiltIn.Should_Be_Equal    '${result}'    ''
56     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
57     BuiltIn.Should_Be_Equal    '${result}'    ''
58     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
59     BuiltIn.Should_Be_Equal    '${result}'    ''
60
61 Cleanup_And_Collect_For_Direct_Access
62     [Documentation]    Cleanup the test data produced by the direct MDSAL access.
63     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
64     RestPerfClient.Collect_From_Restperfclient
65     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars-delete    {}
66
67 Create_Test_Data_For_Connector_Access
68     [Documentation]    Create the test data container again so it is ready for the netconf connector test.
69     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
70     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars    {}
71
72 Configure_ODL_As_A_Device_On_Netconf
73     [Documentation]    Configure ODL MDSAL Northbound as a Netconf device on a Netconf connector.
74     NetconfKeywords.Configure_Device_In_Netconf    odl-mdsal-northbound-via-netconf-connector    device_address=${ODL_SYSTEM_IP}    device_port=${ODL_NETCONF_MDSAL_PORT}    device_user=${ODL_NETCONF_USER}    device_password=${ODL_NETCONF_PASSWORD}
75     NetconfKeywords.Wait_Device_Connected    odl-mdsal-northbound-via-netconf-connector
76
77 Run_RestPerfClient_Through_Netconf_Connector
78     [Documentation]    Ask RestPerfClient to send the requests to the MDSAL mapped via a netconf connector.
79     ${url}=    BuiltIn.Set_Variable    /restconf/config/network-topology:network-topology/topology/topology-netconf/node/odl-mdsal-northbound-via-netconf-connector/yang-ext:mount/car:cars
80     RestPerfClient.Invoke_Restperfclient    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT}    ${url}    testcase=netconf-connector
81
82 Check_For_Failed_Netconf_Connector_Requests
83     [Documentation]    Make sure there are no failed requests in the restperfclient log.
84     ...    This is a separate test case to distinguish between restperfclient
85     ...    failure and failed requests. Failed requests are rejected because
86     ...    we don't want to test performance of ODL rejecting our requests.
87     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
88     Set_Known_Bug_Id    5581
89     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
90     BuiltIn.Should_Be_Equal    '${result}'    ''
91     Set_Unknown_Bug_Id
92     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
93     BuiltIn.Should_Be_Equal    '${result}'    ''
94     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
95     BuiltIn.Should_Be_Equal    '${result}'    ''
96
97 Deconfigure_ODL_From_Netconf
98     [Documentation]    Deconfigure the ODL MDSAL Northbound attached to a Netconf connector.
99     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
100     NetconfKeywords.Remove_Device_From_Netconf    odl-mdsal-northbound-via-netconf-connector
101
102 Cleanup_And_Collect_For_Connector_Access
103     [Documentation]    Delete the test data produced by the Netconf connector MDSAL access.
104     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
105     RestPerfClient.Collect_From_Restperfclient
106     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars-delete    {}
107
108 *** Keywords ***
109 Setup_Everything
110     [Documentation]    Setup everything needed for the test cases.
111     # Setup resources used by the suite.
112     SetupUtils.Setup_Utils_For_Setup_And_Teardown
113     NetconfKeywords.Setup_Netconf_Keywords
114     RestPerfClient.Setup_Restperfclient
115     # Calculate timeouts
116     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/50+10
117     Utils.Set_User_Configurable_Variable_Default    DIRECT_MDSAL_TIMEOUT    ${value} s
118     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/10+10
119     Utils.Set_User_Configurable_Variable_Default    NETCONF_CONNECTOR_MDSAL_TIMEOUT    ${value} s
120
121 Teardown_Everything
122     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
123     Teardown_Netconf_Via_Restconf
124     RequestsLibrary.Delete_All_Sessions
125     RestPerfClient.Teardown_Restperfclient