SXP: Use KWs from ClusterManagement
[integration/test.git] / csit / suites / sxp / clustering / 020_Bindings_consistency.robot
1 *** Settings ***
2 Documentation     Test suite to test cluster binding propagation
3 Suite Setup       Setup SXP Cluster Session
4 Suite Teardown    Clean SXP Cluster Session
5 Test Teardown     Clean SXP Cluster
6 Library           ../../../libraries/Sxp.py
7 Resource          ../../../libraries/ClusterManagement.robot
8 Resource          ../../../libraries/SxpClusterLib.robot
9 Resource          ../../../libraries/SxpLib.robot
10
11 *** Test Cases ***
12 Isolation of SXP service follower Test Listener Part
13     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
14     SxpClusterLib.Check Shards Status
15     Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
16     ${controller_index} =    SxpClusterLib.Get Owner Controller
17     Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
18
19 Isolation of SXP service follower Test Speaker Part
20     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
21     SxpClusterLib.Check Shards Status
22     Setup Custom SXP Cluster    speaker
23     ${controller_index} =    SxpClusterLib.Get Owner Controller
24     Isolate SXP Controller    ${controller_index}    ${CLUSTER_NODE_ID}
25
26 Isolation of SXP noservice follower Test Listener Part
27     [Documentation]    Test SXP binding propagation only if Controller without SCS are isolated
28     SxpClusterLib.Check Shards Status
29     Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
30     ${controller_index} =    SxpClusterLib.Get Not Owner Controller
31     Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
32
33 Isolation of SXP noservice follower Test Speaker Part
34     [Documentation]    Test SXP binding propagation only if Controller without SCS are isolated
35     SxpClusterLib.Check Shards Status
36     Setup Custom SXP Cluster    speaker
37     ${controller_index} =    SxpClusterLib.Get Not Owner Controller
38     Isolate SXP Controller    ${controller_index}    ${CLUSTER_NODE_ID}
39
40 *** Keywords ***
41 Setup Custom SXP Cluster
42     [Arguments]    ${mode}    ${node}=${DEVICE_NODE_ID}    ${session}=${DEVICE_SESSION}
43     [Documentation]    Setup custom SXP cluster topology
44     SxpClusterLib.Setup SXP Cluster    ${mode}
45     : FOR    ${i}    IN RANGE    1    25
46     \    SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
47
48 Isolate SXP Controller
49     [Arguments]    ${controller_index}    ${node}    ${session}=${EMPTY}
50     [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated afterwards reverts isolation
51     ${find_session} =    BuiltIn.Set Variable If    '${session}' == ''    ${True}    ${False}
52     ${session} =    BuiltIn.Set Variable If    ${find_session}    controller${controller_index}    ${session}
53     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
54     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
55     BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
56     ${running_member} =    Collections.Get From List    ${running_members}    0
57     ${owner_controller} =    SxpClusterLib.Get Owner Controller    ${running_member}
58     ${session} =    BuiltIn.Set Variable If    ${find_session}    controller${owner_controller}    ${session}
59     BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
60     ClusterManagement.Flush_Iptables_From_List_Or_All
61     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
62     BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
63     BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
64
65 Check Bindings
66     [Arguments]    ${node}    ${session}
67     [Documentation]    Checks that bindings were propagated to Peer
68     ${resp} =    SxpLib.Get Bindings    node=${node}    session=${session}
69     : FOR    ${i}    IN RANGE    1    25
70     \    SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32