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