[VOL-4543] Added ONU Software Upgrade in Scale Test Suite

Change-Id: I8fdfee238b45ed3dd548700576a0c6d489e1530f
diff --git a/tests/scale/Voltha_Scale_Tests.robot b/tests/scale/Voltha_Scale_Tests.robot
index 93a31e4..9417038 100755
--- a/tests/scale/Voltha_Scale_Tests.robot
+++ b/tests/scale/Voltha_Scale_Tests.robot
@@ -86,6 +86,14 @@
 
 ${timeout}    10m
 
+# ONU Image to test for Upgrade needs to be passed in the following format:
+${image_version}    BBSM_IMG_00002
+${image_url}    http://bbsim0:50074/images/software-image.img
+${image_vendor}    BBSM
+${image_activate_on_success}    false
+${image_commit_on_success}    false
+${image_crc}    0
+
 *** Test Cases ***
 
 Create and Enable devices
@@ -158,6 +166,71 @@
         Wait for AAA Authentication     ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}  ${total_onus_per_olt}   ${deviceId}
     END
 
+Image Download and Validation during ONUs Software Upgrade
+    [Documentation]    Validates the Download Image step in ONU Upgrade process
+    ...    Requirement: Pass image details in following parameters in the robot command
+    ...    onu_image_name, onu_image_url, onu_image_version, onu_image_crc, onu_image_local_dir
+    ...    Note: Expects the image url and other parameters to be common for all ONUs on all BBSim
+    [Tags]    onu-upgrade    onu-upgrade-image-download
+    ${onu_device_ids}=    Get ONUs Device IDs from Voltha
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Download ONU Device Image    ${image_version}    ${image_url}    ${image_vendor}
+        ...    ${image_activate_on_success}    ${image_commit_on_success}
+        ...    ${image_crc}    ${onu_device_id}
+    END
+    ${imageState}=    Run Keyword If    '${image_activate_on_success}'=='true' and '${image_commit_on_success}'=='false'
+    ...    Set Variable    IMAGE_ACTIVE
+    ...    ELSE IF    '${image_activate_on_success}'=='true' and '${image_commit_on_success}'=='true'
+    ...    Set Variable    IMAGE_COMMITTED
+    ...    ELSE    Set Variable    IMAGE_INACTIVE
+    ${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
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    ${committed}    ${activated}    True
+    END
+
+Image Activation and Validation during ONUs Software Upgrade
+    [Documentation]    Validates the Activate Image step in ONU Upgrade process
+    ...    Requirement: Pass image details in following parameters in the robot command
+    ...    onu_image_name, onu_image_url, onu_image_version, onu_image_crc, onu_image_local_dir
+    ...    Note: Expects the image url and other parameters to be common for all ONUs on all BBSim
+    [Tags]    onu-upgrade    onu-upgrade-image-activate
+    Pass Execution If    '${image_activate_on_success}'=='true'    Skipping test: Image activated in download stage
+    ${onu_device_ids}=    Get ONUs Device IDs from Voltha
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Activate ONU Device Image    ${image_version}    ${image_commit_on_success}    ${onu_device_id}
+    END
+    ${imageState}=    Set Variable If    '${image_commit_on_success}'=='true'    IMAGE_COMMITTED    IMAGE_ACTIVE
+    ${committed}=    Set Variable If    '${image_commit_on_success}'=='true'    True    False
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    ${imageState}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    ${committed}    True    True
+    END
+
+Image Commit and Validation during ONUs Software Upgrade
+    [Documentation]    Validates the Commit Image step in ONU Upgrade process
+    ...    Requirement: Pass image details in following parameters in the robot command
+    ...    onu_image_name, onu_image_url, onu_image_version, onu_image_crc, onu_image_local_dir
+    ...    Note: Expects the image url and other parameters to be common for all ONUs on all BBSim
+    [Tags]    onu-upgrade    onu-upgrade-image-commit
+    Pass Execution If    '${image_commit_on_success}'=='true'    Skipping test: Image committed in download or activate stage
+    ${onu_device_ids}=    Get ONUs Device IDs from Voltha
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Commit ONU Device Image    ${image_version}    ${onu_device_id}
+    END
+    FOR    ${onu_device_id}    IN    @{onu_device_ids}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_COMMITTED
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    True    True    True
+    END
+
 Provision subscribers
     [Documentation]    Provision data plane flows for all the subscribers
     [Tags]      provision
@@ -311,4 +384,3 @@
     FOR    ${onu}    IN    @{onu_list}
         JoinOrLeave Igmp Rest Based    ${bbsim_rel_session}    ${onu}    ${task}    224.0.0.22
     END
-