Fix variable naming for some immutable variables
[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/SetupUtils.robot
32 Resource          ${CURDIR}/../../../libraries/Utils.robot
33 Variables         ${CURDIR}/../../../variables/Variables.py
34
35 *** Variables ***
36 ${DEVICE_NAME}    ${FIRST_TESTTOOL_PORT}-sim-device
37 ${REQUEST_COUNT}    65536
38 ${directory_with_crud_templates}    ${CURDIR}/../../../variables/netconf/CRUD
39
40 *** Test Cases ***
41 Start_Testtool
42     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
43     # Start test tool
44     SSHLibrary.Switch_Connection    ${testtool}
45     NetconfKeywords.Install_And_Start_Testtool    device-count=1    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas    mdsal=false    debug=false
46
47 Configure_Device_On_Netconf
48     [Documentation]    Configure the testtool device on Netconf connector.
49     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}
50
51 Wait_For_Device_To_Become_Connected
52     [Documentation]    Wait until the device becomes available through Netconf.
53     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
54
55 Create_Device_Data
56     [Documentation]    Send some sample test data into the device and check that the request went OK.
57     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
58     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${directory_with_crud_templates}${/}cars    ${template_as_string}
59
60 Deploy_And_Run_RestPerfClient
61     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the netconf connector of the device.
62     SSHLibrary.Switch_Connection    ${restperfclient}
63     SSHLibrary.Put_File    ${CURDIR}/../../../variables/netconf/RestPerfClient/request1.json
64     ${filename}=    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    rest-perf-client
65     ${timeout}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/100+10
66     SSHLibrary.Set_Client_Configuration    timeout=${timeout}
67     ${options}=    BuiltIn.Set_Variable    --ip ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --edits ${REQUEST_COUNT}
68     ${options}=    BuiltIn.Set_Variable    ${options} --destination /restconf/config/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount/car:cars
69     ${options}=    BuiltIn.Set_Variable    ${options} --edit-content request1.json
70     ${options}=    BuiltIn.Set_Variable    ${options} --auth ${ODL_RESTCONF_USER} ${ODL_RESTCONF_PASSWORD}
71     ${command}=    NexusKeywords.Compose_Full_Java_Command    -Xmx1G -XX:MaxPermSize=256M -jar ${filename} ${options}
72     BuiltIn.Log    Running restperfclient: ${command}
73     ${restperfclientlog}=    Utils.Get_Log_File_Name    restperfclient
74     BuiltIn.Set_Suite_Variable    ${restperfclientlog}    ${restperfclientlog}
75     Execute_Command_Passes    ${command} >${restperfclientlog} 2>&1
76     SSHLibrary.Get_File    ${restperfclientlog}
77     ${result}=    SSHLibrary.Execute_Command    grep "FINISHED. Execution time:" ${restperfclientlog}
78     BuiltIn.Should_Not_Be_Equal    '${result}'    ''
79
80 Check_For_Failed_Requests
81     [Documentation]    Make sure there are no failed requests in the restperfclient log.
82     ...    This is a separate test case to distinguish between restperfclient
83     ...    failure and failed requests. Failed requests are rejected because
84     ...    we don't want to test performance of ODL rejecting our requests.
85     ${result}=    SSHLibrary.Execute_Command    grep "Request failed" ${restperfclientlog}
86     BuiltIn.Should_Be_Equal    '${result}'    ''
87     ${result}=    SSHLibrary.Execute_Command    grep "Status code" ${restperfclientlog}
88     BuiltIn.Should_Be_Equal    '${result}'    ''
89
90 Deconfigure_Device_From_Netconf
91     [Documentation]    Deconfigure the testtool device on Netconf connector.
92     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
93     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}
94
95 *** Keywords ***
96 Setup_Everything
97     [Documentation]    Setup everything needed for the test cases.
98     # Setup resources used by the suite.
99     SetupUtils.Setup_Utils_For_Setup_And_Teardown
100     NetconfKeywords.Setup_Netconf_Keywords
101     # Connect to the tools system (rest-perf-client)
102     ${restperfclient}=    SSHKeywords.Open_Connection_To_Tools_System
103     BuiltIn.Set_Suite_Variable    ${restperfclient}    ${restperfclient}
104     ${testtool}=    SSHLibrary.Get Connection
105     BuiltIn.Set_Suite_Variable    ${testtool}    ${testtool.index}
106
107 Teardown_Everything
108     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
109     Teardown_Netconf_Via_Restconf
110     RequestsLibrary.Delete_All_Sessions
111     SSHLibrary.Switch_Connection    ${testtool}
112     BuiltIn.Run_Keyword_And_Ignore_Error    NetconfKeywords.Stop_Testtool