284877c5cfeafd50a494157471d18628d14fad54
[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           DateTime
24 Library           RequestsLibrary
25 Library           OperatingSystem
26 Library           SSHLibrary    timeout=10s
27 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
28 Resource          ${CURDIR}/../../../libraries/NetconfViaRestconf.robot
29 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
30 Resource          ${CURDIR}/../../../libraries/RestPerfClient.robot
31 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
32 Resource          ${CURDIR}/../../../libraries/Utils.robot
33 Variables         ${CURDIR}/../../../variables/Variables.py
34
35 *** Variables ***
36 ${DIRECTORY_WITH_TEMPLATE_FOLDERS}    ${CURDIR}/../../../variables/netconf/RestPerfClient
37 ${REQUEST_COUNT}    65536
38
39 *** Test Cases ***
40 Create_Test_Data_For_Direct_Access
41     [Documentation]    Send some sample test data into the device and check that the request went OK.
42     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars    {}
43
44 Run_RestPerfClient_Directly_On_MDSAL
45     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the MDSAL via Restconf.
46     [Timeout]    ${DIRECT_MDSAL_TIMEOUT_FOR_TESTCASE}
47     ${url}=    BuiltIn.Set_Variable    /restconf/config/car:cars
48     RestPerfClient.Invoke_Restperfclient    ${DIRECT_MDSAL_TIMEOUT}    ${url}    testcase=direct
49
50 Check_For_Failed_Direct_MDSAL_Requests
51     [Documentation]    Make sure there are no failed requests in the restperfclient log.
52     ...    This is a separate test case to distinguish between restperfclient
53     ...    failure and failed requests. Failed requests are rejected because
54     ...    we don't want to test performance of ODL rejecting our requests.
55     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
56     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
57     BuiltIn.Should_Be_Equal    '${result}'    ''
58     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
59     BuiltIn.Should_Be_Equal    '${result}'    ''
60     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
61     BuiltIn.Should_Be_Equal    '${result}'    ''
62
63 Cleanup_And_Collect_For_Direct_Access
64     [Documentation]    Cleanup the test data produced by the direct MDSAL access.
65     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
66     RestPerfClient.Collect_From_Restperfclient
67     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars-delete    {}
68
69 Create_Test_Data_For_Connector_Access
70     [Documentation]    Create the test data container again so it is ready for the netconf connector test.
71     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
72     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars    {}
73
74 Configure_ODL_As_A_Device_On_Netconf
75     [Documentation]    Configure ODL MDSAL Northbound as a Netconf device on a Netconf connector.
76     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}
77     NetconfKeywords.Wait_Device_Connected    odl-mdsal-northbound-via-netconf-connector
78
79 Run_RestPerfClient_Through_Netconf_Connector
80     [Documentation]    Ask RestPerfClient to send the requests to the MDSAL mapped via a netconf connector.
81     [Timeout]    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT_FOR_TESTCASE}
82     ${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
83     RestPerfClient.Invoke_Restperfclient    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT}    ${url}    testcase=netconf-connector
84
85 Check_For_Failed_Netconf_Connector_Requests
86     [Documentation]    Make sure there are no failed requests in the restperfclient log.
87     ...    This is a separate test case to distinguish between restperfclient
88     ...    failure and failed requests. Failed requests are rejected because
89     ...    we don't want to test performance of ODL rejecting our requests.
90     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
91     ${restperfclientlog}=    RestPerfClient.Get_Current_Log_Name
92     Set_Known_Bug_Id    5581
93     ${result}=    RestPerfClient.Grep_Restperfclient_Log    thread timed out
94     BuiltIn.Should_Be_Equal    '${result}'    ''
95     Set_Unknown_Bug_Id
96     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Request failed
97     BuiltIn.Should_Be_Equal    '${result}'    ''
98     ${result}=    RestPerfClient.Grep_Restperfclient_Log    Status code
99     BuiltIn.Should_Be_Equal    '${result}'    ''
100
101 Deconfigure_ODL_From_Netconf
102     [Documentation]    Deconfigure the ODL MDSAL Northbound attached to a Netconf connector.
103     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
104     NetconfKeywords.Remove_Device_From_Netconf    odl-mdsal-northbound-via-netconf-connector
105
106 Cleanup_And_Collect_For_Connector_Access
107     [Documentation]    Delete the test data produced by the Netconf connector MDSAL access.
108     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
109     RestPerfClient.Collect_From_Restperfclient
110     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}cars-delete    {}
111
112 *** Keywords ***
113 Setup_Everything
114     [Documentation]    Setup everything needed for the test cases.
115     # Setup resources used by the suite.
116     SetupUtils.Setup_Utils_For_Setup_And_Teardown
117     NetconfKeywords.Setup_Netconf_Keywords
118     RestPerfClient.Setup_Restperfclient
119     # Calculate timeouts
120     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/50+10
121     Utils.Set_User_Configurable_Variable_Default    DIRECT_MDSAL_TIMEOUT    ${value} s
122     ${value}=    DateTime.Add_Time_To_Time    ${DIRECT_MDSAL_TIMEOUT}    60s    result_format=compact
123     Utils.Set_User_Configurable_Variable_Default    DIRECT_MDSAL_TIMEOUT_FOR_TESTCASE    ${value}
124     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/10+10
125     Utils.Set_User_Configurable_Variable_Default    NETCONF_CONNECTOR_MDSAL_TIMEOUT    ${value} s
126     ${value}=    DateTime.Add_Time_To_Time    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT}    60s    result_format=compact
127     Utils.Set_User_Configurable_Variable_Default    NETCONF_CONNECTOR_MDSAL_TIMEOUT_FOR_TESTCASE    ${value}
128
129 Teardown_Everything
130     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
131     Teardown_Netconf_Via_Restconf
132     RequestsLibrary.Delete_All_Sessions
133     RestPerfClient.Teardown_Restperfclient