Migrate Get Requests invocations(libraries)
[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
8 Library             OperatingSystem
9 Library             SSHLibrary
10 Library             Process
11 Resource            ../../../libraries/Utils.robot
12 Resource            ../../../variables/Variables.robot
13
14
15 *** Variables ***
16 ${openflow_port}                    6633
17 ${number_ofconnections_to_fail}     600
18 ${margin_of_error}                  0.05    # percentage
19
20
21 *** Test Cases ***
22 Bug_2429
23     [Documentation]    Using the "nc" tool, a number of connections to the ${openflow_port}
24     ...    will be opened and closed to simulate a failed OF handshake. The java threadcount
25     ...    will be compared before and after to ensure that there are no thread leaks. Since
26     ...    it's reasonable for other valid threads to be started (or stopped) during the test
27     ...    a larger number of failed connections will be used and a small margin of error will
28     ...    determine if the test is a PASS or FAIL
29     Log Environment Details
30     ${controller_pid}=    Get Process ID Based On Regex On Remote System
31     ...    ${ODL_SYSTEM_IP}
32     ...    java.*karaf
33     ...    ${ODL_SYSTEM_USER}
34     Should Match Regexp    ${controller_pid}    [0-9]+    PID was not discovered
35     ${starting_thread_count}=    Get Process Thread Count On Remote System
36     ...    ${ODL_SYSTEM_IP}
37     ...    ${controller_pid}
38     ...    ${ODL_SYSTEM_USER}
39     Repeat Keyword    ${number_ofconnections_to_fail}    Start Process    nc    -w    1    ${ODL_SYSTEM_IP}
40     ...    ${openflow_port}
41     Run    pkill -f 'nc -w'
42     Log Environment Details
43     ${ending_thread_count}=    Get Process Thread Count On Remote System
44     ...    ${ODL_SYSTEM_IP}
45     ...    ${controller_pid}
46     ...    ${ODL_SYSTEM_USER}
47     Log Environment Details
48     Log    starting count: ${starting_thread_count}\nending count: ${ending_thread_count}
49     ${acceptable_thread_count}=    Evaluate
50     ...    ${starting_thread_count} + (${number_of_connections_to_fail} * ${margin_of_error})
51     Should Be True
52     ...    ${ending_thread_count} <= ${acceptable_thread_count}
53     ...    Final thread count of ${ending_thread_count} exceeds acceptable count: ${acceptable_thread_count}
54     [Teardown]    Report_Failure_Due_To_Bug    2429
55
56
57 *** Keywords ***
58 Log Environment Details
59     [Documentation]    Will display relevant details of the test environement to help aid debugging efforts if
60     ...    needed in the future.
61     ${output}=    Get Process ID Based On Regex On Remote System
62     ...    ${ODL_SYSTEM_IP}
63     ...    java.*karaf
64     ...    ${ODL_SYSTEM_USER}
65     Log    ${output}
66     ${output}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    netstat -na | grep 6633    ${ODL_SYSTEM_USER}
67     Log    ${output}