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