[VOL-4734] Check ONU model, vendor and vendor-id
Change-Id: Iee147f9b0baf05b571091a8b68d6670833fd9da9
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index bd415f1..c1fdc82 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -833,6 +833,34 @@
[Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
Wait Until Keyword Succeeds ${timeout} 5s Assert ONUs In Voltha ${count}
+Validate ONU Model
+ [Documentation]
+ ... Parses the output of "voltctl device list" and inspects onu model and optionally Vendor and Vendor-id
+ ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect passed values
+ [Arguments] ${List_ONU_Serial} ${onu_model} ${onu_vendor}=${EMPTY} ${onu_vendor_id}=${EMPTY}
+ ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=brcm_openomci_onu
+ ... --format "{{.Id}}\t{{.SerialNumber}}\t{{.Vendor}}\t{{.VendorId}}\t{{.Model}}" | grep -v SERIALNUMBER
+ ${rc} ${output}= Run and Return Rc and Output ${cmd}
+ Should Be Equal As Integers ${rc} 0 Failed Validate ONU model because of ${output}
+ Log ${output}
+ @{Results}= Split String ${output} \n
+ FOR ${Line} IN @{Results}
+ ${matched}= Set Variable False
+ @{words}= Split String ${Line} \t
+ ${id}= Set Variable ${words[0]}
+ ${sn}= Set Variable ${words[1]}
+ ${vendor}= Set Variable ${words[2]}
+ ${vendor_id}= Set Variable ${words[3]}
+ ${model}= Set Variable ${words[4]}
+ ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
+ ${matched}= Set Variable If -1 != ${onu_id} True False
+ ${matched}= Set Variable If '${model}'=='${onu_model}' ${matched} False
+ ${matched}= Set Variable If '${onu_vendor}'=='${EMPTY}' or '${vendor}'=='${onu_vendor}' ${matched} False
+ ${matched}= Set Variable If '${onu_vendor_id}'=='${EMPTY}' or '${vendor_id}'=='${onu_vendor_id}' ${matched} False
+ Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
+ END
+ Should Be Empty ${List_ONU_Serial} No valid ONU model found for ${List_ONU_Serial}!
+
Count Logical Devices flows
[Documentation] Count the flows across logical devices in VOLTHA
[Arguments] ${targetFlows}
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index e7b425c..14ae04f 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -193,6 +193,18 @@
... AND Run Keyword If ${logging} Collect Logs
... AND Stop Logging SoftRebootONUDevice
+Check Onu Model
+ [Documentation] Checks onu model of all ONU Devices
+ ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
+ [Tags] functionalOnuGo CheckModelOnuGo
+ [Setup] Start Logging CheckModelOnuGo
+ Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
+ ... Do Check Onu Model
+ ... ELSE Pass Execution ${skip_message} skipped
+ [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console}
+ ... AND Run Keyword If ${logging} Collect Logs
+ ... AND Stop Logging CheckModelOnuGo
+
*** Keywords ***
Setup Suite
[Documentation] Set up the test suite
@@ -454,3 +466,12 @@
Sleep 5s
Current State Test All Onus omci-flows-pushed
Do Onu Port Check
+
+Do Check Onu Model
+ [Documentation] This keyword checks onu model of all onus.
+ ${list_onus} Create List
+ Build ONU SN List ${list_onus}
+ ${onu_model}= Set Variable v0.0.1
+ ${onu_vendor}= Set Variable BBSM
+ ${onu_vendor_id}= Set Variable BBSM
+ Validate ONU Model ${list_onus} ${onu_model} ${onu_vendor} ${onu_vendor_id}