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