Add new rpc from ClusterAdmin to sanity
[integration/test.git] / csit / suites / controller / dom_data_broker / ddb-sanity-prefix-based.robot
1 *** Settings ***
2 Documentation     DOMDataBroker testing: Module based shards sanity suite
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 goal is to call several basic rpc form ClusterAdmin.robot and
11 ...               MdsalLowlevel.robot to ensute that those rpcs can be safely used in
12 ...               other suites.
13 ...               It also verify the ability of the odl-controller-test-app to perform
14 ...               several activities.
15 Suite Setup       BuiltIn.Run_Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown    http_timeout=30
16 ...               AND    DdbCommons.Create_Prefix_Based_Shard_And_Verify
17 Suite Teardown    BuiltIn.Run_Keywords    DdbCommons.Remove_Prefix_Based_Shard_And_Verify
18 ...               AND    SSHLibrary.Close_All_Connections
19 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
21 Default Tags      critical
22 Library           SSHLibrary
23 Library           ${CURDIR}/../../../libraries/MdsalLowlevelPy.py
24 Resource          ${CURDIR}/../../../libraries/ClusterAdmin.robot
25 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
26 Resource          ${CURDIR}/../../../libraries/controller/DdbCommons.robot
27 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
28
29 *** Variables ***
30 ${PREF_BASED_SHARD}    id-ints
31 ${SHARD_TYPE}     config
32 ${TRANSACTION_RATE_1K}    ${1000}
33 ${DURATION}       ${30}
34 ${SIMPLE_TX}      ${False}
35 ${CHAINED_TX}     ${True}
36 ${ID_PREFIX}      prefix-
37
38 *** Test Cases ***
39 Get_Prefix_Shard_Role
40     [Documentation]    Get prefix shard role.
41     ${all_indices} =    ClusterManagement.List_All_Indices
42     : FOR    ${index}    IN    @{all_indices}
43     \    ${role} =    ClusterAdmin.Get_Prefix_Shard_Role    ${index}    ${PREF_BASED_SHARD}    ${SHARD_TYPE}
44
45 Produce_Transactions_One_Node_Leader
46     [Documentation]    Produce transactions.
47     ${all_indices} =    ClusterManagement.List_All_Indices
48     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
49     ${leader_idx_as_list} =    BuiltIn.Create_List    ${leader}
50     ${leader_ip_as_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${leader_idx_as_list}
51     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${leader_ip_as_list}    ${leader_idx_as_list}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
52     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
53     : FOR    ${resp}    IN    @{resp_list}
54     \    TemplatedRequests.Check_Status_Code    ${resp}
55
56 Produce_Transactions_One_Node_Follower
57     [Documentation]    Produce transactions.
58     ${all_indices} =    ClusterManagement.List_All_Indices
59     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
60     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
61     ${follower_idx_as_list} =    BuiltIn.Create_List    ${follower_idx}
62     ${follower_ip_as_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${follower_idx_as_list}
63     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${follower_ip_as_list}    ${follower_idx_as_list}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
64     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
65     : FOR    ${resp}    IN    @{resp_list}
66     \    TemplatedRequests.Check_Status_Code    ${resp}
67
68 Become_Prefix_Leader
69     [Documentation]    Make the loeader local and verify.
70     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
71     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
72     ${all_indices} =    ClusterManagement.List_All_Indices
73     ${old_leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
74     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
75     MdsalLowlevel.Become_Prefix_Leader    ${follower1}    ${shard_name}    ${ID_PREFIX}
76     ${leader}    ${follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    30s    3s    ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}!!
77     ...    ${shard_type}    ${True}    ${old_leader}    member_index_list=${EMPTY}
78     BuiltIn.Should_Be_Equal_As_Numbers    ${follower1}    ${leader}
79
80 Remove_Leader_Prefix_Shard_Replica_And_Add_It_Back
81     [Documentation]    Remove and add shard replica adn verify it.
82     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
83     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
84     ${all_indices} =    ClusterManagement.List_All_Indices
85     ${old_leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
86     ClusterAdmin.Remove_Prefix_Shard_Replica    ${old_leader}    ${shard_name}    member-${old_leader}    ${shard_type}
87     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    Verify_Shard_Replica_Removed    ${old_leader}    ${shard_name}!!    ${shard_type}
88     ${actual_leader}    ${actual_follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!
89     ...    verify_restconf=False    shard_type=${shard_type}    member_index_list=${follower_list}
90     BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_leader}    ${actual_leader}
91     ClusterAdmin.Add_Prefix_Shard_Replica    ${old_leader}    ${shard_name}    ${shard_type}
92     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}
93     ...    verify_restconf=False
94
95 Remove_Follower_Prefix_Shard_Replica_And_Add_It_Back
96     [Documentation]    Remove and add shard replica adn verify it.
97     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
98     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
99     ${all_indices} =    ClusterManagement.List_All_Indices
100     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
101     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
102     ClusterAdmin.Remove_Prefix_Shard_Replica    ${follower1}    ${shard_name}    member-${follower1}    ${shard_type}
103     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    DdbCommons.Verify_Shard_Replica_Removed    ${follower1}    ${shard_name}!!    ${shard_type}
104     ${new_indices_list} =    ClusterManagement.List_Indices_Minus_Member    ${follower1}
105     ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}!!    ${shard_type}    ${False}    ${leader}    member_index_list=${new_indices_list}
106     ClusterAdmin.Add_Prefix_Shard_Replica    ${follower1}    ${shard_name}    ${shard_type}
107     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}
108     ...    verify_restconf=False
109
110 Produce_Transactions
111     [Documentation]    Produce transactions.
112     ${all_indices} =    ClusterManagement.List_All_Indices
113     ${all_ip_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${all_indices}
114     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${all_ip_list}    ${all_indices}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
115     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
116     : FOR    ${resp}    IN    @{resp_list}
117     \    TemplatedRequests.Check_Status_Code    ${resp}
118
119 Subscribe_Listener_To_Leader
120     [Documentation]    Subscribe listener to leader.
121     ${all_indices} =    ClusterManagement.List_All_Indices
122     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
123     MdsalLowlevel.Subscribe_Ddtl    ${leader}
124     BuiltIn.Sleep    5s
125     ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${leader}
126     BuiltIn.Should_Be_True    ${copy_matches}
127
128 Subscribe_Listener_To_Follower
129     [Documentation]    Subscribe listener to follower.
130     ${all_indices} =    ClusterManagement.List_All_Indices
131     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
132     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
133     MdsalLowlevel.Subscribe_Ddtl    ${follower_idx}
134     BuiltIn.Sleep    5s
135     ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${follower_idx}
136     BuiltIn.Should_Be_True    ${copy_matches}