[VOL-2869] Verify Zero ONOS Flows Count on OLT Delete

Change-Id: I2aaec2c4a2c467ca8bfab3d0d3da8d7437fb2c10
diff --git a/libraries/onos.robot b/libraries/onos.robot
index d03e27b..2847d7f 100644
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -136,6 +136,13 @@
     ...    flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | wc -l
     Should Be Equal As Integers    ${access_flows_added}    ${expected_flows}
 
+Verify Device Flows Removed
+    [Arguments]    ${ip}    ${port}    ${olt_of_id}
+    [Documentation]    Verifies all flows are removed from the device
+    ${device_flows}=    Execute ONOS CLI Command    ${ip}    ${port}
+    ...    flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
+    Should Be Equal As Integers    ${device_flows}    0
+
 Verify Eapol Flows Added
     [Arguments]    ${ip}    ${port}    ${expected_flows}
     [Documentation]    Matches for number of eapol flows based on number of onus
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index 431a1f7..3e06882 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -240,6 +240,8 @@
     # Delete OLT and Validate Empty Device List
     Delete Device    ${olt_device_id}
     Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s    Test Empty Device List
+    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+    ...    Verify Device Flows Removed    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
     Run Keyword and Ignore Error    Collect Logs
     # Re-do Setup (Recreate the OLT) and Perform Sanity Test DT
     Run Keyword    Setup
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 3f25744..edc988c 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -308,10 +308,12 @@
     ...           AND             Stop Logging    DeleteOLT
     ...           AND             Announce Message    END TEST DeleteOLT
     Run Keyword If    ${has_dataplane}    Clean Up Linux
-    Run Keyword If    ${has_dataplane}    Delete Device and Verify
+    Delete Device and Verify
+    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+    ...    Verify Device Flows Removed    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
     Run Keyword and Ignore Error    Collect Logs
     # Recreate the OLT
-    Run Keyword If    ${has_dataplane}    Setup
+    Setup
     Wait Until Keyword Succeeds    ${timeout}   2s    Perform Sanity Test
 
 Check Mib State on OLT recreation after ONU, OLT deletion
@@ -336,8 +338,10 @@
         Delete Device     ${onu_device_id}
     END
     #Disable and Delete the OLT
-    Run Keyword If    ${has_dataplane}    Delete Device and Verify
-    #Recreate the OLT back
+    Delete Device and Verify
+    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+    ...    Verify Device Flows Removed    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
+    # Recreate the OLT
     Run Keyword If    ${has_dataplane}    Sleep    180s
     ${olt_device_id}=    Create Device    ${olt_ip}    ${OLT_PORT}
     Set Suite Variable    ${olt_device_id}
@@ -408,6 +412,8 @@
     END
     Delete Device    ${olt_device_id}
     Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s    Test Empty Device List
+    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+    ...    Verify Device Flows Removed    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
 
 Validate authentication on a disabled ONU
     [Documentation]    Assuming that test1 was executed where all the ONUs are authenticated/DHCP/pingable