Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / libraries / SetupUtils.robot
1 *** Settings ***
2 Documentation     Simple resource with setup keywords which combine FailFast and Karaf logging.
3 ...
4 ...               Copyright (c) 2015-2017 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 ...               In order for most keywords to work properly, the initialization keyword
12 ...               Setup_Utils_For_Setup_And_Teardown has to be called, best in sute setup.
13 ...               This initialization also initializes dependend Resources,
14 ...               (most important KarafKeywords) whcih may initialize their dependecies as well.
15 ...
16 ...               See FailFast.robot documentation for intricacies of that library.
17 Resource          ${CURDIR}/FailFast.robot
18 Resource          ${CURDIR}/KarafKeywords.robot
19 Resource          ${CURDIR}/Utils.robot
20
21 *** Variables ***
22 ${SetupUtils__Known_Bug_ID}    ${EMPTY}
23
24 *** Keywords ***
25 Setup_Utils_For_Setup_And_Teardown
26     [Arguments]    ${http_timeout}=${DEFAULT_TIMEOUT_HTTP}
27     [Documentation]    Prepare both FailFast and Karaf logging, log that the caller suite has started.
28     ...    This keyword is to be used in suite setup, and without it the other keywords may not work properly.
29     FailFast.Do_Not_Fail_Fast_From_Now_On
30     KarafKeywords.Setup Karaf Keywords    http_timeout=${http_timeout}
31     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Test_Suite_Start_To_Controller_Karaf
32
33 Setup_Test_With_Logging_And_Fast_Failing
34     [Arguments]    ${member_index_list}=${EMPTY}
35     [Documentation]    Test case setup which skips on previous failure. If not, logs test case name to Karaf log.
36     ...    Recommended to be used as the default test case setup.
37     FailFast.Fail_This_Fast_On_Previous_Error
38     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf    member_index_list=${member_index_list}
39
40 Setup_Test_With_Logging_And_Without_Fast_Failing
41     [Arguments]    ${member_index_list}=${EMPTY}
42     [Documentation]    Test case setup which explicitly ignores previous failure and logs test case name to Karaf log.
43     ...    Needed if the recommended default is to be overriden.
44     FailFast.Run_Even_When_Failing_Fast
45     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf    member_index_list=${member_index_list}
46
47 Setup_Logging_For_Debug_Purposes_On_List_Or_All
48     [Arguments]    ${log_level}    ${loggers_list}    ${member_index_list}=${EMPTY}
49     [Documentation]    Set the log level for given loggers on node nodes of the cluster
50     FOR    ${logger}    IN    @{loggers_list}
51         ClusterManagement.Run_Karaf_Command_On_List_Or_All    log:set ${log_level} ${logger}    member_index_list=${member_index_list}
52     END
53
54 Set_Known_Bug_Id
55     [Arguments]    ${id}
56     [Documentation]    Tell the Teardown keywords that any failure from now on is due to the specified known bug.
57     Set_Suite_Variable    ${SetupUtils__Known_Bug_ID}    ${id}
58
59 Set_Unknown_Bug_Id
60     [Documentation]    Tell the Teardown keywords that from now on there is no longer known bug causing the failure so it should use linked bugs.
61     Set_Known_Bug_Id    ${EMPTY}
62
63 SetupUtils__Report_Bugs_Causing_Failure
64     BuiltIn.Run_Keyword_If    '${SetupUtils__Known_Bug_ID}' != ''    Utils.Report_Failure_Due_To_Bug    ${SetupUtils__Known_Bug_ID}
65     BuiltIn.Run_Keyword_And_Return_If    '${SetupUtils__Known_Bug_ID}' != ''    Set_Known_Bug_Id    ${EMPTY}
66     Utils.Report_Failure_And_Point_To_Linked_Bugs
67
68 Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
69     [Documentation]    Test case teardown. Show linked bugs and start fast failing in case of failure.
70     BuiltIn.Run_Keyword_If_Test_Failed    BuiltIn.Set_Suite_Variable    ${SuiteFastFail}    True
71     SetupUtils__Report_Bugs_Causing_Failure
72
73 Teardown_Test_Show_Bugs_If_Test_Failed
74     [Documentation]    Test case teardown. Show linked bugs in case of failure.
75     SetupUtils__Report_Bugs_Causing_Failure