INTTEST-107: Add test cases to cover rpc augmentation action
[integration/test.git] / csit / suites / netconf / scale / max_devices.robot
1 *** Settings ***
2 Documentation     netconf-connector scaling test suite to find max connected devices
3 ...           
4 ...               Copyright (c) 2019 Lumina Networks, 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 ...               Increasing numbers of netconf devices will be connected and cleaned up
12 ...               while validating and profiling between each iteration.
13 Suite Setup       Setup_Everything
14 Suite Teardown    Teardown_Everything
15 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Library           Collections
17 Library           String
18 Library           SSHLibrary    timeout=10s
19 Resource          ../../../libraries/CheckJVMResource.robot
20 Resource          ../../../libraries/KarafKeywords.robot
21 Resource          ../../../libraries/NetconfKeywords.robot
22 Resource          ../../../libraries/SetupUtils.robot
23 Resource          ../../../libraries/SSHKeywords.robot
24 Resource          ../../../variables/Variables.robot
25
26 *** Variables ***
27 ${INIT_DEVICE_COUNT}    250
28 ${MAX_DEVICE_COUNT}    5000
29 ${DEVICE_INCREMENT}    250
30 ${DEVICE_NAME_BASE}    netconf-scaling-device
31 ${DEVICE_TYPE}    full-uri-device
32 ${BASE_PORT}      17830
33 ${NUM_WORKERS}    10
34 ${TIMEOUT_FACTOR}    2
35 ${MIN_CONNECT_TIMEOUT}    300
36 ${DEVICES_RESULT_FILE}    devices.csv
37 ${INSTALL_TESTTOOL}    True
38 ${TESTTOOL_EXECUTABLE}    ${EMPTY}
39
40 *** Test Cases ***
41 Find Max Netconf Devices
42     [Documentation]    Find max number of switches starting from ${MIN_SWITCHES} till reaching ${MAX_SWITCHES} in steps of ${STEP_SWITCHES}
43     ${error_message} =    BuiltIn.Set Variable    Failure initializing suite
44     ${maximum_devices} =    BuiltIn.Set Variable    ${0}
45     ${discover_time} =    BuiltIn.Set Variable    0
46     ${start} =    BuiltIn.Convert to Integer    ${INIT_DEVICE_COUNT}
47     ${stop} =    BuiltIn.Convert to Integer    ${MAX_DEVICE_COUNT}
48     ${increment} =    BuiltIn.Convert to Integer    ${DEVICE_INCREMENT}
49     ${schema_dir} =    Run Keyword If    "${SCHEMA_MODEL}" == "juniper"    Get Juniper Device Schemas
50     ...    ELSE    Set Variable    none
51     Run Keyword And Ignore Error    CheckJVMResource.Get JVM Memory
52     FOR    ${devices}    IN RANGE    ${start}    ${stop+1}    ${increment}
53         ${timeout} =    BuiltIn.Evaluate    ${devices}*${TIMEOUT_FACTOR}
54         ${timeout} =    Set Variable If    ${timeout} > ${MIN_CONNECT_TIMEOUT}    ${timeout}    ${MIN_CONNECT_TIMEOUT}
55         Log To Console    Starting Iteration with ${devices} devices
56         Run Keyword If    "${INSTALL_TESTTOOL}"=="True"    NetconfKeywords.Install_And_Start_Testtool    debug=false    schemas=${schema_dir}    device-count=${devices}
57         ...    ELSE    NetconfKeywords.Start_Testtool    ${TESTTOOL_EXECUTABLE}    debug=false    schemas=${schema_dir}    device-count=${devices}
58         ${status}    ${result} =    Run Keyword And Ignore Error    NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Configure_Device    timeout=${timeout}
59         Exit For Loop If    '${status}' == 'FAIL'
60         ${status}    ${result} =    Run Keyword And Ignore Error    NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Wait_Connected    timeout=${timeout}    log_response=False
61         Exit For Loop If    '${status}' == 'FAIL'
62         ${status}    ${result} =    Run Keyword And Ignore Error    Issue_Requests_On_Devices    ${TOOLS_SYSTEM_IP}    ${devices}
63         ...    ${NUM_WORKERS}
64         Exit For Loop If    '${status}' == 'FAIL'
65         ${status}    ${result} =    Run Keyword And Ignore Error    NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Wait_Connected    timeout=${timeout}    log_response=False
66         Exit For Loop If    '${status}' == 'FAIL'
67         ${status}    ${result} =    Run Keyword And Ignore Error    NetconfKeywords.Perform_Operation_On_Each_Device    NetconfKeywords.Deconfigure_Device    timeout=${timeout}
68         Exit For Loop If    '${status}' == 'FAIL'
69         ${status}    ${result} =    Run Keyword And Ignore Error    NetconfKeywords.Perform_Operation_On_Each_Device    Check_Device_Deconfigured    timeout=${timeout}    log_response=False
70         Exit For Loop If    '${status}' == 'FAIL'
71         ${maximum_devices} =    Set Variable    ${devices}
72         Run Keyword And Ignore Error    CheckJVMResource.Get JVM Memory
73         NetconfKeywords.Stop_Testtool
74     END
75     [Teardown]    Run Keywords    NetconfKeywords.Stop_Testtool
76     ...    AND    Collect_Data_Points    ${maximum_devices}
77     ...    AND    Run Keyword And Ignore Error    CheckJVMResource.Get JVM Memory
78
79 *** Keywords ***
80 Collect_Data_Points
81     [Arguments]    ${devices}
82     [Documentation]    Parse and Log relevant information when Scale test finishes
83     OperatingSystem.Append To File    ${DEVICES_RESULT_FILE}    Max Devices\n
84     OperatingSystem.Append To File    ${DEVICES_RESULT_FILE}    ${devices}\n
85
86 Issue_Requests_On_Devices
87     # FIXME: this keyword is nearly duplicated in the getmulti.robot suite. need to move it to a common lib
88     [Arguments]    ${client_ip}    ${expected_count}    ${worker_count}
89     [Documentation]    Spawn the specified count of worker threads to issue a GET request to each of the devices.
90     ${current_ssh_connection}=    SSHLibrary.Get Connection
91     SSHLibrary.Open_Connection    ${client_ip}
92     SSHKeywords.Flexible_Mininet_Login
93     SSHLibrary.Write    python getter.py --odladdress=${ODL_SYSTEM_IP} --count=${expected_count} --name=${device_name_base} --workers=${worker_count}
94     FOR    ${number}    IN RANGE    1    ${expected_count}+1
95         Read_Python_Tool_Operation_Result    ${number}
96     END
97     SSHLibrary.Read_Until_Prompt
98     SSHLibrary.Close_Connection
99     SSHKeywords.Restore Current SSH Connection From Index    ${current_ssh_connection.index}
100
101 Setup_Everything
102     [Documentation]    Setup everything needed for the test cases.
103     # Setup resources used by the suite.
104     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
105     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
106     SetupUtils.Setup_Utils_For_Setup_And_Teardown
107     NetconfKeywords.Setup_Netconf_Keywords
108     # Deploy testing tools.
109     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/netconf_tools/getter.py
110     SSHLibrary.Put_File    ${CURDIR}/../../../libraries/AuthStandalone.py
111     ${device_type}=    BuiltIn.Set_Variable_If    ${USE_NETCONF_CONNECTOR}==${True}    default    ${device_type}
112     BuiltIn.Set_Suite_Variable    ${device_type}
113
114 Teardown_Everything
115     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
116     RequestsLibrary.Delete_All_Sessions
117     NetconfKeywords.Stop_Testtool
118
119 Read_Python_Tool_Operation_Result
120     [Arguments]    ${number}
121     [Documentation]    Read and process a report line emitted from the Python tool that corresponds to the device with the given number.
122     ${test}=    SSHLibrary.Read_Until_Regexp    \\n
123     ${test}=    String.Split_String    ${test}    |
124     ${response}=    Collections.Get_From_List    ${test}    0
125     ${message}=    Collections.Get_From_List    ${test}    1
126     BuiltIn.Run_Keyword_If    '${response}' == 'ERROR'    Fail    Error getting data: ${message}
127     ${start}=    Collections.Get_From_List    ${test}    1
128     ${stop}=    Collections.Get_From_List    ${test}    2
129     ${ellapsed}=    Collections.Get_From_List    ${test}    3
130     BuiltIn.Log    DATA REQUEST RESULT: Device=${number} StartTime=${start} StopTime=${stop} EllapsedTime=${ellapsed}
131     ${data}=    Collections.Get_From_List    ${test}    4
132     ${expected}=    BuiltIn.Set_Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"></data>'
133     BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
134
135 Check_Device_Deconfigured
136     [Arguments]    ${current_name}    ${log_response}=True
137     [Documentation]    Operation for making sure the device is really deconfigured.
138     KarafKeywords.Log_Message_To_Controller_Karaf    Waiting for device ${current_name} to disappear
139     NetconfKeywords.Wait_Device_Fully_Removed    ${current_name}    period=0.5s    timeout=120s    log_response=${log_response}
140     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} removed
141
142 Get Juniper Device Schemas
143     OperatingSystem.Run    git clone https://github.com/Juniper/yang.git
144     OperatingSystem.Run    mkdir /tmp/junos_19.4R1
145     OperatingSystem.Run    find yang/19.4/19.4R1/junos -type f -name '*yang' -exec cp {} /tmp/junos_19.4R1/ \\;
146     OperatingSystem.Run    cp yang/19.4/19.4R1/common/* /tmp/junos_19.4R1/
147     OperatingSystem.List Directory    /tmp/junos_19.4R1/
148     [Return]    /tmp/junos_19.4R1