32214fa0b644ecdca075ebd308b6a966daf9b96c
[integration/test.git] / csit / suites / controller / dom_data_broker / ddb-sanity-module-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       SetupUtils.Setup_Utils_For_Setup_And_Teardown    http_timeout=30
16 Suite Teardown    SSHLibrary.Close_All_Connections
17 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
19 Default Tags      critical
20 Library           SSHLibrary
21 Library           ${CURDIR}/../../../libraries/MdsalLowlevelPy.py
22 Resource          ${CURDIR}/../../../libraries/ClusterAdmin.robot
23 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
24 Resource          ${CURDIR}/../../../libraries/controller/DdbCommons.robot
25 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
26
27 *** Variables ***
28 ${SHARD_NAME}     default
29 ${SHARD_TYPE}     config
30 ${TRANSACTION_RATE_1K}    ${1000}
31 ${DURATION_10S}    ${10}
32 ${SIMPLE_TX}      ${False}
33 ${CHAINED_TX}     ${True}
34 ${MODULE_SHARD_PREFIX}    prefix-
35
36 *** Test Cases ***
37 Make_Leader_Local
38     [Documentation]    Make the loeader local and verify.
39     ${shard_name} =    BuiltIn.Set_Variable    ${SHARD_NAME}
40     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
41     ${all_indices} =    ClusterManagement.List_All_Indices
42     ${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
43     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
44     ClusterAdmin.Make_Leader_Local    ${follower1}    ${shard_name}    ${shard_type}
45     ${leader}    ${follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    30s    3s    ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}
46     ...    ${shard_type}    ${True}    ${old_leader}    member_index_list=${EMPTY}
47     BuiltIn.Should_Be_Equal_As_Numbers    ${follower1}    ${leader}
48
49 Remove_Leader_Shard_Replica_And_Add_It_Back
50     [Documentation]    Remove and add shard replica adn verify it.
51     ${shard_name} =    BuiltIn.Set_Variable    ${SHARD_NAME}
52     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
53     ${all_indices} =    ClusterManagement.List_All_Indices
54     ${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
55     ClusterAdmin.Remove_Shard_Replica    ${old_leader}    ${shard_name}    member-${old_leader}    ${shard_type}
56     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    DdbCommons.Verify_Shard_Replica_Removed    ${old_leader}    ${shard_name}    ${shard_type}
57     ${actual_leader}    ${actual_follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}
58     ...    verify_restconf=False    shard_type=${shard_type}    member_index_list=${follower_list}
59     BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_leader}    ${actual_leader}
60     ClusterAdmin.Add_Shard_Replica    ${old_leader}    ${shard_name}    ${shard_type}
61     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}
62     ...    verify_restconf=False
63
64 Remove_Follower_Shard_Replica_And_Add_It_Back
65     [Documentation]    Remove and add shard replica adn verify it.
66     ${shard_name} =    BuiltIn.Set_Variable    ${SHARD_NAME}
67     ${shard_type} =    BuiltIn.Set_Variable    ${SHARD_TYPE}
68     ${all_indices} =    ClusterManagement.List_All_Indices
69     ${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
70     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
71     ClusterAdmin.Remove_Shard_Replica    ${follower1}    ${shard_name}    member-${follower1}    ${shard_type}
72     BuiltIn.Wait_Until_Keyword_Succeeds    60s    3s    DdbCommons.Verify_Shard_Replica_Removed    ${follower1}    ${shard_name}    ${shard_type}
73     ${new_indices_list} =    ClusterManagement.List_Indices_Minus_Member    ${follower1}
74     ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}    ${shard_type}    ${False}    ${leader}    member_index_list=${new_indices_list}
75     ClusterAdmin.Add_Shard_Replica    ${follower1}    ${shard_name}    ${shard_type}
76     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}
77     ...    verify_restconf=False
78
79 Write_Transactions
80     [Documentation]    Write transactions.
81     ${all_indices} =    ClusterManagement.List_All_Indices
82     ${all_ip_list} =    ClusterManagement.Resolve_IP_Address_For_Members    ${all_indices}
83     MdsalLowlevelPy.Start_Write_Transactions_On_Nodes    ${all_ip_list}    ${all_indices}    ${MODULE_SHARD_PREFIX}    ${DURATION_10S}    ${TRANSACTION_RATE_1K}    chained_flag=${CHAINED_TX}
84     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
85     : FOR    ${resp}    IN    @{resp_list}
86     \    TemplatedRequests.Check_Status_Code    ${resp}