[VOL-4320] OpenOnuAdapter sw-upgrade extend test suite by further (abort) tests

Change-Id: I23a78bc66bcfeb3b5d1c194ca117c2b1192a3c40
diff --git a/tests/software-upgrades/ONU_Upgrade.robot b/tests/software-upgrades/ONU_Upgrade.robot
index 28d5a0b..0f98522 100755
--- a/tests/software-upgrades/ONU_Upgrade.robot
+++ b/tests/software-upgrades/ONU_Upgrade.robot
@@ -76,6 +76,20 @@
 ${image_crc}    ${EMPTY}
 # Example value: 0
 
+# when voltha is running in k8s port forwarding is needed
+# example: -v PORT_FORWARDING:False
+${PORT_FORWARDING}    True
+
+# Next values are default values for port forward, do not need to be passed, will be overwritten by values taken from image-url
+# bbsim webserver port
+# example: -v BBSIM_WEBSERVER_PORT:50074
+${BBSIM_WEBSERVER_PORT}    50074
+# bbsim instance
+# example: -v BBSIM_INSTANCE:bbsim0
+${BBSIM_INSTANCE}    bbsim0
+# port forward handle
+${portFwdHandle}     None
+
 *** Test Cases ***
 Test ONU Upgrade
     [Documentation]    Validates the ONU Upgrade doesn't affect the system functionality
@@ -90,7 +104,7 @@
     ...           AND             Delete All Devices and Verify
     ...           AND             Restart And Check BBSIM    ${NAMESPACE}
     ...           AND             Stop Logging    ONUUpgrade
-    Test ONU Upgrade All OLTs
+    Do ONU Upgrade All OLTs
 
 Test ONU Upgrade All Activate and Commit Combinations
     [Documentation]    Validates the ONU Upgrade doesn't affect the system functionality by use all combinations of
@@ -112,7 +126,7 @@
     ${true_true}=      Create Dictionary    activate    true     commit    true
     ${flag_list}=    Create List    ${false_false}     ${true_false}    ${false_true}    ${true_true}
     FOR    ${item}     IN      @{flag_list}
-        Test ONU Upgrade All OLTs    ${item['activate']}    ${item['commit']}
+        Do ONU Upgrade All OLTs    ${item['activate']}    ${item['commit']}
         Delete All Devices and Verify
         Restart And Check BBSIM    ${NAMESPACE}
     END
@@ -137,7 +151,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
         ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
-        Test ONU Upgrade Download Failure Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        Do ONU Upgrade Download Failure Per OLT    ${bbsim_pod}    ${olt_serial_number}
         ...    url=http://bbsim0:50074/images/wrong-image.img$
         ...    dwl_dwlstate=DOWNLOAD_FAILED    dwl_reason=INVALID_URL    dwl_imgstate=IMAGE_UNKNOWN
         ...        dwlstate=DOWNLOAD_UNKNOWN       reason=NO_ERROR           imgstate=IMAGE_UNKNOWN
@@ -169,7 +183,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
         ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
-        Test ONU Upgrade Download Failure Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        Do ONU Upgrade Download Failure Per OLT    ${bbsim_pod}    ${olt_serial_number}
         ...    dwlstate=DOWNLOAD_FAILED       reason=CANCELLED_ON_ONU_STATE           imgstate=IMAGE_UNKNOWN
         List ONUs    ${NAMESPACE}    ${bbsim_pod}
     END
@@ -179,17 +193,17 @@
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
 
-Test ONU Upgrade Correct Indication of Download Abort
-    [Documentation]    Validates the ONU Upgrade download abort will be indicated correctly and
+Test ONU Upgrade Correct Indication of Downloading Abort
+    [Documentation]    Validates the ONU Upgrade downloading abort will be indicated correctly and
     ...    doesn't affect the system functionality
     ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
     ...    Check [VOL-4318] for more details
-    [Tags]    functional   ONUUpgradeDownloadAbort
-    [Setup]    Start Logging    ONUUpgradeDownloadAbort
+    [Tags]    functional   ONUUpgradeDownloadingAbort
+    [Setup]    Start Logging    ONUUpgradeDownloadingAbort
     [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
     ...           AND             Delete All Devices and Verify
     ...           AND             Restart And Check BBSIM    ${NAMESPACE}
-    ...           AND             Stop Logging    ONUUpgradeDownloadAbort
+    ...           AND             Stop Logging    ONUUpgradeDownloadingAbort
     # Add OLT device
     Setup
     # Performing Sanity Test to make sure subscribers are all DHCP and pingable
@@ -199,7 +213,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
         ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
-        Test ONU Upgrade Download Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        Do ONU Upgrade Downloading Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
         List ONUs    ${NAMESPACE}    ${bbsim_pod}
     END
     # Additional Verification
@@ -208,17 +222,17 @@
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
 
-Test ONU Upgrade Correct Indication of Activate Abort
-    [Documentation]    Validates the ONU Upgrade activate abort will be indicated correctly and
+Test ONU Upgrade Correct Indication of Downloaded Abort
+    [Documentation]    Validates the ONU Upgrade downloaded abort will be indicated correctly and
     ...    doesn't affect the system functionality
     ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
-    ...    Check [VOL-4319] for more details
-    [Tags]    functional   ONUUpgradeActivateAbort
-    [Setup]    Start Logging    ONUUpgradeActivateAbort
+    ...    Check [VOL-4320] for more details
+    [Tags]    functional   ONUUpgradeDownloadedAbort
+    [Setup]    Start Logging    ONUUpgradeDownloadedAbort
     [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
     ...           AND             Delete All Devices and Verify
     ...           AND             Restart And Check BBSIM    ${NAMESPACE}
-    ...           AND             Stop Logging    ONUUpgradeActivateAbort
+    ...           AND             Stop Logging    ONUUpgradeDownloadedAbort
     # Add OLT device
     Setup
     # Performing Sanity Test to make sure subscribers are all DHCP and pingable
@@ -228,7 +242,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
         ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
-        Test ONU Upgrade Activate Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        Do ONU Upgrade Downloaded Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
         List ONUs    ${NAMESPACE}    ${bbsim_pod}
     END
     # Additional Verification
@@ -237,8 +251,180 @@
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
 
+Test ONU Upgrade Correct Indication of Activating Abort
+    [Documentation]    Validates the ONU Upgrade activating abort will be indicated correctly and
+    ...    doesn't affect the system functionality
+    ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
+    ...    Check [VOL-4319] for more details
+    [Tags]    functional   ONUUpgradeActivatingAbort
+    [Setup]    Start Logging    ONUUpgradeActivatingAbort
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    ...           AND             Delete All Devices and Verify
+    ...           AND             Restart And Check BBSIM    ${NAMESPACE}
+    ...           AND             Stop Logging    ONUUpgradeActivatingAbort
+    # Add OLT device
+    Setup
+    # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
+        ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
+        Do ONU Upgrade Activating Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        List ONUs    ${NAMESPACE}    ${bbsim_pod}
+    END
+    # Additional Verification
+    Wait Until Keyword Succeeds    ${timeout}    2s    Delete All Devices and Verify
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+
+Test ONU Upgrade Correct Indication of Active Abort
+    [Documentation]    Validates the ONU Upgrade active abort will be indicated correctly and
+    ...    doesn't affect the system functionality
+    ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
+    ...    Check [VOL-4320] for more details
+    [Tags]    functional   ONUUpgradeActiveAbort
+    [Setup]    Start Logging    ONUUpgradeActiveAbort
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    ...           AND             Delete All Devices and Verify
+    ...           AND             Restart And Check BBSIM    ${NAMESPACE}
+    ...           AND             Stop Logging    ONUUpgradeActiveAbort
+    # Add OLT device
+    Setup
+    # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
+        ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
+        Do ONU Upgrade Active Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        List ONUs    ${NAMESPACE}    ${bbsim_pod}
+    END
+    # Additional Verification
+    Wait Until Keyword Succeeds    ${timeout}    2s    Delete All Devices and Verify
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+
+Test ONU Upgrade Correct Indication of Committed Abort
+    [Documentation]    Validates the ONU Upgrade committed abort will be indicated correctly and
+    ...    doesn't affect the system functionality. Check BBSIM server transfer image counter after further download,
+    ...    counter should be incremented.
+    ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
+    ...    Check [VOL-4320] for more details
+    [Tags]    functional   ONUUpgradeCommittedAbort
+    [Setup]    Start Logging    ONUUpgradeCommittedAbort
+    [Teardown]    Run Keywords    Run Keyword If    ${portFwdHandle}!=None    Terminate Process    ${portFwdHandle}    kill=true
+    ...           AND             Set Suite Variable   ${portFwdHandle}    None
+    ...           AND             Run Keyword If    ${logging}    Collect Logs
+    ...           AND             Delete All Devices and Verify
+    ...           AND             Restart And Check BBSIM    ${NAMESPACE}
+    ...           AND             Stop Logging    ONUUpgradeCommittedAbort
+    # Add OLT device
+    Setup
+    # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+    # in case of bbsim is running in k8s port forwarding of WEBSERVER is needed
+    ${BBSIM_INSTANCE}   ${BBSIM_WEBSERVER_PORT}=   Run Keyword If   '${image_url}'!='${EMPTY}'   Get BBSIM Svc and Webserver Port
+    ${cmd}    Catenate
+    ...       kubectl port-forward --address 0.0.0.0 -n ${NAMESPACE} svc/${BBSIM_INSTANCE}
+    ...       ${BBSIM_WEBSERVER_PORT}:${BBSIM_WEBSERVER_PORT} &
+    ${portFwdHandle}=    Run Keyword If    ${PORT_FORWARDING}    Start Process   ${cmd}    shell=true
+    Set Suite Variable   ${portFwdHandle}
+    Sleep    5s
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
+        ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
+        Do ONU Upgrade Committed Abort Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        List ONUs    ${NAMESPACE}    ${bbsim_pod}
+    END
+    # Additional Verification
+    Wait Until Keyword Succeeds    ${timeout}    2s    Delete All Devices and Verify
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+
+Test ONU Upgrade Correct Indication Multiple Image Download
+    [Documentation]    Validates the ONU Upgrade multiple Image Download will be indicated correctly,
+    ...    In case of (re-) download the same image without aborting the cached one in openonu-adapter should taken,
+    ...    no further download from server has executed. Check BBSIM server transfer image counter after further download,
+    ...    counter should NOT be incremented.
+    ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
+    ...    Check [VOL-4320] for more details
+    [Tags]    functional   ONUUpgradeMultipleImageDownload
+    [Setup]    Start Logging    ONUUpgradeMultipleImageDownload
+    [Teardown]    Run Keywords    Run Keyword If    ${portFwdHandle}!=None    Terminate Process    ${portFwdHandle}    kill=true
+    ...           AND             Set Suite Variable   ${portFwdHandle}    None
+    ...           AND             Run Keyword If    ${logging}    Collect Logs
+    ...           AND             Delete All Devices and Verify
+    ...           AND             Restart And Check BBSIM    ${NAMESPACE}
+    ...           AND             Stop Logging    ONUUpgradeMultipleImageDownload
+    # Add OLT device
+    Setup
+    # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+    # in case of bbsim is running in k8s port forwarding of WEBSERVER is needed
+    ${BBSIM_INSTANCE}   ${BBSIM_WEBSERVER_PORT}=   Run Keyword If   '${image_url}'!='${EMPTY}'   Get BBSIM Svc and Webserver Port
+    ${cmd}    Catenate
+    ...       kubectl port-forward --address 0.0.0.0 -n ${NAMESPACE} svc/${BBSIM_INSTANCE}
+    ...       ${BBSIM_WEBSERVER_PORT}:${BBSIM_WEBSERVER_PORT} &
+    ${portFwdHandle}=    Run Keyword If    ${PORT_FORWARDING}    Start Process   ${cmd}    shell=true
+    Set Suite Variable   ${portFwdHandle}
+    Sleep    5s
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
+        ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
+        Do ONU Upgrade Multiple Image Download Per OLT    ${bbsim_pod}    ${olt_serial_number}
+        List ONUs    ${NAMESPACE}    ${bbsim_pod}
+    END
+    # Additional Verification
+    Wait Until Keyword Succeeds    ${timeout}    2s    Delete All Devices and Verify
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+
+Test ONU Upgrade Image Download Simultaneously
+    [Documentation]    Validates the ONU Upgrade Image Download to all ONUs simultaneously.
+    ...    Test case should executed in multiple ONU (OLT) environment!
+    ...    Performs the sanity and verifies all the ONUs are authenticated/DHCP/pingable
+    ...    Check [VOL-4320] for more details
+    [Tags]    functionalMultipleONUs   ONUUpgradeImageDownloadSimultaneously
+    [Setup]    Start Logging    ONUUpgradeImageDownloadSimultaneously
+    [Teardown]    Run Keywords    Run Keyword If    ${portFwdHandle}!=None    Terminate Process    ${portFwdHandle}    kill=true
+    ...           AND             Set Suite Variable   ${portFwdHandle}    None
+    ...           AND             Run Keyword If    ${logging}    Collect Logs
+    ...           AND             Delete All Devices and Verify
+    ...           AND             Restart And Check BBSIM    ${NAMESPACE}
+    ...           AND             Stop Logging    ONUUpgradeImageDownloadSimultaneously
+    # Add OLT device
+    Setup
+    # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+    # in case of bbsim is running in k8s port forwarding of WEBSERVER is needed
+    ${BBSIM_INSTANCE}   ${BBSIM_WEBSERVER_PORT}=   Run Keyword If   '${image_url}'!='${EMPTY}'   Get BBSIM Svc and Webserver Port
+    ${cmd}    Catenate
+    ...       kubectl port-forward --address 0.0.0.0 -n ${NAMESPACE} svc/${BBSIM_INSTANCE}
+    ...       ${BBSIM_WEBSERVER_PORT}:${BBSIM_WEBSERVER_PORT} &
+    ${portFwdHandle}=    Run Keyword If    ${PORT_FORWARDING}    Start Process   ${cmd}    shell=true
+    Set Suite Variable   ${portFwdHandle}
+    Sleep    5s
+    Do ONU Upgrade Image Download Simultaneously
+    # Additional Verification
+    Wait Until Keyword Succeeds    ${timeout}    2s    Delete All Devices and Verify
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
+
 *** Keywords ***
-Test ONU Upgrade All OLTs
+Do ONU Upgrade All OLTs
     [Documentation]    This keyword performs the ONU Upgrade test on all OLTs
     [Arguments]    ${activate_on_success}=${image_activate_on_success}    ${commit_on_success}=${image_commit_on_success}
     # Add OLT device
@@ -250,7 +436,7 @@
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
         ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
-        Test ONU Upgrade Per OLT    ${bbsim_pod}    ${olt_serial_number}    ${activate_on_success}    ${commit_on_success}
+        Do ONU Upgrade Per OLT    ${bbsim_pod}    ${olt_serial_number}    ${activate_on_success}    ${commit_on_success}
         List ONUs    ${NAMESPACE}    ${bbsim_pod}
     END
     # Additional Verification
@@ -259,10 +445,11 @@
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test
 
-Test ONU Upgrade Per OLT
+Do ONU Upgrade Per OLT
     [Documentation]    This keyword performs the ONU Upgrade test on single OLT
     [Arguments]    ${bbsim_pod}    ${olt_serial_number}   ${activate_on_success}=${image_activate_on_success}
     ...            ${commit_on_success}=${image_commit_on_success}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
@@ -307,11 +494,12 @@
         Remove Adapter Image    ${image_version}    ${onu_device_id}
     END
 
-Test ONU Upgrade Download Failure Per OLT
+Do ONU Upgrade Download Failure Per OLT
     [Documentation]    This keyword performs the ONU Upgrade Dowload Failure test on single OLT
     [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
     ...            ${dwl_dwlstate}=DOWNLOAD_STARTED    ${dwl_reason}=NO_ERROR    ${dwl_imgstate}=IMAGE_UNKNOWN
     ...            ${dwlstate}=DOWNLOAD_SUCCEEDED    ${reason}=NO_ERROR    ${imgstate}=IMAGE_INACTIVE
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    INVALID_IMAGE    ${onu_device_id}
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
@@ -328,9 +516,10 @@
         Remove Adapter Image    INVALID_IMAGE    ${onu_device_id}
     END
 
-Test ONU Upgrade Download Abort Per OLT
-    [Documentation]    This keyword performs the ONU Upgrade Download Abort test on single OLT
+Do ONU Upgrade Downloading Abort Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Downloading Abort test on single OLT
     [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
@@ -349,9 +538,10 @@
         Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
     END
 
-Test ONU Upgrade Activate Abort Per OLT
-    [Documentation]    This keyword performs the ONU Upgrade Activate Abort test on single OLT
+Do ONU Upgrade Downloaded Abort Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Downloaded Abort test on single OLT
     [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
@@ -362,7 +552,31 @@
         ...    false    false    ${image_crc}    ${onu_device_id}
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
         ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_INACTIVE
-        Activate ONU Device Image    ${image_version}    true    ${onu_device_id}
+        Abort ONU Device Image    ${image_version}    ${onu_device_id}
+        ...    DOWNLOAD_SUCCEEDED    CANCELLED_ON_REQUEST    IMAGE_INACTIVE
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    CANCELLED_ON_REQUEST    IMAGE_INACTIVE
+        #   !!!    Expected is image is not visible in list   !!!
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    False    False    True
+        Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
+    END
+
+Do ONU Upgrade Activating Abort Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Activating Abort test on single OLT
+    [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_serial_number}"!="${src['olt']}"
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        # Download Image
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    false    false    ${image_crc}    ${onu_device_id}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_INACTIVE
+        Activate ONU Device Image    ${image_version}    false    ${onu_device_id}
         Abort ONU Device Image    ${image_version}    ${onu_device_id}
         ...    DOWNLOAD_SUCCEEDED    CANCELLED_ON_REQUEST    IMAGE_ACTIVATING
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
@@ -373,6 +587,156 @@
         Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
     END
 
+Do ONU Upgrade Active Abort Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Active Abort test on single OLT
+    [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_serial_number}"!="${src['olt']}"
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        # Download Image
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    false    false    ${image_crc}    ${onu_device_id}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_INACTIVE
+        Activate ONU Device Image    ${image_version}    false    ${onu_device_id}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_ACTIVE
+        Abort ONU Device Image    ${image_version}    ${onu_device_id}
+        ...    DOWNLOAD_SUCCEEDED    CANCELLED_ON_REQUEST    IMAGE_ACTIVE
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    CANCELLED_ON_REQUEST    IMAGE_ACTIVE
+        #   !!!    Expected is image is not visible in list   !!!
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    False    True    True
+        Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
+    END
+
+Do ONU Upgrade Committed Abort Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Committed Abort test on single OLT
+    [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_serial_number}"!="${src['olt']}"
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${Images_Count_Start}=    Get Images Count
+        # Download Image
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    false    false    ${image_crc}    ${onu_device_id}
+        # After download of image, check image counter of BBSIM, has to be incremented by 2, because bbsim increments counter
+        # whenever openonu adapter touch the image, so one increment for check image is available and one for downloading
+        ${Images_Count_First}=    Get Images Count
+        ${Images_Count_Start}=    Evaluate    ${Images_Count_Start}+2
+        Should Be Equal as Integers    ${Images_Count_First}    ${Images_Count_Start}    Count of image download not correct!
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_INACTIVE
+        Activate ONU Device Image    ${image_version}    false    ${onu_device_id}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_SUCCEEDED    NO_ERROR    IMAGE_ACTIVE
+        Commit ONU Device Image    ${image_version}    ${onu_device_id}
+        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
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image On BBSim    ${NAMESPACE}    ${bbsim_pod}
+        ...    ${src['onu']}    software_image_committed
+        Abort ONU Device Image    ${image_version}    ${onu_device_id}
+        ...    DOWNLOAD_UNKNOWN    NO_ERROR    IMAGE_UNKNOWN
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image Status    ${image_version}
+        ...    ${onu_device_id}    DOWNLOAD_UNKNOWN    NO_ERROR    IMAGE_UNKNOWN
+        #   !!!    Expected is image is not visible in list   !!!
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image List    ${onu_device_id}
+        ...    ${image_version}    True    True    True
+        Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
+        ${Images_Count_Intermediate}=    Get Images Count
+        # Repeat download of aborted image, check image counter of BBSIM, has to be incremented by 2, because bbsim increments
+        # whenever openonu adapter touch the image, so one increment for check image is available and one for downloading
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    false    false    ${image_crc}    ${onu_device_id}
+        ${Images_Count_End}=    Get Images Count
+        ${Images_Count_Intermediate}=    Evaluate    ${Images_Count_Intermediate}+2
+        Should Be Equal as Integers    ${Images_Count_End}    ${Images_Count_Intermediate}   Count of image download not correct!
+        Remove Adapter Image    ${image_version}    ${onu_device_id}
+    END
+
+Do ONU Upgrade Multiple Image Download Per OLT
+    [Documentation]    This keyword performs the ONU Upgrade Image Download test on single OLT
+    [Arguments]    ${bbsim_pod}    ${olt_serial_number}    ${url}=${image_url}
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Continue For Loop If    "${olt_serial_number}"!="${src['olt']}"
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${Images_Count_Start}=    Get Images Count
+        # Download Image
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    true    true    ${image_crc}    ${onu_device_id}
+        # After download of image, check image counter of BBSIM, has to be incremented by 2, because bbsim increments counter
+        # whenever openonu adapter touch the image, so one increment for check image is available and one for downloading
+        ${Images_Count_First}=    Get Images Count
+        ${Images_Count_Start}=    Evaluate    ${Images_Count_Start}+2
+        Should Be Equal as Integers    ${Images_Count_First}    ${Images_Count_Start}    Count of image download not correct!
+        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
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image On BBSim    ${NAMESPACE}    ${bbsim_pod}
+        ...    ${src['onu']}    software_image_committed
+        Wait Until Keyword Succeeds    ${timeout}    5s    Perform Sanity Test     ${suppressaddsubscriber}
+        ${Images_Count_Intermediate}=    Get Images Count
+        # Repeat download of same image, check image counter of BBSIM, has to be not incremented, because no download from
+        # server will be executed, the cached one from openonu-adapter will taken
+        Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+        ...    false    false    ${image_crc}    ${onu_device_id}
+        ${Images_Count_End}=    Get Images Count
+        Should Be Equal as Integers    ${Images_Count_End}    ${Images_Count_Intermediate}   Count of image download not correct!
+        Remove Adapter Image    ${image_version}    ${onu_device_id}
+    END
+
+Do ONU Upgrade Image Download Simultaneously
+    [Documentation]    This keyword performs the ONU Upgrade Image Download Simultaneously on all ONUs test
+    [Arguments]    ${url}=${image_url}
+    [Teardown]     Remove Adapter Image from ONUs    ${image_version}    ${list_onus}
+    # collect all ONU's device ids
+    ${list_onus}    Create List
+    Build ONU Device Id List    ${list_onus}
+    # prepare OLT-SN BBSIM-POD releation dictionary for later fast access
+    ${olt_bbsim_dict}=     Create Dictionary
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${bbsim_rel}=    Catenate    SEPARATOR=    bbsim    ${J}
+        ${bbsim_pod}=    Get Pod Name By Label    ${NAMESPACE}    release     ${bbsim_rel}
+        Set To Dictionary    ${olt_bbsim_dict}    ${olt_serial_number}    ${bbsim_pod}
+    END
+    ${Images_Count_Start}=    Get Images Count
+    # Download Image to all ONUs simultaneously
+    ${onu_device_ids} =    Catenate    @{list_onus}
+    Download ONU Device Image    ${image_version}    ${url}    ${image_vendor}
+    ...    true    true    ${image_crc}    ${onu_device_ids}
+    # do all the check stuff
+    FOR  ${onu_device_id}  IN  @{list_onus}
+        Log  ${onu_device_id}
+        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
+    # last but not least check bbsim
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${bbsim_pod}=    Get From Dictionary    ${olt_bbsim_dict}    ${src['olt']}
+        Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU Device Image On BBSim    ${NAMESPACE}    ${bbsim_pod}
+        ...    ${src['onu']}    software_image_committed
+    END
+    ${Images_Count_End}=    Get Images Count
+    ${Images_Count_Start}=    Evaluate    ${Images_Count_Start}+2
+    Should Be Equal as Integers    ${Images_Count_End}    ${Images_Count_Start}   Count of image download not correct!
+
 Restart And Check BBSIM
     [Documentation]    This keyword restarts bbsim and waits for it to come up again
     ...    Following steps will be executed:
@@ -386,11 +750,28 @@
     Sleep    5s
     Wait For Pods Ready    ${namespace}    ${bbsim_apps}
 
+Get BBSIM Svc and Webserver Port
+    [Documentation]    This keyword gets bbsim instance and bbsim webserver port from image url
+    @{words}=    Split String    ${image_url}    /
+    ${SvcAndPort}    Set Variable     @{words}[2]
+    ${bbsim_svc}    ${webserver_port}=    Split String    ${SvcAndPort}    :    1
+    ${svc_return}    Set Variable If    '${bbsim_svc}'!='${EMPTY}'    ${bbsim_svc}    ${BBSIM_INSTANCE}
+    ${port_return}   Set Variable If    '${webserver_port}'!='${EMPTY}'    ${webserver_port}    ${BBSIM_WEBSERVER_PORT}
+    [Return]    ${svc_return}    ${port_return}
+
 Setup Suite
     [Documentation]    Set up the test suite
+    Start Logging Setup or Teardown    Setup-${SUITE NAME}
     Common Test Suite Setup
+    Run Keyword If    ${logging}    Collect Logs
+    Stop Logging Setup or Teardown    Setup-${SUITE NAME}
 
 Teardown Suite
     [Documentation]    Tear down steps for the suite
+    Start Logging Setup or Teardown    Teardown-${SUITE NAME}
+    # stop port forwarding if still running
+    Run Keyword If    ${portFwdHandle}!=None    Terminate Process    ${portFwdHandle}    kill=true
     Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Run Keyword If    ${logging}    Collect Logs
+    Stop Logging Setup or Teardown    Teardown-${SUITE NAME}
     Close All ONOS SSH Connections