RestPerfClient performance test suite
[integration/test.git] / csit / suites / netconf / restperfclient / performance.robot
1 *** Settings ***
2 Documentation     netconf-restperfclient Update performance test suite.
3 ...
4 ...               Copyright (c) 2015 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 ...               TODO: The "Wait_Until_Prompt" keyword shall probably be turned into a
20 ...               reusable piece and moved into SSHKeywords. There is a bunch of other
21 ...               test suites (e.g. PCEP, BGP) which contain the same or similar pieces of
22 ...               code.
23 Suite Setup       Setup_Everything
24 Suite Teardown    Teardown_Everything
25 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
26 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
27 Library           Collections
28 Library           RequestsLibrary
29 Library           OperatingSystem
30 Library           String
31 Library           SSHLibrary    timeout=10s
32 Resource          ${CURDIR}/../../../libraries/FailFast.robot
33 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
34 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
35 Resource          ${CURDIR}/../../../libraries/NetconfViaRestconf.robot
36 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
37 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
38 Resource          ${CURDIR}/../../../libraries/Utils.robot
39 Variables         ${CURDIR}/../../../variables/Variables.py
40
41 *** Variables ***
42 ${DIRECTORY_WITH_CRUD_TEMPLATES}    ${CURDIR}/../../../variables/netconf/CRUD
43 ${DIRECTORY_WITH_TEMPLATE_FOLDERS}    ${CURDIR}/../../../variables/netconf/RestPerfClient
44 ${DEVICE_NAME}    ${FIRST_TESTTOOL_PORT}-sim-device
45 ${REQUEST_COUNT}    65536
46
47 *** Test Cases ***
48 Start_Testtool
49     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
50     # Start test tool
51     SSHLibrary.Switch_Connection    ${testtool}
52     NetconfKeywords.Install_And_Start_Testtool    device-count=1    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas    mdsal=false    debug=false
53
54 Configure_Device_On_Netconf
55     [Documentation]    Configure the testtool device on Netconf connector.
56     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}
57
58 Wait_For_Device_To_Become_Connected
59     [Documentation]    Wait until the device becomes available through Netconf.
60     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
61
62 Create_Device_Data
63     [Documentation]    Send some sample test data into the device and check that the request went OK.
64     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
65     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_CRUD_TEMPLATES}${/}cars    ${template_as_string}
66
67 Deploy_And_Run_RestPerfClient
68     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the netconf connector of the device.
69     SSHLibrary.Switch_Connection    ${restperfclient}
70     SSHLibrary.Put_File    ${CURDIR}/../../../variables/netconf/RestPerfClient/request1.json
71     ${filename}=    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    rest-perf-client
72     ${timeout}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/100+10
73     SSHLibrary.Set_Client_Configuration    timeout=${timeout}
74     ${options}=    BuiltIn.Set_Variable    --ip ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --edits ${REQUEST_COUNT}
75     ${options}=    BuiltIn.Set_Variable    ${options} --destination /restconf/config/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount/car:cars
76     ${options}=    BuiltIn.Set_Variable    ${options} --edit-content request1.json
77     ${options}=    BuiltIn.Set_Variable    ${options} --auth ${ODL_RESTCONF_USER} ${ODL_RESTCONF_PASSWORD}
78     ${command}    BuiltIn.Set_Variable    java -Xmx1G -XX:MaxPermSize=256M -jar ${filename} ${options}
79     BuiltIn.Log    Running restperfclient: ${command}
80     ${restperfclientlog}=    Utils.Get_Log_File_Name    restperfclient
81     BuiltIn.Set_Suite_Variable    ${restperfclientlog}    ${restperfclientlog}
82     Execute_Command_Passes    ${command} >${restperfclientlog} 2>&1
83     SSHLibrary.Get_File    ${restperfclientlog}
84     ${result}=    SSHLibrary.Execute_Command    grep "FINISHED. Execution time:" ${restperfclientlog}
85     BuiltIn.Should_Not_Be_Equal    '${result}'    ''
86
87 Check_For_Failed_Requests
88     [Documentation]    Make sure there are no failed requests in the restperfclient log.
89     ...    This is a separate test case to distinguish between restperfclient
90     ...    failure and failed requests. Failed requests are rejected because
91     ...    we don't want to test performance of ODL rejecting our requests.
92     ${result}=    SSHLibrary.Execute_Command    grep "Request failed" ${restperfclientlog}
93     BuiltIn.Should_Be_Equal    '${result}'    ''
94
95 Deconfigure_Device_From_Netconf
96     [Documentation]    Deconfigure the testtool device on Netconf connector.
97     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
98     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}
99
100 *** Keywords ***
101 Setup_Everything
102     [Documentation]    Setup everything needed for the test cases.
103     # Setup resources used by the suite.
104     SetupUtils.Setup_Utils_For_Setup_And_Teardown
105     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
106     NetconfKeywords.Setup_Netconf_Keywords
107     # Connect to the tools system (rest-perf-client)
108     ${restperfclient}=    SSHKeywords.Open_Connection_To_Tools_System
109     BuiltIn.Set_Suite_Variable    ${restperfclient}    ${restperfclient}
110     # Initialize artifact deployment infrastructure.
111     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
112     ${testtool}=    SSHLibrary.Get Connection
113     BuiltIn.Set_Suite_Variable    ${testtool}    ${testtool.index}
114
115 Teardown_Everything
116     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
117     Teardown_Netconf_Via_Restconf
118     RequestsLibrary.Delete_All_Sessions
119     SSHLibrary.Switch_Connection    ${testtool}
120     BuiltIn.Run_Keyword_And_Ignore_Error    NetconfKeywords.Stop_Testtool
121
122 Wait_Until_Prompt
123     [Documentation]    Wait until prompt appears or timeout occurs. When timeout occurs, send Ctrl-C and then wait for the prompt again.
124     ...    This is necessary because the restperfclient can crash and hang, requiring that Ctrl-C character to get rid of it for good.
125     ${status}    ${result}=    BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Read_Until_Prompt
126     Return_From_Keyword_If    '${status}' == 'PASS'
127     Utils.Write_Bare_Ctrl_C
128     SSHLibrary.Read_Until_Prompt