Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / controller / cluster_singleton / master_stability.robot
1 *** Settings ***
2 Documentation     Cluster Singleton testing: Master Stability
3 ...
4 ...               Copyright (c) 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 ...               Cluster Singleton service is designed to ensure that only one instance of an
11 ...               application is registered globally in the cluster.
12 ...               The goal is to establish the service operates correctly in face of application
13 ...               registration changing without moving the active instance.
14 Suite Setup       Setup_Keyword
15 Suite Teardown    SSHLibrary.Close_All_Connections
16 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
17 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
18 Default Tags      critical
19 Library           Collections
20 Library           SSHLibrary
21 Resource          ${CURDIR}/../../../libraries/controller/CsCommon.robot
22 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
23 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
25
26 *** Variables ***
27 ${STABILITY_TIMEOUT}    1m
28
29 *** Test Cases ***
30 Register_Singleton_Constant_On_Each_Node_And_Verify
31     [Documentation]    Register a candidate application on each node.
32     CsCommon.Register_Singleton_Constant_On_Nodes    ${cs_all_indices}
33     ${owner}    ${candidates}=    CsCommon.Get_And_Save_Present_CsOwner_And_CsCandidates    1
34     BuiltIn.Wait_Until_Keyword_Succeeds    15s    2s    CsCommon.Verify_Singleton_Constant_On_Nodes    ${cs_all_indices}    ${CS_CONSTANT_PREFIX}${owner}
35
36 Unregister_Singleton_Constant_On_Non_Master_Node
37     [Documentation]    Unregister the application on a non master node.
38     ${unregistered_node} =    Get_Node_Idx_To_Unregister
39     CsCommon.Unregister_Singleton_And_Update_Expected_Candidates    ${unregistered_node}
40     BuiltIn.Set_Suite_Variable    ${unregistered_node}
41
42 Monitor_Stability_While_Unregistered
43     [Documentation]    Verify that the owner remains on the same node after non-owner candidate is unregistered.
44     CsCommon.Monitor_Owner_And_Candidates_Stability    ${STABILITY_TIMEOUT}    ${cs_owner}
45
46 Reregister_Singleton_Constant
47     [Documentation]    Re-register the unregistered candidate.
48     CsCommon.Register_Singleton_And_Update_Expected_Candidates    ${unregistered_node}    ${CS_CONSTANT_PREFIX}${unregistered_node}
49
50 Verify_Stability_After_Reregistration
51     [Documentation]    Verify that the owner remains on the same node after the unregistered candidate re-registration.
52     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    5x    3s    CsCommon.Verify_Owner_And_Candidates_Stable    ${cs_owner}
53
54 Unregister_Singleton_Constant_On_Each_Node
55     [Documentation]    Unregister the application from each node.
56     CsCommon.Unregister_Singleton_Constant_On_Nodes    ${cs_all_indices}
57
58 *** Keywords ***
59 Setup_Keyword
60     SetupUtils.Setup_Utils_For_Setup_And_Teardown    http_timeout=125
61     CsCommon.Cluster_Singleton_Init
62
63 Get_Node_Idx_To_Unregister
64     [Documentation]    Return the first non owner node from the stored candidate list.
65     FOR    ${index}    IN    @{cs_candidates}
66         BuiltIn.Return_From_Keyword_If    "${index}" != "${cs_owner}"    ${index}
67     END