Many library improvements.
[integration/test.git] / csit / libraries / SetupUtils.robot
1 *** Settings ***
2 Documentation     Simple resource with setup keywords which combine FailFast and Karaf logging.
3 ...
4 ...               See FailFast.robot documentation for intricacies of that library.
5 Resource          ${CURDIR}/FailFast.robot
6 Resource          ${CURDIR}/KarafKeywords.robot
7 Resource          ${CURDIR}/Utils.robot
8
9 *** Variables ***
10 ${SetupUtils__Known_Bug_ID}    ${EMPTY}
11
12 *** Keywords ***
13 Setup_Utils_For_Setup_And_Teardown
14     [Documentation]    Prepare both FailFast and karaf logging, to be used in suite setup.
15     FailFast.Do_Not_Fail_Fast_From_Now_On
16     BuiltIn.Comment    First connections to Karaf console may fail, so WUKS is used. TODO: Track as a Bug.
17     BuiltIn.Wait_Until_Keyword_Succeeds    3x    0.2s    KarafKeywords.Open_Controller_Karaf_Console_On_Background
18     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Test_Suite_Start_To_Controller_Karaf
19
20 Setup_Test_With_Logging_And_Fast_Failing
21     [Documentation]    Test case setup which skips on previous failure. If not, logs test case name to Karaf log.
22     ...    Recommended to be used as the default test case setup.
23     FailFast.Fail_This_Fast_On_Previous_Error
24     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
25
26 Setup_Test_With_Logging_And_Without_Fast_Failing
27     [Documentation]    Test case setup which explicitly ignores previous failure and logs test case name to Karaf log.
28     ...    Needed if the recommended default is to be overriden.
29     FailFast.Run_Even_When_Failing_Fast
30     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
31
32 Set_Known_Bug_Id
33     [Arguments]    ${id}
34     [Documentation]    Tell the Teardown keywords that any failure from now on is due to the specified known bug.
35     Set_Suite_Variable    ${SetupUtils__Known_Bug_ID}    ${id}
36
37 Set_Unknown_Bug_Id
38     [Documentation]    Tell the Teardown keywords that from now on there is no longer known bug causing the failure so it should use linked bugs.
39     Set_Known_Bug_Id    ${EMPTY}
40
41 SetupUtils__Report_Bugs_Causing_Failure
42     BuiltIn.Run_Keyword_If    '${SetupUtils__Known_Bug_ID}' != ''    Utils.Report_Failure_Due_To_Bug    ${SetupUtils__Known_Bug_ID}
43     BuiltIn.Run_Keyword_And_Return_If    '${SetupUtils__Known_Bug_ID}' != ''    Set_Known_Bug_Id    ${EMPTY}
44     Utils.Report_Failure_And_Point_To_Linked_Bugs
45
46 Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
47     [Documentation]    Test case teardown. Show linked bugs and start fast failing in case of failure.
48     BuiltIn.Run_Keyword_If_Test_Failed    BuiltIn.Set_Suite_Variable    ${SuiteFastFail}    True
49     SetupUtils__Report_Bugs_Causing_Failure
50
51 Teardown_Test_Show_Bugs_If_Test_Failed
52     [Documentation]    Test case teardown. Show linked bugs in case of failure.
53     SetupUtils__Report_Bugs_Causing_Failure