Add test logging in karaf console
[integration/test.git] / csit / suites / openflowplugin / Clustered_Reconciliation / 010_Group_Flows.robot
index 7cc60ec581b871d26901dfcad82438e8ffe1f25d..1d50fb11a40d2d54c554be68dc3324b5a3c3669b 100644 (file)
@@ -2,7 +2,10 @@
 Documentation     Switch connections and cluster are restarted.
 Suite Setup       Initialization Phase
 Suite Teardown    Final Phase
+Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Library           RequestsLibrary
+Library           Collections
+Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/ClusterManagement.robot
 Resource          ../../../libraries/ClusterOpenFlow.robot
 Resource          ../../../libraries/TemplatedRequests.robot
@@ -37,6 +40,10 @@ Check Flows In Operational DS
     [Documentation]    Check Flows after mininet starts.
     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
 
+Check Stats Are Not Frozen
+    [Documentation]    Check that duration flow stat is increasing
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen
+
 Check Groups In Operational DS
     [Documentation]    Check Groups after mininet starts.
     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Number Of Groups On Member    ${all_groups}
@@ -53,15 +60,16 @@ Check Entity Owner Status And Find Owner and Successor Before Fail
 
 Disconnect Mininet From Owner
     [Documentation]    Disconnect mininet from the owner
-    ${owner_list}    BuiltIn.Create List    ${original_owner}
-    MininetKeywords.Disconnect Cluster Mininet    break    ${owner_list}
-    BuiltIn.Set Suite Variable    ${owner_list}
+    ${original_owner_list}    BuiltIn.Create List    ${original_owner}
+    MininetKeywords.Disconnect Cluster Mininet    break    ${original_owner_list}
+    BuiltIn.Set Suite Variable    ${original_owner_list}
 
 Check Entity Owner Status And Find Owner and Successor After Fail
     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
     ${new_owner}    ${new_successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
     ...    1    ${new_cluster_list}    after_stop=True
     BuiltIn.Set Suite Variable    ${new_owner}
+    BuiltIn.Set Suite Variable    ${new_successor_list}
 
 Check Switch Moves To New Master
     [Documentation]    Check switch s1 is connected to new Master.
@@ -72,6 +80,10 @@ Check Linear Topology After Disconnect
     [Documentation]    Check Linear Topology After Disconnecting mininet from owner.
     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
 
+Check Stats Are Not Frozen After Disconnect
+    [Documentation]    Check that duration flow stat is increasing
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen
+
 Remove Flows And Groups After Mininet Is Disconnected
     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
     Remove Single Group And Flow On Member
@@ -90,13 +102,47 @@ Check Flows In Switch After Mininet Is Disconnected
 
 Reconnect Mininet To Owner
     [Documentation]    Reconnect mininet to switch 1 owner.
-    MininetKeywords.Disconnect Cluster Mininet    restore    ${owner_list}
+    MininetKeywords.Disconnect Cluster Mininet    restore    ${original_owner_list}
 
 Check Entity Owner Status And Find Owner and Successor After Reconnect
     [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
     ${owner}    ${successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
     ...    1
 
+Disconnect Mininet From Successor
+    [Documentation]    Disconnect mininet from the Successor
+    MininetKeywords.Disconnect Cluster Mininet    break    ${new_successor_list}
+
+Check Entity Owner Status And Find New Owner and Successor After Disconnect
+    [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
+    ${owner_list}=    BuiltIn.Create List    ${original_owner}    ${new_owner}
+    ${current_owner}    ${current_successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
+    ...    1    ${owner_list}    after_stop=True
+    BuiltIn.Set Suite Variable    ${current_owner}
+    BuiltIn.Set Suite Variable    ${current_successor_list}
+
+Disconnect Mininet From Current Owner
+    [Documentation]    Disconnect mininet from the owner
+    ${current_owner_list}=    BuiltIn.Create List    ${current_owner}
+    MininetKeywords.Disconnect Cluster Mininet    break    ${current_owner_list}
+
+Check Entity Owner Status And Find Current Owner and Successor After Disconnect
+    [Documentation]    Check Entity Owner Status and identify owner and successor for first switch s1.
+    ${current_new_owner}    ${current_new_successor_list}    BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device    openflow:1
+    ...    1    ${original_owner_list}    after_stop=True
+    BuiltIn.Set Suite Variable    ${current_new_owner}
+    BuiltIn.Set Suite Variable    ${current_new_successor_list}
+
+Check Switch Moves To Current Master
+    [Documentation]    Check switch s1 is connected to new Master.
+    ${current_new_master}=    BuiltIn.Set Variable    ${ODL_SYSTEM_${current_new_owner}_IP}
+    BuiltIn.Wait Until Keyword Succeeds    10s    1s    OvsManager.Should Be Master    s1    ${current_new_master}    update_data=${True}
+    BuiltIn.Should Be Equal    ${current_new_owner}    ${original_owner}
+
+Reconnect Mininet To All Cluster Instances
+    [Documentation]    Reconnect mininet to all cluster instances.
+    MininetKeywords.Disconnect Cluster Mininet    restore    ${new_cluster_list}
+
 Check Linear Topology After Reconnect
     [Documentation]    Check Linear Topology After Reconnect.
     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
@@ -105,6 +151,10 @@ Add Flows And Groups After Reconnect
     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
     Add Single Group And Flow On Member
 
+Check Stats Are Not Frozen After Reconnect
+    [Documentation]    Check that duration flow stat is increasing
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen
+
 Check Flows After Reconnect In Operational DS
     [Documentation]    Check Flows in Operational DS after mininet is reconnected.
     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
@@ -194,6 +244,11 @@ Add Configuration In Owner and Verify After Fail
     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
     Add Single Group And Flow On Member    ${new_owner}
 
+Check Stats Are Not Frozen After Owner Stops
+    [Documentation]    Check that duration flow stat is increasing
+    Log    ${new_owner}
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen    ${new_owner}
+
 Check Flows In Operational DS After Owner Is Stopped
     [Documentation]    Check Flows in Operational DS after Owner is Stopped.
     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}    ${new_owner}
@@ -219,6 +274,10 @@ Check Linear Topology After Owner Restart
     [Documentation]    Check Linear Topology.
     BuiltIn.Wait Until Keyword Succeeds    10s    1s    ClusterOpenFlow.Check Linear Topology On Member    ${SWITCHES}
 
+Check Stats Are Not Frozen After Owner Restart
+    [Documentation]    Check that duration flow stat is increasing
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen
+
 Remove Configuration In Owner and Verify After Owner Restart
     [Documentation]    Remove 1 group 1&2 and 1 flow in every switch.
     Remove Single Group And Flow On Member    ${new_owner}
@@ -250,6 +309,10 @@ Add Flow And Group After Restart
     [Documentation]    Add 1 group type 1&2 and 1 flow in every switch.
     Add Single Group And Flow On Member
 
+Check Stats Are Not Frozen After Cluster Restart
+    [Documentation]    Check that duration flow stat is increasing
+    BuiltIn.Wait Until Keyword Succeeds    30s    1s    Check Flow Stats Are Not Frozen
+
 Check Flows In Operational DS After Controller Restarts
     [Documentation]    Check Flows in Operational DS after controller is restarted.
     BuiltIn.Wait Until Keyword Succeeds    30s    1s    ClusterOpenFlow.Check Number Of Flows On Member    ${all_flows}
@@ -273,7 +336,7 @@ Check No Switches
 *** Keywords ***
 Initialization Phase
     [Documentation]    Create controller session and set variables.
-    ClusterManagement.ClusterManagement_Setup
+    SetupUtils.Setup_Utils_For_Setup_And_Teardown
     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${switches}    Convert To Integer    ${SWITCHES}
     ${iter}    Convert To Integer    ${ITER}
@@ -322,3 +385,25 @@ Remove Single Group And Flow On Member
     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/table/0/flow/1
     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/group/1
     \    RequestsLibrary.Delete Request    ${session}    ${CONFIG_NODES_API}/node/openflow:${switch}/group/1000
+
+Check Flow Stats Are Not Frozen
+    [Arguments]    ${member_index}=1    ${period_in_seconds}=5
+    [Documentation]    Verify flow stats are not frozen for flow 1 and switch 1.
+    ${duration_1} =    Extract Flow Duration    ${member_index}
+    ${duration_1}    Builtin.Convert To Integer    ${duration_1}
+    BuiltIn.Sleep    ${period_in_seconds}
+    ${duration_2} =    Extract Flow Duration    ${member_index}
+    ${duration_2}    Builtin.Convert To Integer    ${duration_2}
+    Should Not Be Equal As Integers    ${duration_1}    ${duration_2}
+
+Extract Flow Duration
+    [Arguments]    ${member_index}
+    [Documentation]    Extract duration for flow 1 in switch 1.
+    ${session} =    Resolve_Http_Session_For_Member    member_index=${member_index}
+    ${resp}    RequestsLibrary.Get Request    ${session}    ${OPERATIONAL_NODES_API}/node/openflow:1/table/0/flow/1    headers=${headers}
+    Log    ${resp.content}
+    ${json_resp} =    RequestsLibrary.To_Json    ${resp.content}
+    ${flow_list} =    Collections.Get_From_Dictionary    ${json_resp}    flow-node-inventory:flow
+    ${flow_stats} =    Collections.Get_From_Dictionary    @{flow_list}[0]    opendaylight-flow-statistics:flow-statistics
+    ${duration} =    Collections.Get_From_Dictionary    &{flow_stats}[duration]    second
+    Return From Keyword    ${duration}