Correctly space expected_status
[integration/test.git] / csit / suites / controller / singleton_service / global_rpc_kill.robot
1 *** Settings ***
2 Documentation       Controller functional HA testing of global singleton rpcs.
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 Resource            ${CURDIR}/../../../libraries/ClusterManagement.robot
11 Resource            ${CURDIR}/../../../libraries/KarafKeywords.robot
12 Resource            ${CURDIR}/../../../libraries/ShardStability.robot
13 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
14 Resource            ${CURDIR}/../../../libraries/TemplatedRequests.robot
15 Resource            ${CURDIR}/../../../libraries/WaitForFailure.robot
16 Resource            ${CURDIR}/../../../variables/Variables.robot
17
18 Suite Setup         Setup_Suite
19 Suite Teardown      SSHLibrary.Close_All_Connections
20 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
21 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
22
23 Default Tags        critical
24
25
26 *** Variables ***
27 ${RPC_URL}                  /restconf/operations/basic-rpc-test:basic-global
28 &{EMPTY_DICT}
29 ${SERVICE}                  Basic-rpc-test']
30 ${TEST_LOG_LEVEL}           info
31 @{TEST_LOG_COMPONENTS}      org.opendaylight.controller.remote.rpc
32 ${EOS_URL}                  /restconf/operational/entity-owners:entity-owners
33
34
35 *** Test Cases ***
36 Get_Basic_Rpc_Test_Owner
37     [Documentation]    Find a service owner and successors.
38     Get_Present_Brt_Owner_And_Successors    1    store=${True}
39
40 Rpc_Before_Stopping_On_Owner
41     [Documentation]    Run rpc on the service owner.
42     Run_Rpc    ${brt_owner}
43
44 Rpc_Before_Stop_On_Successors
45     [Documentation]    Run rpc on non owher cluster nodes.
46     FOR    ${idx}    IN    @{brt_successors}
47         Run_Rpc    ${idx}
48     END
49
50 Stop_Current_Owner_Member
51     [Documentation]    Stop cluster node which is the owner.
52     ClusterManagement.Stop_Single_Member    ${brt_owner}
53     BuiltIn.Set Suite variable    ${old_brt_owner}    ${brt_owner}
54     BuiltIn.Set Suite variable    ${old_brt_successors}    ${brt_successors}
55
56 Verify_New_Basic_Rpc_Test_Owner_Elected
57     [Documentation]    Verify new owner of the service is elected.
58     ${idx}=    Collections.Get_From_List    ${old_brt_successors}    0
59     BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    Verify_Owner_Elected    ${True}    ${old_brt_owner}    ${idx}
60     Get_Present_Brt_Owner_And_Successors    ${idx}    store=${True}
61
62 Rpc_On_Remained_Cluster_Nodes
63     [Documentation]    Run rpc on remained cluster nodes.
64     FOR    ${idx}    IN    @{old_brt_successors}
65         BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    Run_Rpc    ${idx}
66     END
67
68 Restart_Stopped_Member
69     [Documentation]    Restart stopped node
70     ClusterManagement.Start_Single_Member    ${old_brt_owner}
71
72 Verify_New_Owner_Remained_After_Rejoin
73     [Documentation]    Verify no owner change happened after rejoin.
74     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout
75     ...    15s
76     ...    2s
77     ...    Verify_Owner_Elected
78     ...    ${False}
79     ...    ${brt_owner}
80     ...    ${brt_owner}
81     BuiltIn.Wait_Until_Keyword_Succeeds
82     ...    70s
83     ...    10s
84     ...    ShardStability.Shards_Stability_Get_Details
85     ...    ${DEFAULT_SHARD_LIST}
86
87 Rpc_After_Rejoin_On_New_Owner
88     [Documentation]    Run rpc on the new service owner node.
89     Run_Rpc    ${brt_owner}
90
91 Rpc_After_Rejoin_On_Old_Owner
92     [Documentation]    Run rpc on rejoined cluster node.
93     Run_Rpc    ${old_brt_owner}
94
95 Rpc_After_Rejoin_On_All
96     [Documentation]    Run rpc again on all nodes.
97     Run_Rpc    ${brt_owner}
98     FOR    ${idx}    IN    @{brt_successors}
99         Run_Rpc    ${idx}
100     END
101
102
103 *** Keywords ***
104 Setup_Suite
105     [Documentation]    FIXME: Add a documentation.
106     SetupUtils.Setup_Utils_For_Setup_And_Teardown    http_timeout=30
107     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${TEST_LOG_LEVEL}    ${TEST_LOG_COMPONENTS}
108
109 Run_Rpc
110     [Documentation]    Run rpc and log the entity ownership service details to karaf log.
111     ...    Logging the details was a developer's request during the implementation to improve debugging.
112     [Arguments]    ${node_idx}
113     ${session}=    Resolve_Http_Session_For_Member    member_index=${node_idx}
114     ${out}=    TemplatedRequests.Get_From_Uri    ${EOS_URL}    session=${session}
115     KarafKeywords.Log_Message_To_Controller_Karaf    EOS rest resp: ${out}
116     TemplatedRequests.Post_To_Uri    ${RPC_URL}    ${EMPTY}    ${HEADERS_XML}    ${ACCEPT_XML}    session=${session}
117
118 Verify_Owner_Elected
119     [Documentation]    Verify new owner was elected or remained the same.
120     [Arguments]    ${new_elected}    ${old_owner}    ${node_to_ask}
121     ${owner}    ${successors}=    Get_Present_Brt_Owner_And_Successors    ${node_to_ask}
122     IF    ${new_elected}
123         BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_owner}    ${owner}
124     END
125     IF    not ${new_elected}
126         BuiltIn.Should_Be_Equal_As_numbers    ${old_owner}    ${owner}
127     END
128
129 Get_Present_Brt_Owner_And_Successors
130     [Documentation]    Find a basic rpc test service owner and successors and store them if indicated.
131     [Arguments]    ${node_to_ask}    ${store}=${False}
132     ${brt_owner}    ${brt_successors}=    ClusterManagement.Get_Owner_And_Successors_For_Device
133     ...    ${SERVICE}
134     ...    org.opendaylight.mdsal.ServiceEntityType
135     ...    ${node_to_ask}
136     IF    ${store}    BuiltIn.Set_Suite_Variable    ${brt_owner}    ${brt_owner}
137     IF    ${store}
138         BuiltIn.Set_Suite_Variable    ${brt_successors}    ${brt_successors}
139     END
140     RETURN    ${brt_owner}    ${brt_successors}