[VOL-4493] fix Flow Deletion After Adapter Restart

Change-Id: Ib651a17444be19b378d152aaf9ec967136b589ed
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index d12a3b0..4309899 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -429,14 +429,11 @@
     ${tp_path_empty}=    Set Variable    True
     Log    ${tp_path_values}
     Log    ${tp_path_keys}
-    ${expected_tp}=    Set Variable    64
     # In case of not empty tp_path each value will be checked depending on must_exist
     FOR    ${key}  IN  @{tp_path_keys}
-        Should Be Equal As Numbers    ${expected_tp}    ${key}
         ${value}=    Get From Dictionary    ${tp_path}     ${key}
         Run Keyword If    ${must_exist}    Should Not Be Empty    ${value}
         ...               ELSE             Should Be Empty        ${value}
-        ${expected_tp}=    Evaluate    ${expected_tp}+1
     END
     Run Keyword If    ${must_exist}    Should Not Be Empty    ${flow_params}
     ...               ELSE             Should Be Empty        ${flow_params}
@@ -626,6 +623,14 @@
     ...    Validate Onu Data In Etcd    namespace=${namespace}    nbofetcddata=0    without_pm_data=False
     [Return]    ${result}
 
+Validate ONOS Flows per OLT
+    [Documentation]    This keyword validates onos flows per olt
+    [Arguments]    ${olt_sn}    ${expected_flows}
+    ${olt_of_id}    Validate OLT Device in ONOS    ${olt_sn}
+    ${flows}=    Count flows    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${olt_of_id}   added
+    Log     Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn}
+    Should Be Equal As Integers    ${expected_flows}    ${flows}
+
 Validate OLT Flows Per Onu
     [Documentation]    This keyword validates olt flows per onu
     ...                It checks checks presence/absence of olt flows depending on must_exist.
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index de98195..1cf19cf 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -497,27 +497,32 @@
     ${expected_flows_onu}=    Set Variable If   "${workflow}"=="ATT"    1    0
     Wait Until Keyword Succeeds    ${timeout}    2s    Validate number of flows    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
     ...    ${expected_flows_onu}  ${of_id}   any    ${onu_port}
+    ${flow}=    Execute ONOS CLI Command use single connection
+    ...    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s any ${of_id}
+    Log    ${flow}
     # Beside onu port specific flows additional flows deleted depending on workflow
     ${additional_flows_deleted}=    Set Variable If
     ...    "${workflow}"=="DT"    1
     ...    "${workflow}"=="TT"    3
     ...    "${workflow}"=="ATT"   0
     FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_of_id}    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${list_olts}[${I}][sn]
-        ${flows}=    Count flows    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${olt_of_id}   added
         ${expected_flows}=    Run Keyword If    "${of_id}"=="${olt_flows_list}[${I}][olt]"
         ...    Evaluate    ${olt_flows_list}[${I}][flows]-${flows_onu}-${additional_flows_deleted}
         ...    ELSE    Set Variable    ${olt_flows_list}[${I}][flows]
-        Log     Found added ${flows} of ${expected_flows} expected flows on device ${list_olts}[${I}][sn]
-        Should Be Equal As Integers    ${expected_flows}    ${flows}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Validate ONOS Flows per OLT    ${list_olts}[${I}][sn]
+        ...    ${expected_flows}
     END
+    ${flow}=    Execute ONOS CLI Command use single connection
+    ...    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s any ${of_id}
+    Log    ${flow}
     # validate etcd data
     ${List_ONU_Serial}    Create List
     Build ONU SN List    ${List_ONU_Serial}
     ${onu_sn_no_flows}=    Set Variable    ${hosts.src[0]['onu']}
     FOR  ${onu_sn}  IN  @{List_ONU_Serial}
         ${must_exist}=    Set Variable If    "${onu_sn}"=="${onu_sn_no_flows}"    False    True
-        Validate Tech Profiles and Flows in ETCD Data Per Onu   ${onu_sn}   ${INFRA_NAMESPACE}   ${kvstoreprefix}  ${must_exist}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Validate Tech Profiles and Flows in ETCD Data Per Onu
+        ...    ${onu_sn}   ${INFRA_NAMESPACE}   ${kvstoreprefix}  ${must_exist}
     END
     ${onu_device_id_no_flows}=    Get Device ID From SN    ${hosts.src[0]['onu']}
     FOR  ${onu_device_id}  IN  @{onu_device_id_list}