Replace deprecated variables in suites/openflowplugin (1).
[integration/test.git] / csit / suites / openflowplugin / Bug_Validation / 2429.robot
1 *** Settings ***
2 Documentation     OF Handshake threads should be closed if the connection has a
3 ...               failure. This bug was fixed in the Helium SR3 release but
4 ...               persisted in to the Lithium release. Once fixed, this will
5 ...               catch any future regressions
6 Metadata          https://bugs.opendaylight.org/show_bug.cgi?id=2429    ${EMPTY}
7 Library           OperatingSystem
8 Library           SSHLibrary
9 Library           Process
10 Resource          ../../../libraries/Utils.robot
11 Variables         ../../../variables/Variables.py
12
13 *** Variables ***
14 ${openflow_port}    6633
15 ${number_ofconnections_to_fail}    600
16 ${margin_of_error}    0.05    # percentage
17
18 *** Test Cases ***
19 Bug_2429
20     [Documentation]    Using the "nc" tool, a number of connections to the ${openflow_port}
21     ...    will be opened and closed to simulate a failed OF handshake. The java threadcount
22     ...    will be compared before and after to ensure that there are no thread leaks. Since
23     ...    it's reasonable for other valid threads to be started (or stopped) during the test
24     ...    a larger number of failed connections will be used and a small margin of error will
25     ...    determine if the test is a PASS or FAIL
26     Log Environment Details
27     ${controller_pid}=    Get Process ID Based On Regex On Remote System    ${ODL_SYSTEM_IP}    java.*distribution.*karaf    ${CONTROLLER_USER}
28     Should Match Regexp    ${controller_pid}    [0-9]+    PID was not discovered
29     ${starting_thread_count}=    Get Process Thread Count On Remote System    ${ODL_SYSTEM_IP}    ${controller_pid}    ${CONTROLLER_USER}
30     Repeat Keyword    ${number_ofconnections_to_fail}    Start Process    nc    -w    1    ${ODL_SYSTEM_IP}
31     ...    ${openflow_port}
32     Run    pkill -f 'nc -w'
33     Log Environment Details
34     ${ending_thread_count}=    Get Process Thread Count On Remote System    ${ODL_SYSTEM_IP}    ${controller_pid}    ${CONTROLLER_USER}
35     Log Environment Details
36     Log    starting count: ${starting_thread_count}\nending count: ${ending_thread_count}
37     ${acceptable_thread_count}=    Evaluate    ${starting_thread_count} + (${number_of_connections_to_fail} * ${margin_of_error})
38     Should Be True    ${ending_thread_count} <= ${acceptable_thread_count}    Final thread count of ${ending_thread_count} exceeds acceptable count: ${acceptable_thread_count}
39     [Teardown]    Report_Failure_Due_To_Bug    2429
40
41 *** Keywords ***
42 Log Environment Details
43     [Documentation]    Will display relevant details of the test environement to help aid debugging efforts if
44     ...    needed in the future.
45     ${output}=    Get Process ID Based On Regex On Remote System    ${ODL_SYSTEM_IP}    java.*distribution.*karaf    ${CONTROLLER_USER}
46     Log    ${output}
47     ${output}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    netstat -na | grep 6633    ${CONTROLLER_USER}
48     Log    ${output}