b9eb4f67d9151a44833ae5529228670973ab50b8
[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 Suite Setup       Setup_Everything
18 Suite Teardown    Teardown_Everything
19 Library           Collections
20 Library           String
21 Library           SSHLibrary    timeout=10s
22 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
23 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
24 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
25 Resource          ${CURDIR}/../../../libraries/Utils.robot
26 Variables         ${CURDIR}/../../../variables/Variables.py
27
28 *** Variables ***
29 ${DEVICE_COUNT}    500
30 ${WORKER_COUNT}    10
31 ${device_name_base}    netconf-scaling-device
32 ${base_port}      17830
33
34 *** Test Cases ***
35 Start_Test_Tool
36     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
37     NetconfKeywords.Install_And_Start_Testtool    device-count=${DEVICE_COUNT}    mdsal=false
38
39 Configure_Devices_On_Netconf
40     [Documentation]    Make requests to configure the testtool devices.
41     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*10
42     NetconfKeywords.Perform_Operation_On_Each_Device    Configure_Device    timeout=${timeout}
43
44 Wait_For_Devices_To_Connect
45     [Documentation]    Wait for the devices to become connected.
46     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*10
47     NetconfKeywords.Perform_Operation_On_Each_Device    Wait_Connected    timeout=${timeout}
48
49 Issue_Requests_On_Devices
50     [Documentation]    Spawn the specified count of worker threads to issue a GET request to each of the devices.
51     ${current_ssh_connection}=    SSHLibrary.Get Connection
52     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
53     Utils.Flexible_Mininet_Login
54     SSHLibrary.Write    python getter.py --odladdress=${ODL_SYSTEM_IP} --count=${DEVICE_COUNT} --name=${device_name_base} --workers=${WORKER_COUNT}
55     : FOR    ${number}    IN RANGE    1    ${DEVICE_COUNT}+1
56     \    Read_Python_Tool_Operation_Result    ${number}
57     SSHLibrary.Read_Until_Prompt
58     SSHLibrary.Close_Connection
59     Restore Current SSH Connection From Index    ${current_ssh_connection.index}
60
61 Deconfigure_Devices
62     [Documentation]    Make requests to deconfigure the testtool devices.
63     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*10
64     NetconfKeywords.Perform_Operation_On_Each_Device    Deconfigure_Device    timeout=${timeout}
65     [Teardown]    Report_Failure_Due_To_Bug    4547
66
67 Check_Devices_Are_Deconfigured
68     [Documentation]    Check there are no netconf connectors or other stuff related to the testtool devices.
69     ${timeout}=    BuiltIn.Evaluate    ${DEVICE_COUNT}*10
70     NetconfKeywords.Perform_Operation_On_Each_Device    Check_Device_Deconfigured    timeout=${timeout}
71
72 *** Keywords ***
73 Setup_Everything
74     [Documentation]    Setup everything needed for the test cases.
75     # Setup resources used by the suite.
76     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
77     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
78     SetupUtils.Setup_Utils_For_Setup_And_Teardown
79     NetconfKeywords.Setup_Netconf_Keywords
80     # Deploy testing tools.
81     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/netconf_tools/getter.py
82     SSHLibrary.Put_File    ${CURDIR}/../../../libraries/AuthStandalone.py
83
84 Teardown_Everything
85     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
86     Teardown_Netconf_Via_Restconf
87     RequestsLibrary.Delete_All_Sessions
88     NetconfKeywords.Stop_Testtool
89
90 Configure_Device
91     [Arguments]    ${current_name}
92     [Documentation]    Operation for configuring the device.
93     KarafKeywords.Log_Message_To_Controller_Karaf    Configuring device ${current_name} to Netconf
94     NetconfKeywords.Configure_Device_In_Netconf    ${current_name}    device_port=${current_port}
95     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} configured
96
97 Wait_Connected
98     [Arguments]    ${current_name}
99     [Documentation]    Operation for waiting until the device is connected.
100     KarafKeywords.Log_Message_To_Controller_Karaf    Waiting for device ${current_name} to connect
101     NetconfKeywords.Wait_Device_Connected    ${current_name}    period=0.5s    timeout=120s
102     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} connected
103
104 Read_Python_Tool_Operation_Result
105     [Arguments]    ${number}
106     [Documentation]    Read and process a report line emitted from the Python tool that corresponds to the device with the given number.
107     ${test}=    SSHLibrary.Read_Until_Regexp    \\n
108     ${test}=    String.Split_String    ${test}    |
109     ${response}=    Collections.Get_From_List    ${test}    0
110     ${message}=    Collections.Get_From_List    ${test}    1
111     BuiltIn.Run_Keyword_If    '${response}' == 'ERROR'    Fail    Error getting data: ${message}
112     ${start}=    Collections.Get_From_List    ${test}    1
113     ${stop}=    Collections.Get_From_List    ${test}    2
114     ${ellapsed}=    Collections.Get_From_List    ${test}    3
115     BuiltIn.Log    DATA REQUEST RESULT: Device=${number} StartTime=${start} StopTime=${stop} EllapsedTime=${ellapsed}
116     ${data}=    Collections.Get_From_List    ${test}    4
117     ${expected}=    BuiltIn.Set_Variable    '<data xmlns="${ODL_NETCONF_NAMESPACE}"></data>'
118     BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
119
120 Deconfigure_Device
121     [Arguments]    ${current_name}
122     [Documentation]    Operation for deconfiguring the device.
123     KarafKeywords.Log_Message_To_Controller_Karaf    Deconfiguring device ${current_name}
124     NetconfKeywords.Remove_Device_From_Netconf    ${current_name}
125     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} deconfigured
126
127 Check_Device_Deconfigured
128     [Arguments]    ${current_name}
129     [Documentation]    Operation for making sure the device is really deconfigured.
130     KarafKeywords.Log_Message_To_Controller_Karaf    Waiting for device ${current_name} to disappear
131     NetconfKeywords.Wait_Device_Fully_Removed    ${current_name}    period=0.5s    timeout=120s
132     KarafKeywords.Log_Message_To_Controller_Karaf    Device ${current_name} removed