Add global rpc ha scenarion for frozen/stopped/paused node
[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     [Documentation]    Prepare both FailFast and Karaf logging, log that the caller suite has started.
27     ...    This keyword is to be used in suite setup, and without it the other keywords may not work properly.
28     FailFast.Do_Not_Fail_Fast_From_Now_On
29     KarafKeywords.Setup Karaf Keywords
30     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Test_Suite_Start_To_Controller_Karaf
31
32 Setup_Test_With_Logging_And_Fast_Failing
33     [Arguments]    ${member_index_list}=${EMPTY}
34     [Documentation]    Test case setup which skips on previous failure. If not, logs test case name to Karaf log.
35     ...    Recommended to be used as the default test case setup.
36     FailFast.Fail_This_Fast_On_Previous_Error
37     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf    member_index_list=${member_index_list}
38
39 Setup_Test_With_Logging_And_Without_Fast_Failing
40     [Arguments]    ${member_index_list}=${EMPTY}
41     [Documentation]    Test case setup which explicitly ignores previous failure and logs test case name to Karaf log.
42     ...    Needed if the recommended default is to be overriden.
43     FailFast.Run_Even_When_Failing_Fast
44     BuiltIn.Run Keyword And Ignore Error    KarafKeywords.Log_Testcase_Start_To_Controller_Karaf    member_index_list=${member_index_list}
45
46 Setup_Logging_For_Debug_Purposes_On_List_Or_All
47     [Arguments]    ${log_level}    ${loggers_list}    ${member_index_list}=${EMPTY}
48     [Documentation]    Set the log level for given loggers on node nodes of the cluster
49     : FOR    ${logger}    IN    @{loggers_list}
50     \    ClusterManagement.Run_Karaf_Command_On_List_Or_All    log:set ${log_level} ${logger}    member_index_list=${member_index_list}
51
52 Set_Known_Bug_Id
53     [Arguments]    ${id}
54     [Documentation]    Tell the Teardown keywords that any failure from now on is due to the specified known bug.
55     Set_Suite_Variable    ${SetupUtils__Known_Bug_ID}    ${id}
56
57 Set_Unknown_Bug_Id
58     [Documentation]    Tell the Teardown keywords that from now on there is no longer known bug causing the failure so it should use linked bugs.
59     Set_Known_Bug_Id    ${EMPTY}
60
61 SetupUtils__Report_Bugs_Causing_Failure
62     BuiltIn.Run_Keyword_If    '${SetupUtils__Known_Bug_ID}' != ''    Utils.Report_Failure_Due_To_Bug    ${SetupUtils__Known_Bug_ID}
63     BuiltIn.Run_Keyword_And_Return_If    '${SetupUtils__Known_Bug_ID}' != ''    Set_Known_Bug_Id    ${EMPTY}
64     Utils.Report_Failure_And_Point_To_Linked_Bugs
65
66 Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
67     [Documentation]    Test case teardown. Show linked bugs and start fast failing in case of failure.
68     BuiltIn.Run_Keyword_If_Test_Failed    BuiltIn.Set_Suite_Variable    ${SuiteFastFail}    True
69     SetupUtils__Report_Bugs_Causing_Failure
70
71 Teardown_Test_Show_Bugs_If_Test_Failed
72     [Documentation]    Test case teardown. Show linked bugs in case of failure.
73     SetupUtils__Report_Bugs_Causing_Failure