[VOL-3676] OpenOnu-Go-Adapter: Improvements for tests for OpenOnu-Go-Adapter

Change-Id: Id970b6e770dae517d3f81347212045dba117db0a
diff --git a/Makefile b/Makefile
index ec8a7e5..b824ae9 100755
--- a/Makefile
+++ b/Makefile
@@ -90,7 +90,7 @@
 
 # target to invoke openonu go adapter
 openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v logging:True -i sanityOnuGo -i functionalOnuGo -v timeout:180s
+openonu-go-adapter-test: ROBOT_MISC_ARGS += -v logging:True -i sanityOnuGo -i functionalOnuGo
 openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
 openonu-go-adapter-test: ROBOT_FILE := Voltha_ONUStateTests.robot
@@ -98,7 +98,7 @@
 
 # target to invoke test with openonu go adapter applying 1T4GEM tech-profile at single ONU
 1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T4GEM -v logging:True -v timeout:180s
+1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T4GEM -v logging:True
 1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i sanityOnuGo -i functionalOnuGo
 1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 1t4gem-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
@@ -107,7 +107,7 @@
 
 # target to invoke test with openonu go adapter applying 1T8GEM tech-profile at single ONU
 1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T8GEM -v logging:True -v timeout:180s
+1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T8GEM -v logging:True
 1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i sanityOnuGo -i functionalOnuGo
 1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 1t8gem-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
@@ -116,7 +116,7 @@
 
 # target to invoke multiple openonu go adapter
 multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v logging:True -i sanityOnuGo -i functionalOnuGo -v timeout:180s
+multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v logging:True -i sanityOnuGo -i functionalOnuGo
 multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 multi-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_ONU_FILE)
 multi-openonu-go-adapter-test: ROBOT_FILE := Voltha_ONUStateTests.robot
@@ -124,7 +124,7 @@
 
 # target to invoke test with openonu go adapter applying 1T4GEM tech-profile at multiple ONU
 multi-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-multi-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T4GEM -v logging:True -v timeout:180s
+multi-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T4GEM -v logging:True
 multi-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i sanityOnuGo -i functionalOnuGo
 multi-1t4gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 multi-1t4gem-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_ONU_FILE)
@@ -133,7 +133,7 @@
 
 # target to invoke test with openonu go adapter applying 1T8GEM tech-profile at multiple ONU
 multi-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:omci-flows-pushed -v testmode:SingleStateTime
-multi-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T8GEM -v logging:True -v timeout:180s
+multi-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v techprofile:1T8GEM -v logging:True
 multi-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i sanityOnuGo -i functionalOnuGo
 multi-1t8gem-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 multi-1t8gem-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_ONU_FILE)
@@ -141,8 +141,7 @@
 multi-1t8gem-openonu-go-adapter-test: openonu-go-adapter-tests
 
 # target to invoke test with openonu go adapter applying MIB-Upload-Templating
-mib-upload-templating-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v timeout:60s -v logging:True
-mib-upload-templating-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i functionalOnuGo
+mib-upload-templating-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v logging:True -i functionalOnuGo
 mib-upload-templating-openonu-go-adapter-test: ROBOT_MISC_ARGS += -e notreadyOnuGo -X $(ROBOT_DEBUG_LOG_OPT)
 mib-upload-templating-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
 mib-upload-templating-openonu-go-adapter-test: ROBOT_FILE := Voltha_ONUTemplateTests.robot
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 7368e8c..bd9e671 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -433,7 +433,7 @@
     END
 
 Assert Ports in ONOS
-    [Arguments]    ${onos_ssh_connection}     ${count}     ${deviceId}  ${filter}
+    [Arguments]    ${onos_ssh_connection}     ${count}     ${deviceId}    ${filter}
     [Documentation]    Check that a certain number of ports are enabled in ONOS
     ${ports}=    Execute ONOS CLI Command on open connection     ${onos_ssh_connection}
         ...    ports -e ${deviceId} | grep ${filter} | wc -l
@@ -441,22 +441,22 @@
     Should Be Equal As Integers    ${ports}    ${count}
 
 Wait for Ports in ONOS
-    [Arguments]    ${onos_ssh_connection}     ${count}     ${deviceId}  ${filter}
+    [Arguments]    ${onos_ssh_connection}    ${count}    ${deviceId}    ${filter}    ${max_wait_time}=10m
     [Documentation]    Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
-    Wait Until Keyword Succeeds     10m     5s      Assert Ports in ONOS
+    Wait Until Keyword Succeeds     ${max_wait_time}     5s      Assert Ports in ONOS
     ...     ${onos_ssh_connection}     ${count}     ${deviceId}     ${filter}
 
 Wait for AAA Authentication
-    [Arguments]    ${onos_ssh_connection}     ${count}  ${deviceId}
+    [Arguments]    ${onos_ssh_connection}    ${count}    ${deviceId}    ${max_wait_time}=10m
     [Documentation]    Waits untill a certain number of subscribers are authenticated in ONOS
-    Wait Until Keyword Succeeds     10m     5s      Assert Number of AAA-Users
+    Wait Until Keyword Succeeds     ${max_wait_time}     5s      Assert Number of AAA-Users
     ...     ${onos_ssh_connection}     ${count}     ${deviceId}
 
 Wait for DHCP Ack
-    [Arguments]    ${onos_ssh_connection}     ${count}  ${workflow}     ${deviceId}
+    [Arguments]    ${onos_ssh_connection}    ${count}    ${workflow}    ${deviceId}    ${max_wait_time}=10m
     [Documentation]    Waits untill a certain number of subscribers have received a DHCP_ACK
-    Wait Until Keyword Succeeds     10m     5s      Validate DHCP Allocations
-        ...     ${onos_ssh_connection}     ${count}  ${workflow}    ${deviceId}
+    Wait Until Keyword Succeeds     ${max_wait_time}     5s      Validate DHCP Allocations
+        ...     ${onos_ssh_connection}     ${count}    ${workflow}    ${deviceId}
 
 Provision subscriber
     [Documentation]  Calls volt-add-subscriber-access in ONOS
diff --git a/libraries/utils.robot b/libraries/utils.robot
old mode 100644
new mode 100755
index c0a146d..50e33f2
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -24,7 +24,7 @@
 Library           OperatingSystem
 Library           CORDRobot
 Library           ImportResource    resources=CORDRobot
-Resource          ./libraries/voltctl.robot
+Resource          ./voltctl.robot
 
 *** Keywords ***
 Check CLI Tools Configured
@@ -111,7 +111,8 @@
     ${count}=    Set Variable    0
     FOR    ${I}    IN RANGE    0     ${src_length}
         ${sn}    Evaluate    ${src}[${I}].get("olt")
-        ${count}=    Run Keyword If    '${serial_number}' == '${sn}'    Evaluate    ${count} + 1    ELSE  Set Variable  ${count}
+        ${count}=    Run Keyword If    '${serial_number}' == '${sn}'    Evaluate    ${count} + 1
+        ...          ELSE  Set Variable  ${count}
     END
     [Return]    ${count}
 
@@ -214,7 +215,8 @@
     ...    Sanity test performs authentication, dhcp and pings for all the ONUs given for the POD
     ...    This keyword can be used to call in any other tests where sanity check is required
     ...    and avoids duplication of code. - ATT workflow
-    #${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS    ${olt_serial_number}
+    #${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s
+    #...    Validate OLT Device in ONOS    ${olt_serial_number}
     #Set Global Variable    ${of_id}
     #${nni_port}=    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2s
     #...    Get NNI Port in ONOS    ${of_id}
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index 410a545..4ae5bd5 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -1,3 +1,17 @@
+# Copyright 2020 - present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 *** Settings ***
 Documentation     Test states of ONU Go adapter with ATT workflows only (not for DT/TT workflow!)
 Suite Setup       Setup Suite
@@ -19,7 +33,7 @@
 Resource          Voltha_ONUUtilities.robot
 
 *** Variables ***
-${timeout}        180s
+${timeout}        60s
 ${of_id}          0
 ${logical_id}     0
 ${has_dataplane}    True
@@ -53,6 +67,9 @@
 # if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline!
 # example: -v pausebeforecleanup:True
 ${pausebeforecleanup}    False
+# if True some outputs to console are done during running tests e.g. long duration flow test
+# example: -v print2console:True
+${print2console}    False
 ${data_dir}    ../data
 
 
@@ -96,13 +113,9 @@
     ...    Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
     [Tags]    functionalOnuGo    PortTestOnuGo
     [Setup]    Start Logging    ONUPortTest
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
-        ...    Do Onu Port Check    ${of_id}
-        ...    ELSE    Pass Execution    ${skip_message}    skipped
-    END
+    Run Keyword If    '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
+    ...    Do Onu Port Check
+    ...    ELSE    Pass Execution    ${skip_message}    skipped
     [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
     ...    AND    Stop Logging    ONUPortTest
 
@@ -178,6 +191,7 @@
     ...    \r\nPassed arguments:
     ...    state2test:${state2test}, testmode:${testmode}, techprofile:${techprofile},
     ...    debugmode:${debugmode}, logging:${logging}, pausebeforecleanup:${pausebeforecleanup},
+    ...    print2console:${print2console}
     Log    ${LogInfo}    console=yes
     Common Test Suite Setup
     # prepare skip message in yellow for console log
@@ -185,6 +199,7 @@
     ${skipped}=  Evaluate  "\\033[33m${SPACE*14} ===> Test case above was skipped! <=== ${SPACE*15}\\033[0m"
     ${skip_message}    Catenate    ${skipped} | ${skip} |
     Set Suite Variable    ${skip_message}
+    Set Suite Variable    ${all_onu_timeout}    ${timeout}
     Run Keyword If   ${num_all_onus}>4    Calculate Timeout
     ${techprofile}=    Set Variable If    "${techprofile}"=="1T1GEM"    default    ${techprofile}
     Run Keyword If    "${techprofile}"=="default"   Log To Console    \nTechProfile:default (1T1GEM)
@@ -213,11 +228,11 @@
     Run Keyword If    ${pausebeforecleanup}    Log    Teardown will be continued...    console=yes
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
     Validate Onu Data In Etcd    0
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Wait for Ports in ONOS    ${onos_ssh_connection}    0    ${of_id}    BBSM
-    END
+    # Re-open ssh connection to onos since no keep alive is implemented in  SSH library
+    Close ONOS SSH Connection   ${onos_ssh_connection}
+    ${onos_ssh_connection}    Open ONOS SSH Connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
+    Set Suite Variable  ${onos_ssh_connection}
+    Wait for Ports in ONOS for all OLTs      ${onos_ssh_connection}  0   BBSM    ${timeout}
     Close ONOS SSH Connection   ${onos_ssh_connection}
     Remove Tech Profile
 
@@ -247,11 +262,12 @@
 
 Calculate Timeout
     [Documentation]    Calculates the timeout regarding num-onus in case of more than 4 onus
-    ${timeout}    Fetch From Left    ${timeout}    s
-    ${timeout}=    evaluate    ${timeout}+((${num_all_onus}-4)*30)
-    ${timeout}=    Set Variable If    (not ${debugmode}) and (${timeout}>600)    600    ${timeout}
-    ${timeout}=    Catenate    SEPARATOR=    ${timeout}    s
-    Set Suite Variable    ${timeout}
+    ${all_onu_timeout}    Fetch From Left    ${all_onu_timeout}    s
+    ${all_onu_timeout}=    evaluate    ${all_onu_timeout}+((${num_all_onus}-4)*10)
+    ${all_onu_timeout}=    Set Variable If    (not ${debugmode}) and (${all_onu_timeout}>300)
+    ...    300   ${all_onu_timeout}
+    ${all_onu_timeout}=    Catenate    SEPARATOR=    ${all_onu_timeout}    s
+    Set Suite Variable    ${all_onu_timeout}
 
 Do ONU Up To State Test
     [Documentation]    This keyword performs Up2State Test
@@ -260,27 +276,27 @@
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
         Run Keyword If   ${onu_state_nb}>=1
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVATING    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=activating-onu
         Run Keyword If   ${onu_state_nb}>=2
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVATING    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=starting-openomci
         Run Keyword If   ${onu_state_nb}>=3
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVATING    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=discovery-mibsync-complete
         Run Keyword If   ${onu_state_nb}>=4
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVE    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=initial-mib-downloaded
         Run Keyword If   ${onu_state_nb}>=5
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVE    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=tech-profile-config-download-success
         Run Keyword If   ${onu_state_nb}>=6
-        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        ...    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ENABLED    ACTIVE    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=omci-flows-pushed
     END
@@ -291,7 +307,7 @@
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
         ...    Validate Device    ${admin_state}    ${oper_status}    ${connect_status}
         ...    ${src['onu']}    onu=True    onu_reason=${onu_state}
     END
@@ -305,15 +321,14 @@
     Create File    ONU_Startup_Time.txt    This file contains the startup times of all ONUs.
     ${list_onus}    Create List
     Build ONU SN List    ${list_onus}
-    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    50ms
+    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${all_onu_timeout}    50ms
     ...    Validate ONU Devices MIB State With Duration
-    ...    ${onu_state}    ${list_onus}    ${timeStart}    print2console=True
+    ...    ${onu_state}    ${list_onus}    ${timeStart}    print2console=${print2console}
     ...    output_file=ONU_Startup_Time.txt
 
 Do Onu Port Check
     [Documentation]    Check that all the UNI ports show up in ONOS
-    [Arguments]     ${olt_serial_number}
-    Wait for Ports in ONOS    ${onos_ssh_connection}    ${num_all_onus}    ${olt_serial_number}     BBSM
+    Wait for Ports in ONOS for all OLTs    ${onos_ssh_connection}    ${num_all_onus}    BBSM
 
 Do Onu Etcd Data Check
     [Documentation]    Check Onu data stored in etcd
@@ -329,11 +344,20 @@
         ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
         ...    ${olt_serial_number}
         Set Global Variable    ${of_id}
+        # Verify Default Meter in ONOS (valid only for ATT)
+        Do Onu Subscriber Add Per OLT    ${of_id}    ${olt_serial_number}   ${onu_count}
+    END
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${onu_count}=    Set Variable    ${list_olts}[${J}][onucount]
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        Set Global Variable    ${of_id}
         ${nni_port}=    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2s
         ...    Get NNI Port in ONOS    ${of_id}
         Set Global Variable    ${nni_port}
         # Verify Default Meter in ONOS (valid only for ATT)
-        Do Onu Subscriber Add And Flow Check Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}   ${onu_count}
+        Do Onu Flow Check Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}   ${onu_count}
     END
     #log flows for verification
     ${flowsresult}=    Execute ONOS CLI Command    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s
@@ -357,16 +381,21 @@
     END
     #check  for previous state is kept (normally omci-flows-pushed)
     Sleep    10s
+    Run Keyword If    ${print2console}    Log    \r\nStart State Test All Onus.    console=yes
     Run Keyword And Continue On Failure    Do Current State Test All Onus    ${state2test}
+    Run Keyword If    ${print2console}    Log    \r\nFinished State Test All Onus.    console=yes
     Run Keyword And Continue On Failure    Validate Vlan Rules In Etcd    prevvlanrules=${firstvlanrules}
     ...                                    setvidequal=True
+    # Re-open ssh connection to onos since no keep alive is implemented in  SSH library
+    Close ONOS SSH Connection   ${onos_ssh_connection}
+    ${onos_ssh_connection}    Open ONOS SSH Connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
+    Set Suite Variable  ${onos_ssh_connection}
 
-Do Onu Subscriber Add And Flow Check Per OLT
-    [Documentation]    Add Subscriber per OLT and checks all ONU flows show up in ONOS and Voltha
-    [Arguments]    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}
+Do Onu Subscriber Add Per OLT
+    [Documentation]    Add Subscriber per OLT
+    [Arguments]    ${of_id}    ${olt_serial_number}    ${num_onus}
     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']}
         ${onu_port}=    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2s
@@ -374,10 +403,26 @@
         Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
         ...    Execute ONOS CLI Command    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
         ...    volt-add-subscriber-access ${of_id} ${onu_port}
+        Run Keyword If    ${print2console}    Log    \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
+        ...   console=yes
+    END
+
+Do Onu Flow Check Per OLT
+    [Documentation]    Checks all ONU flows show up in ONOS and Voltha
+    [Arguments]    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        Continue For Loop If    "${olt_serial_number}"!="${src['olt']}"
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${onu_port}=    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2s
+        ...    Get ONU Port in ONOS    ${src['onu']}    ${of_id}
         # Verify subscriber access flows are added for the ONU port
         Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
         ...    Verify Subscriber Access Flows Added For ONU    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
         ...    ${onu_port}    ${nni_port}    ${src['c_tag']}    ${src['s_tag']}
+        ${logoutput}    Catenate    \r\n[${I}] Verify Subscriber Access Flows Added For
+        ...    ONU ${of_id}    ${onu_port}    ${src['c_tag']}    ${src['s_tag']}.
+        Run Keyword If    ${print2console}    Log    ${logoutput}    console=yes
     END
 
 Do Onu Subscriber Remove Per OLT
@@ -393,6 +438,8 @@
         Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
         ...    Execute ONOS CLI Command    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
         ...    volt-remove-subscriber-access ${of_id} ${onu_port}
+        Run Keyword If    ${print2console}    Log    \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
+        ...    console=yes
     END
 
 Set Tech Profile
@@ -403,12 +450,13 @@
     ${podname}=    Set Variable    etcd
     ${src}=    Set Variable    ${data_dir}/TechProfile-${TechProfile}.json
     ${dest}=    Set Variable    /tmp/flexpod.json
+    ${stackname}=    Get Stack Name
     ${command}    Catenate
-    ...    /bin/sh -c 'cat    ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'cat    ${dest} | ETCDCTL_API=3 etcdctl put service/${stackname}/technology_profiles/XGS-PON/64'
     Copy File To Pod    ${namespace}    ${podname}    ${src}    ${dest}
     Exec Pod In Kube    ${namespace}    ${podname}    ${command}
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/technology_profiles/XGS-PON/64'
     Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
 
 Remove Tech Profile
@@ -416,19 +464,21 @@
     Log To Console    \nTechProfile:${TechProfile}
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
+    ${stackname}=    Get Stack Name
     ${command}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${stackname}/technology_profiles/XGS-PON/64'
     Exec Pod In Kube    ${namespace}    ${podname}    ${command}
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/technology_profiles/XGS-PON/64'
     Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
 
 Do Check Tech Profile
     [Documentation]    This keyword checks the loaded TechProfile
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
+    ${stackname}=    Get Stack Name
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/technology_profiles/XGS-PON/64'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     ${num_gem_ports}=    Set Variable    1
     ${num_gem_ports}=    Set Variable If
@@ -449,25 +499,18 @@
     ...    ${state2checkafterdisable}=tech-profile-config-delete-success
     Run Keyword If    ${checkstatebeforedisable}    Do Current State Test All Onus    ${state2check}
     Do Disable Onu Device
-    ${alternative_onu_reason}=    Set Variable If    '${state2checkafterdisable}'=='tech-profile-config-delete-success'
-    ...    omci-flows-deleted    ${EMPTY}
+    ${alternative_onu_reason}=    Set Variable If
+    ...    '${state2checkafterdisable}'=='tech-profile-config-delete-success'    omci-flows-deleted
+    ...    '${state2checkafterdisable}'=='omci-admin-lock'    tech-profile-config-delete-success    ${EMPTY}
     Do Current State Test All Onus    ${state2checkafterdisable}    alternativeonustate=${alternative_onu_reason}
     Log Ports
     #check no port is enabled in ONOS
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Wait for Ports in ONOS    ${onos_ssh_connection}    0    ${of_id}    BBSM
-    END
+    Wait for Ports in ONOS for all OLTs    ${onos_ssh_connection}    0    BBSM
     Do Enable Onu Device
     Do Current State Test All Onus    ${state2check}
     Log Ports    onlyenabled=True
     #check that all the UNI ports show up in ONOS again
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Wait for Ports in ONOS    ${onos_ssh_connection}    ${num_all_onus}     ${of_id}    BBSM
-    END
+    Wait for Ports in ONOS for all OLTs    ${onos_ssh_connection}    ${num_all_onus}    BBSM
 
 Do Reconcile Onu Device
     [Documentation]    This keyword reconciles ONU device and check the state afterwards.
@@ -489,11 +532,7 @@
     Sleep    5s
     Wait For Pods Ready    ${namespace}    ${list_openonu_apps}
     Do Disable Enable Onu Test
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Do Onu Port Check   ${of_id}
-    END
+    Do Onu Port Check
 
 Do Power Off Power On Onu Device
     [Documentation]    This keyword power off/on all onus and checks the states.
@@ -518,11 +557,7 @@
     Run Keyword Unless    ${has_dataplane}    Do Disable Enable Onu Test    checkstatebeforedisable=False
     ...    state2checkafterdisable=omci-admin-lock
     Run Keyword If    ${has_dataplane}    Do Current State Test All Onus    omci-flows-pushed
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Do Onu Port Check   ${of_id}
-    END
+    Do Onu Port Check
 
 Do Disable Onu Device
     [Documentation]    This keyword disables all onus.
diff --git a/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot b/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
index 0386b27..5ef9b6a 100755
--- a/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUTemplateTests.robot
@@ -1,3 +1,17 @@
+# Copyright 2020 - present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 *** Settings ***
 Documentation     Test Template handling of ONU Go adapter with BBSIM controlledActivation: only-onu only!
 ...               Values.yaml must contain 'onu: 2' and 'controlledActivation: only-onu' under BBSIM!
@@ -22,7 +36,7 @@
 
 *** Variables ***
 ${NAMESPACE}      voltha
-${timeout}        180s
+${timeout}        60s
 ${of_id}          0
 ${logical_id}     0
 ${has_dataplane}    True
@@ -51,7 +65,7 @@
     ...                - request MIB-Upload-Data by ONU via OMCI
     ...                - storage MIB-Upload-Data in etcd
     ...                - store setup duration of ONU
-    ...                - check Template-Data in etcd stored (service/voltha/omci_mibs/go_templates/)
+    ...                - check Template-Data in etcd stored (service/%{NAME}/omci_mibs/go_templates/)
     ...                - setup second ONU
     ...                - collect setup durationof second ONU
     ...                - compare both duration
@@ -87,11 +101,7 @@
     Run Keyword If    ${pausebeforecleanup}    Pause Execution    Press OK to continue with clean up!
     Run Keyword If    ${pausebeforecleanup}    Log    Teardown will be continued...    console=yes
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
-    FOR    ${I}    IN RANGE    0    ${num_olts}
-        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
-        ${of_id}=    Wait Until Keyword Succeeds    60s    5s    Validate OLT Device in ONOS    ${olt_serial_number}
-        Wait for Ports in ONOS    ${onos_ssh_connection}    0    ${of_id}    BBSM
-    END
+    Wait for Ports in ONOS for all OLTs      ${onos_ssh_connection}  0   BBSM
     # delete etcd MIB Template Data (for repeating test)
     Delete MIB Template Data
     Close ONOS SSH Connection   ${onos_ssh_connection}
diff --git a/tests/openonu-go-adapter/Voltha_ONUUtilities.robot b/tests/openonu-go-adapter/Voltha_ONUUtilities.robot
index 3c4286d..53ce5ec 100755
--- a/tests/openonu-go-adapter/Voltha_ONUUtilities.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUUtilities.robot
@@ -1,4 +1,4 @@
-# Copyright 2020-present Open Networking Foundation
+# Copyright 2020 - present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -11,11 +11,13 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-# voltctl common functions
 
 *** Settings ***
 Documentation     Library for various openonu-go-adpter utilities
 
+*** Variables ***
+${defaultstackname}    minimal
+
 *** Keywords ***
 Do Power On ONU Device
     [Documentation]    This keyword power on all onus.
@@ -87,9 +89,10 @@
 Verify MIB Template Data Available
     [Documentation]    This keyword verifies MIB Template Data stored in etcd
     ${namespace}=    Set Variable    default
-    ${podname}=    Set Variable    etcd
+    ${podname}=      Set Variable    etcd
+    ${stackname}=    Get Stack Name
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/omci_mibs/go_templates/'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     Should Not Be Empty    ${result}    No MIB Template Data stored in etcd!
 
@@ -97,12 +100,13 @@
     [Documentation]    This keyword deletes MIB Template Data stored in etcd
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
+    ${stackname}=    Get Stack Name
     ${commanddel}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/%{NAME}/omci_mibs/go_templates/'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${stackname}/omci_mibs/go_templates/'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commanddel}
     Sleep    3s
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/%{NAME}/omci_mibs/go_templates/'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/omci_mibs/go_templates/'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     Should Be Empty    ${result}    Could not delete MIB Template Data stored in etcd!
 
@@ -112,8 +116,9 @@
     ...                Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
     ...                Number of etcd entries has to match with the passed number.
     [Arguments]    ${nbofetcddata}=${num_all_onus}
+    ${stackname}=    Get Stack Name
     ${etcddata}=    Get ONU Go Adapter ETCD Data
-    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/%{NAME}/openonu    \n
+    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${stackname}/openonu    \n
     #prepare result for json convert
     ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
     ${jsondata}=    To Json    ${result}
@@ -149,8 +154,9 @@
     ...                In case of a passed dictionary containing set_vids these will be checked for to
     ...                current set-vid depending on setvidequal (True=equal, False=not equal).
     [Arguments]    ${nbofcookieslice}=1    ${reqmatchvid}=4096    ${prevvlanrules}=${NONE}    ${setvidequal}=False
+    ${stackname}=    Get Stack Name
     ${etcddata}=    Get ONU Go Adapter ETCD Data
-    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/%{NAME}/openonu    \n
+    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${stackname}/openonu    \n
     #prepare result for json convert
     ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
     ${jsondata}=    To Json    ${result}
@@ -189,8 +195,9 @@
     [Documentation]    This keyword delivers openonu-go-adapter Data stored in etcd
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
+    ${stackname}=    Get Stack Name
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix --prefix service/%{NAME}/openonu'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix --prefix service/${stackname}/openonu'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     log    ${result}
     [Return]    ${result}
@@ -266,6 +273,25 @@
     Should Be Equal As Integers    ${uni}    ${uni_id}
     ...    msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
 
+Get Stack Name
+    [Documentation]    This keyword delivers the stack name read from environment variable NAME if present.
+    ${env_name}=    Get Environment Variable    NAME    default=${defaultstackname}
+    # while Get Environment Variable does not work correctly, a manual correction follows
+    ${env_name}=    Set Variable If    "${env_name}"=="${EMPTY}"    ${defaultstackname}    ${env_name}
+    [Return]    ${env_name}
+
+Wait for Ports in ONOS for all OLTs
+    [Documentation]    Waits untill a certain number of ports are enabled in all ONOS
+    [Arguments]    ${onos_ssh_connection}    ${count}    ${filter}    ${max_wait_time}=10m
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${onu_count}=    Set Variable    ${list_olts}[${J}][onucount]
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        Set Global Variable    ${of_id}
+        Wait for Ports in ONOS    ${onos_ssh_connection}    ${count}    ${of_id}    BBSM    ${max_wait_time}
+    END
+
 Map State
     [Documentation]    This keyword converts the passed numeric value or name of a onu state to its state values.
     [Arguments]    ${state}