Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / netconf / scale / getmulti.robot
1 *** Settings ***
2 Documentation       netconf-connector scaling test suite (multi-threaded GET requests).
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 ...                 Performs scaling tests:
12 ...                 - Send configurations of the devices one by one (via restconf).
13 ...                 - Wait for the devices to become connected.
14 ...                 - Send requests for configuration data using ${WORKER_COUNT} worker threads
15 ...                 (using external Python tool).
16 ...                 - Deconfigure the devices one by one.
17
18 Library             Collections
19 Library             String
20 Library             SSHLibrary    timeout=10s
21 Resource            ${CURDIR}/../../../libraries/KarafKeywords.robot
22 Resource            ${CURDIR}/../../../libraries/NetconfKeywords.robot
23 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource            ${CURDIR}/../../../libraries/SSHKeywords.robot
25 Variables           ${CURDIR}/../../../variables/Variables.py
26
27 Suite Setup         Setup_Everything
28 Suite Teardown      Teardown_Everything
29 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30
31
32 *** Variables ***
33 ${DEVICE_COUNT}         500
34 ${WORKER_COUNT}         10
35 ${TIMEOUT_FACTOR}       10
36 ${device_name_base}     netconf-scaling-device
37 ${device_type}          full-uri-device
38 ${base_port}            17830
39
40
41 *** Test Cases ***
42 Start_Test_Tool
43     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
44     IF    '${IS_KARAF_APPL}' == 'True'
45         NetconfKeywords.Install_And_Start_Testtool    device-count=${DEVICE_COUNT}
46     ELSE
47         NetconfKeywords.Start_Testtool    ${NETCONF_FILENAME}    device-count=${DEVICE_COUNT}
48     END
49
50 Configure_Devices_On_Netconf
51     [Documentation]    Make requests to configure the testtool devices.
52     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*${TIMEOUT_FACTOR}
53     NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Configure_Device    timeout=${timeout}
54
55 Wait_For_Devices_To_Connect
56     [Documentation]    Wait for the devices to become connected.
57     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*${TIMEOUT_FACTOR}
58     NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Wait_Connected    timeout=${timeout}
59
60 Issue_Requests_On_Devices
61     [Documentation]    Spawn the specified count of worker threads to issue a GET request to each of the devices.
62     # FIXME: this test case is a keyword and nearly duplicated in the max_devices.robot suite. need to move it to a common lib
63     ${current_ssh_connection}=    SSHLibrary.Get Connection
64     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
65     SSHKeywords.Flexible_Mininet_Login
66     SSHLibrary.Write
67     ...    python getter.py --odladdress=${ODL_SYSTEM_IP} --count=${DEVICE_COUNT} --name=${device_name_base} --workers=${WORKER_COUNT}
68     FOR    ${number}    IN RANGE    1    ${DEVICE_COUNT}+1
69         Read_Python_Tool_Operation_Result    ${number}
70     END
71     SSHLibrary.Read_Until_Prompt
72     SSHLibrary.Close_Connection
73     SSHKeywords.Restore Current SSH Connection From Index    ${current_ssh_connection.index}
74
75 Deconfigure_Devices
76     [Documentation]    Make requests to deconfigure the testtool devices.
77     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*${TIMEOUT_FACTOR}
78     NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Deconfigure_Device    timeout=${timeout}
79     [Teardown]    Report_Failure_Due_To_Bug    4547
80
81 Check_Devices_Are_Deconfigured
82     [Documentation]    Check there are no netconf connectors or other stuff related to the testtool devices.
83     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*${TIMEOUT_FACTOR}
84     NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Check_Device_Deconfigured    timeout=${timeout}
85
86
87 *** Keywords ***
88 Setup_Everything
89     [Documentation]    Setup everything needed for the test cases.
90     # Setup resources used by the suite.
91     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${REST_API}    auth=${AUTH}
92     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
93     SetupUtils.Setup_Utils_For_Setup_And_Teardown
94     NetconfKeywords.Setup_Netconf_Keywords
95     # Deploy testing tools.
96     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/netconf_tools/getter.py
97     SSHLibrary.Put_File    ${CURDIR}/../../../libraries/AuthStandalone.py
98     ${device_type}=    BuiltIn.Set_Variable_If    ${USE_NETCONF_CONNECTOR}==${True}    default    ${device_type}
99     BuiltIn.Set_Suite_Variable    ${device_type}
100
101 Teardown_Everything
102     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
103     RequestsLibrary.Delete_All_Sessions
104     NetconfKeywords.Stop_Testtool
105
106 Read_Python_Tool_Operation_Result
107     [Documentation]    Read and process a report line emitted from the Python tool that corresponds to the device with the given number.
108     [Arguments]    ${number}
109     ${test}=    SSHLibrary.Read_Until_Regexp    \\n
110     ${test}=    String.Split_String    ${test}    |
111     ${response}=    Collections.Get_From_List    ${test}    0
112     ${message}=    Collections.Get_From_List    ${test}    1
113     IF    '${response}' == 'ERROR'    Fail    Error getting data: ${message}
114     ${start}=    Collections.Get_From_List    ${test}    1
115     ${stop}=    Collections.Get_From_List    ${test}    2
116     ${ellapsed}=    Collections.Get_From_List    ${test}    3
117     BuiltIn.Log    DATA REQUEST RESULT: Device=${number} StartTime=${start} StopTime=${stop} EllapsedTime=${ellapsed}
118     ${data}=    Collections.Get_From_List    ${test}    4
119     IF    '${IS_KARAF_APPL}' == 'True'
120         ${expected}=    BuiltIn.Set_Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"></data>'
121     ELSE
122         ${expected}=    Set Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"/>'
123     END
124     BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}