Update ddb prefix shards sanity suite
[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 Produce_Transactions_One_Node_Leader
40     [Documentation]    Produce transactions.
41     ${all_indices} =    ClusterManagement.List_All_Indices
42     ${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
43     ${leader_idx_as_list} =    BuiltIn.Create_List    ${leader}
44     ${leader_ip_as_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${leader_idx_as_list}
45     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${leader_ip_as_list}    ${leader_idx_as_list}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
46     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
47     : FOR    ${resp}    IN    @{resp_list}
48     \    TemplatedRequests.Check_Status_Code    ${resp}
49
50 Produce_Transactions_One_Node_Follower
51     [Documentation]    Produce transactions.
52     ${all_indices} =    ClusterManagement.List_All_Indices
53     ${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
54     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
55     ${follower_idx_as_list} =    BuiltIn.Create_List    ${follower_idx}
56     ${follower_ip_as_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${follower_idx_as_list}
57     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${follower_ip_as_list}    ${follower_idx_as_list}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
58     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
59     : FOR    ${resp}    IN    @{resp_list}
60     \    TemplatedRequests.Check_Status_Code    ${resp}
61
62 Become_Prefix_Leader
63     [Documentation]    Make the loeader local and verify.
64     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
65     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
66     ${all_indices} =    ClusterManagement.List_All_Indices
67     ${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
68     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
69     MdsalLowlevel.Become_Prefix_Leader    ${follower1}    ${shard_name}    ${ID_PREFIX}
70     ${leader}    ${follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    30s    3s    ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}!!
71     ...    ${shard_type}    ${True}    ${old_leader}    member_index_list=${EMPTY}
72     BuiltIn.Should_Be_Equal_As_Numbers    ${follower1}    ${leader}
73
74 Remove_Leader_Prefix_Shard_Replica_And_Add_It_Back
75     [Documentation]    Remove and add shard replica adn verify it.
76     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
77     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
78     ${all_indices} =    ClusterManagement.List_All_Indices
79     ${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
80     ClusterAdmin.Remove_Prefix_Shard_Replica    ${old_leader}    ${shard_name}    member-${old_leader}    ${shard_type}
81     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    Verify_Shard_Replica_Removed    ${old_leader}    ${shard_name}!!    ${shard_type}
82     ${actual_leader}    ${actual_follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!
83     ...    verify_restconf=False    shard_type=${shard_type}    member_index_list=${follower_list}
84     BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_leader}    ${actual_leader}
85     ClusterAdmin.Add_Prefix_Shard_Replica    ${old_leader}    ${shard_name}    ${shard_type}
86     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}
87     ...    verify_restconf=False
88
89 Remove_Follower_Prefix_Shard_Replica_And_Add_It_Back
90     [Documentation]    Remove and add shard replica adn verify it.
91     ${shard_name} =    BuiltIn.Set_Variable    ${PREF_BASED_SHARD}
92     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
93     ${all_indices} =    ClusterManagement.List_All_Indices
94     ${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
95     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
96     ClusterAdmin.Remove_Prefix_Shard_Replica    ${follower1}    ${shard_name}    member-${follower1}    ${shard_type}
97     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    DdbCommons.Verify_Shard_Replica_Removed    ${follower1}    ${shard_name}!!    ${shard_type}
98     ${new_indices_list} =    ClusterManagement.List_Indices_Minus_Member    ${follower1}
99     ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}!!    ${shard_type}    ${False}    ${leader}    member_index_list=${new_indices_list}
100     ClusterAdmin.Add_Prefix_Shard_Replica    ${follower1}    ${shard_name}    ${shard_type}
101     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}
102     ...    verify_restconf=False
103
104 Produce_Transactions
105     [Documentation]    Produce transactions.
106     ${all_indices} =    ClusterManagement.List_All_Indices
107     ${all_ip_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${all_indices}
108     MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${all_ip_list}    ${all_indices}    ${ID_PREFIX}    ${DURATION}    ${TRANSACTION_RATE_1K}
109     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
110     : FOR    ${resp}    IN    @{resp_list}
111     \    TemplatedRequests.Check_Status_Code    ${resp}
112
113 Subscribe_Listener_To_Leader
114     [Documentation]    Subscribe listener to leader.
115     ${all_indices} =    ClusterManagement.List_All_Indices
116     ${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
117     MdsalLowlevel.Subscribe_Ddtl    ${leader}
118     BuiltIn.Sleep    5s
119     ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${leader}
120     BuiltIn.Should_Be_True    ${copy_matches}
121
122 Subscribe_Listener_To_Follower
123     [Documentation]    Subscribe listener to follower.
124     ${all_indices} =    ClusterManagement.List_All_Indices
125     ${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
126     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
127     MdsalLowlevel.Subscribe_Ddtl    ${follower_idx}
128     BuiltIn.Sleep    5s
129     ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${follower_idx}
130     BuiltIn.Should_Be_True    ${copy_matches}