Add Rpc Provider Test Suites
[integration/test.git] / csit / suites / controller / dom_rpc_broker / rpc_provider_precedence.robot
1 *** Settings ***
2 Documentation     DOMRpcBroker testing: RPC Provider Precedence
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 ...               The aim is to establish that remote RPC implementations have lower priority
11 ...               than local ones, which is to say that any movement of RPCs on remote nodes
12 ...               does not affect routing as long as a local implementation is available.
13 Suite Setup       Setup_Keyword
14 Suite Teardown    SSHLibrary.Close_All_Connections
15 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
17 Default Tags      critical
18 Library           Collections
19 Library           SSHLibrary
20 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
21 Resource          ${CURDIR}/../../../libraries/MdsalLowlevel.robot
22 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
23 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
24
25 *** Variables ***
26 ${UNREGISTERED_RPC_NODE}    ${1}
27 ${CONSTANT_PREFIX}    constant-
28
29 *** Test Cases ***
30 Register_Rpc_On_Each_Node
31     [Documentation]    Register global rpc on each node of the cluster.
32     : FOR    ${index}    IN    @{full_cluster_index_list}
33     \    MdsalLowlevel.Register_Constant    ${index}    ${CONSTANT_PREFIX}${index}
34
35 Invoke_Rpc_On_Each_Node
36     [Documentation]    Verify that the rpc response comes from the local node.
37     : FOR    ${index}    IN    @{full_cluster_index_list}
38     \    ${constant} =    MdsalLowlevel.Get_Constant    ${index}
39     \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
40
41 Unregister_Rpc_On_Node
42     [Documentation]    Unregister the rpc on one of the cluster nodes.
43     MdsalLowlevel.Unregister_Constant    ${UNREGISTERED_RPC_NODE}
44
45 Invoke_Rpc_On_Node_With_Unregistered_Rpc
46     [Documentation]    Invoke rcp on the node with unregistered rpc. The response is expected
47     ...    to come from other nodes where the rpc remained registered.
48     ${constant} =    MdsalLowlevel.Get_Constant    ${UNREGISTERED_RPC_NODE}
49     Collections.List_Should_Contain_Value    ${allowed_values}    ${constant}
50
51 Invoke_Rpc_On_Remaining_Nodes
52     [Documentation]    Verify that the rpc response comes from the local node.
53     : FOR    ${index}    IN    @{allowed_index_list}
54     \    ${constant} =    MdsalLowlevel.Get_Constant    ${index}
55     \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
56
57 Reregister_Rpc_On_Node
58     [Documentation]    Reregister the rpc.
59     MdsalLowlevel.Register_Constant    ${UNREGISTERED_RPC_NODE}    ${CONSTANT_PREFIX}${UNREGISTERED_RPC_NODE}
60
61 Invoke_Rpc_On_Each_Node_Again
62     [Documentation]    Verify that the rpc response comes from the local node.
63     : FOR    ${index}    IN    @{full_cluster_index_list}
64     \    ${constant} =    MdsalLowlevel.Get_Constant    ${index}
65     \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
66
67 Unregister_Rpc_On_Each_Node
68     [Documentation]    Unregister rpc on every node.
69     : FOR    ${index}    IN    @{full_cluster_index_list}
70     \    MdsalLowlevel.Unregister_Constant    ${index}
71
72 *** Keywords ***
73 Setup_Keyword
74     [Documentation]    Create a list of possible constant responses on the node with unregistered rpc.
75     SetupUtils.Setup_Utils_For_Setup_And_Teardown
76     ${full_cluster_index_list} =    ClusterManagement.List_All_Indices
77     BuiltIn.Set_Suite_Variable    ${full_cluster_index_list}
78     ${allowed_values} =    BuiltIn.Create_List
79     ${allowed_index_list} =    ClusterManagement.List_Indices_Minus_Member    ${UNREGISTERED_RPC_NODE}    ${full_cluster_index_list}
80     : FOR    ${index}    IN    @{allowed_index_list}
81     \    Collections.Append_To_List    ${allowed_values}    ${CONSTANT_PREFIX}${index}
82     BuiltIn.Set_Suite_Variable    ${allowed_index_list}
83     BuiltIn.Set_Suite_Variable    ${allowed_values}