Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / libraries / WaitForFailure.robot
1 *** Settings ***
2 Documentation     Robot keyword library (Resource) for catching a later failure in temporarily passing repeated check.
3 ...
4 ...               Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...
11 ...               Terminology:
12 ...               "cell_sequence" is a sequence of Robot cells, usually executable.
13 ...               "keyword" is a first cell in that sequence, entry point of execution,
14 ...               the item defined in Keywords table (or in library) which may take arguments (the rest of cell sequence).
15 ...               "Keyword" may refer to keyword or executable cell sequence, or both, depending on context.
16
17 *** Keywords ***
18 Log_Failable_Keyword
19     [Arguments]    @{cell_sequence}
20     [Documentation]    Execute failable Keyword. Log the resulting value when it does not fail.
21     ${result}=    BuiltIn.Run_Keyword    @{cell_sequence}
22     BuiltIn.Log    ${result}
23     [Return]    ${result}
24
25 Keyword_Should_Fail_In_Any_Way
26     [Arguments]    @{cell_sequence}
27     [Documentation]    Try to run the Keyword and Log the result. Pass and return the error on any failure, Fail otherwise.
28     ${error}=    BuiltIn.Run_Keyword_And_Expect_Error    *    Log_Failable_Keyword    @{cell_sequence}
29     # '*' means we really catch all types of errors.
30     [Return]    ${error}
31
32 Confirm_Keyword_Fails_Within_Timeout
33     [Arguments]    ${timeout}    ${refresh}    @{cell_list}
34     [Documentation]    Some Keywords need several tries to finally fail, this keyword passes if and only if the failure ultimately happens.
35     # Arguments with default values interact badly with varargs, so using WUKS argument style.
36     ${error}=    BuiltIn.Wait_Until_Keyword_Succeeds    ${timeout}    ${refresh}    Keyword_Should_Fail_In_Any_Way    @{cell_list}
37
38 Verify_Keyword_Does_Not_Fail_Within_Timeout
39     [Arguments]    ${timeout}    ${refresh}    @{cell_list}
40     [Documentation]    Some checks report false success for a short time. This keyword verifies no failure does happen within timeout period.
41     ...    This keyword does not report the return value of the cell list execution.
42     BuiltIn.Run_Keyword_And_Expect_Error    *    Confirm_Keyword_Fails_Within_Timeout    ${timeout}    ${refresh}    @{cell_list}
43     # TODO: '*' means we are not sure about formatting of ${timeout}. Check whether Robot can print it for us.