[VOL-4645] Updated onu-upgrade scale test to bulk verify onu image status

Change-Id: Ibd3575303279e690d704509e9cfa51ba4075b9ef
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 7538874..3579db7 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -978,6 +978,22 @@
     Validate ONU Device Image    ${output}    ${image_version}    ${dev_id}    ${download_state}    ${expected_reason}
     ...    ${image_state}
 
+Assert ONUs Image Status in Voltha
+    [Arguments]    ${onu_count}    ${image_version}    ${download_state}    ${expected_reason}    ${image_state}
+    [Documentation]    Check that a certain number of devices reached the given image status
+    ${cmd}=    Catenate    voltctl -c ${VOLTCTL_CONFIG} -m 32MB device onuimage status ${image_version}
+    ...    | grep ${download_state} | grep ${expected_reason} | grep ${image_state} | wc -l
+    ${rc}    ${count}=    Run and Return Rc and Output    ${cmd}
+    Should Be Equal As Integers    ${rc}    0
+    Should Be Equal As Integers    ${count}    ${onu_count}
+
+Wait for ONUs Image Status in VOLTHA
+    [Arguments]    ${onu_count}    ${image_version}    ${download_state}    ${expected_reason}    ${image_state}
+    ...    ${timeout}=10m
+    [Documentation]    Waits until a certain number of devices reached the given image status
+    Wait Until Keyword Succeeds    ${timeout}    5s    Assert ONUs Image Status in Voltha    ${onu_count}
+    ...    ${image_version}    ${download_state}    ${expected_reason}    ${image_state}
+
 Verify ONU Device Image List
     [Documentation]    Verfies the ONU device image list
     [Arguments]    ${dev_id}    ${image_version}    ${committed}    ${activated}    ${valid}    ${image_should_not_in_list}=False
diff --git a/tests/scale/Voltha_Scale_Tests.robot b/tests/scale/Voltha_Scale_Tests.robot
index 3034e70..e2ef26e 100755
--- a/tests/scale/Voltha_Scale_Tests.robot
+++ b/tests/scale/Voltha_Scale_Tests.robot
@@ -186,8 +186,8 @@
     ${activated}=    Set Variable If    '${image_activate_on_success}'=='true'    True    False
     ${committed}=    Set Variable If    '${image_activate_on_success}'=='true' and '${image_commit_on_success}'=='true'
     ...    True    False
-    Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image Status    ${image_version}
-    ...    ${onu_device_id_str}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+    Wait for ONUs Image Status in VOLTHA    ${total_onus}    ${image_version}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+    ...    ${timeout}
     FOR    ${onu_device_id}    IN    @{list_onu_device_id}
         Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image List    ${onu_device_id}
         ...    ${image_version}    ${committed}    ${activated}    True
@@ -206,8 +206,8 @@
     Activate ONU Device Image    ${image_version}    ${image_commit_on_success}    ${onu_device_id_str}
     ${imageState}=    Set Variable If    '${image_commit_on_success}'=='true'    IMAGE_COMMITTED    IMAGE_ACTIVE
     ${committed}=    Set Variable If    '${image_commit_on_success}'=='true'    True    False
-    Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image Status    ${image_version}
-    ...    ${onu_device_id_str}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+    Wait for ONUs Image Status in VOLTHA    ${total_onus}    ${image_version}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+    ...    ${timeout}
     FOR    ${onu_device_id}    IN    @{list_onu_device_id}
         Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image List    ${onu_device_id}
         ...    ${image_version}    ${committed}    True    True
@@ -224,8 +224,8 @@
     ${list_onu_device_id}=    Get ONUs Device IDs from Voltha
     ${onu_device_id_str}=    Catenate    @{list_onu_device_id}
     Commit ONU Device Image    ${image_version}    ${onu_device_id_str}
-    Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image Status    ${image_version}
-    ...    ${onu_device_id_str}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_COMMITTED
+    Wait for ONUs Image Status in VOLTHA    ${total_onus}    ${image_version}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_COMMITTED
+    ...    ${timeout}
     FOR    ${onu_device_id}    IN    @{list_onu_device_id}
         Wait Until Keyword Succeeds    ${timeout}    10s    Verify ONU Device Image List    ${onu_device_id}
         ...    ${image_version}    True    True    True