SXP: Check cluster is in sync
[integration/test.git] / csit / suites / sxp / clustering / 020_Bindings_consistency.robot
index 8ca4c872ff313efa9912dc6b9eb05979e4c7652b..1766bac250ebde51822c4ebbc878a8012ec690b2 100644 (file)
@@ -1,76 +1,87 @@
 *** Settings ***
 Documentation     Test suite to test cluster binding propagation
-Suite Setup       Setup SXP Cluster Session
-Suite Teardown    Clean SXP Cluster Session
-Test Teardown     Clean SXP Cluster
+Suite Setup       SxpClusterLib.Setup SXP Cluster Session With Device
+Suite Teardown    SxpClusterLib.Clean SXP Cluster Session
 Library           ../../../libraries/Sxp.py
-Resource          ../../../libraries/SxpLib.robot
 Resource          ../../../libraries/ClusterManagement.robot
 Resource          ../../../libraries/SxpClusterLib.robot
+Resource          ../../../libraries/SxpLib.robot
 
 *** Variables ***
-${SAMPLES}        1
+${RUNNING_MEMBER}    ${EMPTY}
 
 *** Test Cases ***
-Isolation of SXP service follower Test Listener Part
-    [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
-    Check Shards Status
-    Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
-    : FOR    ${i}    IN RANGE    0    ${SAMPLES}
-    \    ${controller_index}    Get Active Controller
-    \    Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
-
 Isolation of SXP service follower Test Speaker Part
-    [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
-    Check Shards Status
-    Setup Custom SXP Cluster    speaker
-    : FOR    ${i}    IN RANGE    0    ${SAMPLES}
-    \    ${controller_index}    Get Active Controller
-    \    Isolate SXP Controller    ${controller_index}    ${CLUSTER_NODE_ID}
-
-Isolation of SXP noservice follower Test Listener Part
-    [Documentation]    Test SXP binding propagation only if Controller without SCS are isolated
-    Check Shards Status
-    Setup Custom SXP Cluster    listener    ${CLUSTER_NODE_ID}    controller1
-    : FOR    ${i}    IN RANGE    0    ${SAMPLES}
-    \    ${controller_index}    Get Inactive Controller
-    \    Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    [Documentation]    Test SXP binding propagation from device to cluster after cluster owner is isolated
+    [Setup]    Setup Custom SXP Cluster    speaker
+    ${controller_index} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${controller_index}
+    Isolate SXP Controller    ${controller_index}    ${INADDR_ANY}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${RUNNING_MEMBER}
+    UnIsolate SXP Controller    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${controller_index}
+    [Teardown]    SxpClusterLib.Clean SXP Cluster
 
 Isolation of SXP noservice follower Test Speaker Part
-    [Documentation]    Test SXP binding propagation only if Controller without SCS are isolated
-    Check Shards Status
-    Setup Custom SXP Cluster    speaker
-    : FOR    ${i}    IN RANGE    0    ${SAMPLES}
-    \    ${controller_index}    Get Inactive Controller
-    \    Isolate SXP Controller    ${controller_index}    ${CLUSTER_NODE_ID}
+    [Documentation]    Test SXP binding propagation from device to cluster after cluster (not owner) node is isolated
+    [Setup]    Setup Custom SXP Cluster    speaker
+    ${controller_index} =    SxpClusterLib.Get Not Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${controller_index}
+    Isolate SXP Controller    ${controller_index}    ${INADDR_ANY}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${RUNNING_MEMBER}
+    UnIsolate SXP Controller    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${INADDR_ANY}    ClusterManagement__session_${controller_index}
+    [Teardown]    SxpClusterLib.Clean SXP Cluster
+
+Isolation of SXP service follower Test Listener Part
+    [Documentation]    Test SXP binding propagation from cluster to device after cluster owner is isolated
+    [Setup]    Setup Custom SXP Cluster    listener    ${INADDR_ANY}    ${CONTROLLER_SESSION}
+    ${controller_index} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    UnIsolate SXP Controller    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    [Teardown]    SxpClusterLib.Clean SXP Cluster
+
+Isolation of SXP noservice follower Test Listener Part
+    [Documentation]    Test SXP binding propagation from cluster to device after cluster (not owner) node is isolated
+    [Setup]    Setup Custom SXP Cluster    listener    ${INADDR_ANY}    ${CONTROLLER_SESSION}
+    ${controller_index} =    SxpClusterLib.Get Not Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    UnIsolate SXP Controller    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    [Teardown]    SxpClusterLib.Clean SXP Cluster
 
 *** Keywords ***
 Setup Custom SXP Cluster
     [Arguments]    ${mode}    ${node}=${DEVICE_NODE_ID}    ${session}=${DEVICE_SESSION}
-    [Documentation]    Setup custom SXP cluster topology
-    Setup SXP Cluster    ${mode}
+    [Documentation]    Setup custom SXP cluster topology with ${NUM_ODL_SYSTEM} nodes and one device
+    SxpClusterLib.Setup SXP Cluster    ${mode}
     : FOR    ${i}    IN RANGE    1    25
-    \    Add Binding    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
+    \    SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
+
+Isolate SXP Controller
+    [Arguments]    ${controller_index}    ${node}    ${session}=ClusterManagement__session_${controller_index}
+    [Documentation]    Isolate one of cluster nodes and perform check that device is connected
+    @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
+    ${running_member} =    Collections.Get From List    ${running_members}    0
+    BuiltIn.Set Test Variable    ${RUNNING_MEMBER}    ${running_member}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
+
+UnIsolate SXP Controller
+    [Arguments]    ${controller_index}
+    [Documentation]    Un-Isolate one of cluster nodes and perform check that device is connected
+    ClusterManagement.Flush_Iptables_From_List_Or_All
+    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Check_Cluster_Is_In_Sync
+    BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
 
 Check Bindings
     [Arguments]    ${node}    ${session}
     [Documentation]    Checks that bindings were propagated to Peer
-    ${resp}    Get Bindings    node=${node}    session=${session}
+    ${resp} =    SxpLib.Get Bindings    node=${node}    session=${session}
     : FOR    ${i}    IN RANGE    1    25
-    \    Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32
-
-Isolate SXP Controller
-    [Arguments]    ${controller_index}    ${node}    ${session}=${EMPTY}
-    [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated afterwards reverts isolation
-    ${find_session}    Set Variable If    '${session}' == ''    ${True}    ${False}
-    ${session}    Set Variable If    ${find_session}    controller${controller_index}    ${session}
-    Isolate_Member_From_List_Or_All    ${controller_index}
-    Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
-    Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    ${active_controller}    Get Active Controller
-    ${session}    Set Variable If    ${find_session}    controller${active_controller}    ${session}
-    Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
-    Flush_Iptables_From_List_Or_All
-    Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}
-    Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
+    \    SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32