Update Robot Framework format - step 14
[integration/test.git] / csit / suites / sxp / performance / 010_ConnectivityTests.robot
1 *** Settings ***
2 Documentation       Test suite measuring connectivity speed.
3
4 Library             ../../../libraries/Sxp.py
5 Resource            ../../../libraries/SxpLib.robot
6 Library             Remote    http://${ODL_SYSTEM_IP}:8270/ConnectionTestLibrary    WITH NAME    ConnectionTestLibrary
7
8 Suite Setup         Setup SXP Environment
9 Suite Teardown      Clean SXP Environment
10 Test Teardown       Test Clean
11
12
13 *** Variables ***
14 ${TEST_SAMPLES}     5
15
16
17 *** Test Cases ***
18 Connectivity Test
19     [Documentation]    Test covering speed of connecting to remote peers without TCP-MD5
20     Check Connectivity    80    70    30
21
22 Connectivity TCP-MD5 Test
23     [Documentation]    Test covering speed of connecting to remote peers with TCP-MD5
24     Check Connectivity    80    70    10    passwd
25
26
27 *** Keywords ***
28 Setup Topology
29     [Documentation]    Adds connections to local and remote nodes
30     [Arguments]    ${connections}    ${PASSWORD}    ${version}
31     FOR    ${num}    IN RANGE    0    ${connections}
32         ${address}    Get Ip From Number    ${num}    2130771968
33         Add Connection    ${version}    listener    ${address}    64999    password=${PASSWORD}
34         ConnectionTestLibrary.Add Node    ${address}    ${version}    64999    ${PASSWORD}
35         ConnectionTestLibrary.Add Connection    ${version}    speaker    127.0.0.1    64999    ${PASSWORD}
36         ...    ${address}
37     END
38
39 Check Connectivity
40     [Documentation]    Starts SXP nodes and checks if peers are already connected, this is repeated N times
41     [Arguments]    ${peers}    ${min_peers}    ${min_speed}    ${PASSWORD}=${EMPTY}    ${version}=version4
42     @{ITEMS}    Create List
43     FOR    ${num}    IN RANGE    0    ${TEST_SAMPLES}
44         Setup Topology    ${peers}    ${PASSWORD}    ${version}
45         ConnectionTestLibrary.Start Nodes
46         ConnectionTestLibrary.Initiate Connecting    ${min_peers}
47         ${ELEMENT}    Wait Until Keyword Succeeds    120    1    Check Connections Connected
48         Append To List    ${ITEMS}    ${ELEMENT}
49         Test Clean
50     END
51     ${connectivity_speed}    Get Average Of Items    ${ITEMS}
52     Log    Average connectivity speed ${connectivity_speed} connection/s.
53     Should Be True    ${connectivity_speed} > ${min_speed}
54
55 Check Connections Connected
56     [Documentation]    Checking if Peers were connected and return connectivity speed
57     ${peers_connected}    ConnectionTestLibrary.Get Connected Peers
58     ${connect_time}    ConnectionTestLibrary.Get Connect Time
59     Should Not Be Equal As Numbers    ${connect_time}    0
60     ${connectivity_speed}    Evaluate    ${peers_connected}/${connect_time}
61     RETURN    ${connectivity_speed}
62
63 Test Clean
64     ConnectionTestLibrary.Clean Library
65     Clean Connections