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