Remove Start/Stop Suite from Utils.robot
[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 Resource          ../../../libraries/KarafKeywords.robot
17
18 *** Variables ***
19 ${NUM_SWITCHES}    200
20 ${SUSTAIN_TIME}    60
21 ${TEST_LENGTH}    2 hours
22 ${KARAF_LOG_LEVEL}    ERROR
23
24 *** Test Cases ***
25 Longevity Test
26     [Documentation]    Uses switch scalability 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}    ${SUSTAIN_TIME}
32     \    Check If There Is A Reason To Exit Test Or If Duration Has Expired    ${switch_count}    ${NUM_SWITCHES}    Switch count not correct
33
34 *** Keywords ***
35 Check If There Is A Reason To Exit Test Or If Duration Has Expired
36     [Arguments]    ${comparator1}=1    ${comparator2}=1    ${comparator_failure_message}=null
37     [Documentation]    In order to simplify the main test case, this keyword will make all the neccessary checks
38     ...    to determine if the test should FAIL and quit because of some problem. It will also return a bool to
39     ...    indicate if the requested duration of the longevity test has elapsed. The caller does not have to use
40     ...    that return value.
41     Should Be Equal    ${comparator1}    ${comparator2}    ${comparator_failure_message}
42     Verify Controller Is Not Dead    ${ODL_SYSTEM_IP}
43     Verify Controller Has No Null Pointer Exceptions    ${ODL_SYSTEM_IP}
44     ${is_expired}=    Check If Test Duration Is Expired
45     [Return]    ${is_expired}
46
47 Check If Test Duration Is Expired
48     [Documentation]    Compares the current time with that of the suite variable ${end_time} to determine if the
49     ...    test duration has expired.
50     ${test_is_expired}=    Set Variable    False
51     ${current_time}=    Get Current Date
52     ${current_time}=    Convert Date    ${current_time}    epoch
53     ${test_is_expired}=    Set Variable If    "${current_time}" > "${end_time}"    True
54     [Return]    ${test_is_expired}
55
56 Longevity Suite Setup
57     [Documentation]    In addtion to opening the REST session to the controller, the ${end_time} that this
58     ...    test should not exceed is calculated and made in to a suite wide variable.
59     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
60     Wait Until Keyword Succeeds    3x    1s    KarafKeywords.Issue Command On Karaf Console    log:set ${KARAF_LOG_LEVEL}
61     ${start_time}=    Get Current Date
62     ${end_time}=    Add Time To Date    ${start_time}    ${TEST_LENGTH}
63     ${end_time}=    Convert Date    ${end_time}    epoch
64     Set Suite Variable    ${end_time}
65
66 Longevity Suite Teardown
67     [Documentation]    Any cleanup neccessary to allow this test to be run in a static environment should go here
68     ...    Currently, the same steps needed for the scalability suites should suffice.
69     Scalability Suite Teardown