da2d30d49fd0190ddcdb479e037b37d2c10b4eae
[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=1000s
19 Library           ../../../libraries/TopologyNetconfNodes.py
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}    100000
29 ${DEVICE_INCREMENT}    5000
30 ${DEVICE_NAME_BASE}    netconf-scaling-device
31 ${DEVICE_TYPE}    full-uri-device
32 ${BASE_PORT}      17830
33 ${NUM_WORKERS}    500
34 ${TIMEOUT_FACTOR}    3
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     ${INSTALL_TESTTOOL} =    Set Variable If    '${IS_KARAF_APPL}' == 'False'    False    True
52     ${TESTTOOL_EXECUTABLE} =    Set Variable If    '${IS_KARAF_APPL}' == 'False'    ${NETCONF_FILENAME}    ${EMPTY}
53     ${SCHEMAS} =    Set Variable If    '${IS_KARAF_APPL}' == 'False'    ${CURDIR}/../../../variables/netconf/CRUD/schemas    ${schema_dir}
54     ${restconf_url} =    BuiltIn.Set_Variable    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/rests
55     ${device_names} =    BuiltIn.Set_Variable    []
56     FOR    ${devices}    IN RANGE    ${start}    ${stop+1}    ${increment}
57         ${timeout} =    BuiltIn.Evaluate    ${devices}*${TIMEOUT_FACTOR}
58         ${timeout} =    Set Variable If    ${timeout} > ${MIN_CONNECT_TIMEOUT}    ${timeout}    ${MIN_CONNECT_TIMEOUT}
59         Log To Console    Starting Iteration with ${devices} devices
60         Run Keyword If    "${INSTALL_TESTTOOL}"=="True"    NetconfKeywords.Install_And_Start_Testtool    debug=false    schemas=${schema_dir}    device-count=${devices}    log_response=False
61         ...    ELSE    NetconfKeywords.Start_Testtool    ${TESTTOOL_EXECUTABLE}    debug=false    schemas=${SCHEMAS}    device-count=${devices}    log_response=False
62         ${devices_to_configure} =    BuiltIn.Evaluate    ${devices} - len(${device_names})
63         ${first_id} =    BuiltIn.Evaluate    len(${device_names}) + 1
64         ${device_names} =    TopologyNetconfNodes.Configure Device Range    restconf_url=${restconf_url}    device_name_prefix=${DEVICE_NAME_BASE}
65         ...    device_ipaddress=${TOOLS_SYSTEM_IP}    device_port=17830    device_count=${devices_to_configure}    first_device_id=${first_id}
66         TopologyNetconfNodes.Await Devices Connected    restconf_url=${restconf_url}    device_names=${device_names}    deadline_seconds=${timeout}
67         ${status}    ${result} =    Run Keyword And Ignore Error    Issue_Requests_On_Devices    ${TOOLS_SYSTEM_IP}    ${devices}    ${NUM_WORKERS}
68         Exit For Loop If    '${status}' == 'FAIL'
69         ${maximum_devices} =    Set Variable    ${devices}
70         NetconfKeywords.Stop_Testtool
71     END
72     [Teardown]    Run Keywords    NetconfKeywords.Stop_Testtool
73     ...    AND    Collect_Data_Points    ${maximum_devices}
74
75 *** Keywords ***
76 Collect_Data_Points
77     [Arguments]    ${devices}
78     [Documentation]    Parse and Log relevant information when Scale test finishes
79     OperatingSystem.Append To File    ${DEVICES_RESULT_FILE}    Max Devices\n
80     OperatingSystem.Append To File    ${DEVICES_RESULT_FILE}    ${devices}\n
81
82 Issue_Requests_On_Devices
83     # FIXME: this keyword is nearly duplicated in the getmulti.robot suite. need to move it to a common lib
84     [Arguments]    ${client_ip}    ${expected_count}    ${worker_count}
85     [Documentation]    Spawn the specified count of worker threads to issue a GET request to each of the devices.
86     ${current_ssh_connection}=    SSHLibrary.Get Connection
87     SSHLibrary.Open_Connection    ${client_ip}
88     SSHKeywords.Flexible_Mininet_Login
89     SSHLibrary.Write    python getter.py --odladdress=${ODL_SYSTEM_IP} --count=${expected_count} --name=${device_name_base} --workers=${worker_count}
90     SSHLibrary.Read_Until    ${DEFAULT_LINUX_PROMPT_STRICT}
91     SSHLibrary.Write    python getter.py --odladdress=${ODL_SYSTEM_IP} --count=${expected_count} --name=${device_name_base} --workers=${worker_count}
92     FOR    ${number}    IN RANGE    1    ${expected_count}+1
93         Read_Python_Tool_Operation_Result    ${number}
94     END
95     SSHLibrary.Read_Until    ${DEFAULT_LINUX_PROMPT_STRICT}
96     SSHLibrary.Close_Connection
97     SSHKeywords.Restore Current SSH Connection From Index    ${current_ssh_connection.index}
98
99 Setup_Everything
100     [Documentation]    Setup everything needed for the test cases.
101     # Setup resources used by the suite.
102     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${REST_API}    auth=${AUTH}
103     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
104     SetupUtils.Setup_Utils_For_Setup_And_Teardown
105     NetconfKeywords.Setup_Netconf_Keywords
106     # Deploy testing tools.
107     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/netconf_tools/getter.py
108     SSHLibrary.Put_File    ${CURDIR}/../../../libraries/AuthStandalone.py
109     ${device_type}=    BuiltIn.Set_Variable_If    ${USE_NETCONF_CONNECTOR}==${True}    default    ${device_type}
110     BuiltIn.Set_Suite_Variable    ${device_type}
111
112 Teardown_Everything
113     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
114     RequestsLibrary.Delete_All_Sessions
115     NetconfKeywords.Stop_Testtool
116
117 Read_Python_Tool_Operation_Result
118     [Arguments]    ${number}
119     [Documentation]    Read and process a report line emitted from the Python tool that corresponds to the device with the given number.
120     ${test}=    SSHLibrary.Read_Until_Regexp    \\n
121     ${test}=    String.Split_String    ${test}    |
122     ${response}=    Collections.Get_From_List    ${test}    0
123     ${message}=    Collections.Get_From_List    ${test}    1
124     BuiltIn.Run_Keyword_If    '${response}' == 'ERROR'    Fail    Error getting data: ${message}
125     ${start}=    Collections.Get_From_List    ${test}    1
126     ${stop}=    Collections.Get_From_List    ${test}    2
127     ${ellapsed}=    Collections.Get_From_List    ${test}    3
128     BuiltIn.Log    DATA REQUEST RESULT: Device=${number} StartTime=${start} StopTime=${stop} EllapsedTime=${ellapsed}
129     ${data}=    Collections.Get_From_List    ${test}    4
130     ${expected}=    Run Keyword If    '${IS_KARAF_APPL}' == 'False'    BuiltIn.Set_Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"/>'
131     ...    ELSE    BuiltIn.Set_Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"></data>'
132     Should Be Equal As Strings    ${data}    ${expected}
133
134 Check_Device_Deconfigured
135     [Arguments]    ${current_name}    ${log_response}=True
136     [Documentation]    Operation for making sure the device is really deconfigured.
137     KarafKeywords.Log_Message_To_Controller_Karaf    Waiting for device ${current_name} to disappear
138     NetconfKeywords.Wait_Device_Fully_Removed    ${current_name}    period=0.5s    timeout=120s    log_response=${log_response}
139     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} removed
140
141 Get Juniper Device Schemas
142     OperatingSystem.Run    git clone https://github.com/Juniper/yang.git
143     OperatingSystem.Run    mkdir /tmp/junos_19.4R1
144     OperatingSystem.Run    find yang/19.4/19.4R1/junos -type f -name '*yang' -exec cp {} /tmp/junos_19.4R1/ \\;
145     OperatingSystem.Run    cp yang/19.4/19.4R1/common/* /tmp/junos_19.4R1/
146     OperatingSystem.List Directory    /tmp/junos_19.4R1/
147     [Return]    /tmp/junos_19.4R1