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