Step 2: Move test folder to root
[integration/test.git] / csit / suites / openflowplugin / Longevity / 020__longevity_switches_links.robot
1 *** Settings ***
2 Documentation     Beta Version of the Longevity Test.  Currently:
3 ...               1.  runs one iteration of the switch scale test based on ${NUM_SWITCHES}
4 ...               2.  runs one iteration of the link scale test based on ${NUM_LINKS}
5 ...               Steps 1 and 2 are run in a psuedo infinite loop and before each loop is
6 ...               run, a time check is made against the ${TEST_LENGTH}. If the test duration
7 ...               has expired, the loop is exited and the test is marked PASS
8 ...
9 ...               If either of steps 1 or 2 fail to reach their configured value of ${NUM_SWITCHES}
10 ...               or ${NUM_LINKS} the test will exit immediately and not continue.
11 Suite Setup       Longevity Suite Setup
12 Suite Teardown    Longevity Suite Teardown
13 Library           RequestsLibrary
14 Library           DateTime
15 Variables         ../../../variables/Variables.py
16 Resource          ../../../libraries/Scalability.robot
17
18 *** Variables ***
19 ${NUM_SWITCHES}           200
20 ${NUM_LINKS}              20
21 ${TEST_LENGTH}            2 hours
22
23
24 *** Test Cases ***
25 Longevity Test
26     [Documentation]    Uses switch and link scale test functionality in a loop for given period of time
27     #  This loop is not infinite, so going "sufficiently large" for now.
28     : FOR  ${i}  IN RANGE    1    65536
29     \    ${expiration_flag}=    Check If There Is A Reason To Exit Test Or If Duration Has Expired
30     \    Exit For Loop If    "${expiration_flag}" == "True"
31     \    ${switch_count}=    Find Max Switches    ${NUM_SWITCHES}     ${NUM_SWITCHES}     ${NUM_SWITCHES}
32     \    Check If There Is A Reason To Exit Test Or If Duration Has Expired    ${switch_count}    ${NUM_SWITCHES}    Switch count not correct
33     \    ${link_count}=    Find Max Links    ${NUM_LINKS}    ${NUM_LINKS}    ${NUM_LINKS}
34     \    Check If There Is A Reason To Exit Test Or If Duration Has Expired    ${link_count}    ${NUM_LINKS}    Link count not correct
35
36 *** Keywords ***
37 Check If There Is A Reason To Exit Test Or If Duration Has Expired
38     [Documentation]    In order to simplify the main test case, this keyword will make all the neccessary checks
39     ...    to determine if the test should FAIL and quit because of some problem.  It will also return a bool to
40     ...    indicate if the requested duration of the longevity test has elapsed.  The caller does not have to use
41     ...    that return value.
42     [Arguments]    ${comparator1}=1    ${comparator2}=1    ${comparator_failure_message}=null
43     Should Be Equal    ${comparator1}    ${comparator2}    ${comparator_failure_message}
44     Verify Controller Is Not Dead    ${CONTROLLER}
45     ${is_expired}=    Check If Test Duration Is Expired
46     [Return]    ${is_expired}
47
48 Check If Test Duration Is Expired
49     [Documentation]    Compares the current time with that of the suite variable ${end_time} to determine if the
50     ...    test duration has expired.
51     ${test_is_expired}=  Set Variable    False
52     ${current_time}=    Get Current Date
53     ${current_time}=    Convert Date    ${current_time}    epoch
54     ${test_is_expired}=    Set Variable If    "${current_time}" > "${end_time}"    True
55     [Return]    ${test_is_expired}
56
57 Longevity Suite Setup
58     [Documentation]    In addtion to opening the REST session to the controller, the ${end_time} that this
59     ...    test should not exceed is calculated and made in to a suite wide variable.
60     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
61     ${mininet_conn_id}=    Open Connection    ${MININET}    prompt=${DEFAULT_LINUX_PROMPT}
62     Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
63     Log     Copying ${CREATE_FULLYMESH_TOPOLOGY_FILE_PATH} file to Mininet VM
64     Put File  ${CURDIR}/../../../${CREATE_FULLYMESH_TOPOLOGY_FILE_PATH}
65     Close Connection
66     ${start_time}=    Get Current Date
67     ${end_time}=    Add Time To Date    ${start_time}    ${TEST_LENGTH}
68     ${end_time}=    Convert Date    ${end_time}    epoch
69     Set Suite Variable    ${end_time}
70
71 Longevity Suite Teardown
72     [Documentation]    Any cleanup neccessary to allow this test to be run in a static environment should go here
73     ...    Currently, the same steps needed for the scalability suites should suffice.
74     Scalability Suite Teardown