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