SXP cluster tests: declare variables in one place
[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     Check Shards Status
15     Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
16     ${controller_index} =    Get Active 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     Check Shards Status
22     Setup Custom SXP Cluster    speaker
23     ${controller_index} =    Get Active 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     Check Shards Status
29     Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
30     ${controller_index} =    Get Inactive 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     Check Shards Status
36     Setup Custom SXP Cluster    speaker
37     ${controller_index} =    Get Inactive 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     Setup SXP Cluster    ${mode}
45     : FOR    ${i}    IN RANGE    1    25
46     \    Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
47
48 Check Bindings
49     [Arguments]    ${node}    ${session}
50     [Documentation]    Checks that bindings were propagated to Peer
51     ${resp} =    Get Bindings    node=${node}    session=${session}
52     : FOR    ${i}    IN RANGE    1    25
53     \    Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32
54
55 Isolate SXP Controller
56     [Arguments]    ${controller_index}    ${node}    ${session}=${EMPTY}
57     [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated afterwards reverts isolation
58     ${find_session} =    Set Variable If    '${session}' == ''    ${True}    ${False}
59     ${session} =    Set Variable If    ${find_session}    controller${controller_index}    ${session}
60     Isolate_Member_From_List_Or_All    ${controller_index}
61     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
62     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
63     ${active_controller} =    Get Active Controller
64     ${session} =    Set Variable If    ${find_session}    controller${active_controller}    ${session}
65     Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
66     Flush_Iptables_From_List_Or_All
67     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}
68     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
69     Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}