[VOL-4358] Waiting for the device to complete the reconciliation process before continuing
Change-Id: I641ee1b41251e810d91798b82685419564554cb4
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index 593a964..3db563a 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -114,6 +114,46 @@
# teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
[Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
+Wait for ONU Adapter Reconcile
+ [Documentation] After the OpenONU adapter is restarted waits for all the ONUs to go through the reconciling process
+ ... till they reach the expect OpenStatus
+ [Arguments] ${oper_status}
+ # wait for the reconcile to complete
+ # - we check that the first ONU state is set to reconciling. All of the ONUs will be set to reconciling
+ # very quickly at that point
+ # we need the Ignore Error to support he kafka case, in which the reconcile happens meanwhile we're waiting for
+ # the adapter to restart
+ Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
+ ... 100ms Check ONU OperStatus ${hosts.src[0]['onu']} RECONCILING
+ # - then we wait that all ONU move to the next state
+ ${onu_list} Create List
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${onu_sn}= Set Variable ${hosts.src[${I}]['onu']}
+ # skip the check if we have already performed it for this ONU
+ ${onu_id}= Get Index From List ${onu_list} ${onu_sn}
+ Continue For Loop If -1 != ${onu_id}
+ Append To List ${onu_list} ${onu_sn}
+ Wait Until Keyword Succeeds ${timeout} 100ms Check ONU OperStatus ${onu_sn} ${oper_status}
+ END
+
+Check ONU OperStatus
+ [Documentation] Checks that all ONUs OperStatus is ACTIVE
+ [Arguments] ${sn} ${oper_status}
+ ${List_ONU_Serial} Create List
+ Build ONU SN List ${List_ONU_Serial}
+ ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=brcm_openomci_onu
+ ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}"
+ ... | grep -v SERIALNUMBER | grep ${sn}
+ ${rc} ${output}= Run and Return Rc and Output ${cmd}
+ Should Be Equal As Integers ${rc} 0
+ Log ${output}
+
+ @{words}= Split String ${output} \t
+ ${sn}= Set Variable ${words[0]}
+ ${opstatus}= Set Variable ${words[2]}
+ Log OperStatus is ${opstatus} for device ${sn}
+ Should Be True '${opstatus}' == '${oper_status}' OperStatus ${oper_status} not matched on ONU ${sn}
+
Log Ports
[Documentation] This keyword logs all port data available in ONOS of first port per ONU
[Arguments] ${onlyenabled}=False