[VOL-4249] Create Flow check test

Change-Id: I520b5155a00b99a0cfad7777a1cf1fb25f147d56
diff --git a/Makefile b/Makefile
index b59fda4..07abd77 100755
--- a/Makefile
+++ b/Makefile
@@ -451,7 +451,7 @@
 voltha-onu-omci-get-single-kind-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
 voltha-onu-omci-get-single-kind-dt: voltha-onu-omci-get-tests
 
-# target to invoke single ONU OMCI Geta scenarios in TT workflow
+# target to invoke single ONU OMCI Get scenarios in TT workflow
 voltha-onu-omci-get-single-kind-tt: ROBOT_MISC_ARGS += -v workflow:TT
 voltha-onu-omci-get-single-kind-tt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TT_SINGLE_PON_FILE)
 voltha-onu-omci-get-single-kind-tt: voltha-onu-omci-get-tests
@@ -475,6 +475,40 @@
 voltha-onu-omci-get-tests: ROBOT_FILE := Voltha_ONUOmciGetTest.robot
 voltha-onu-omci-get-tests: openonu-go-adapter-tests
 
+# target to invoke single ONU Flows Check in ATT workflow
+voltha-onu-flows-check-single-kind-att: ROBOT_MISC_ARGS += -v workflow:ATT
+voltha-onu-flows-check-single-kind-att: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
+voltha-onu-flows-check-single-kind-att: voltha-onu-flows-check-tests
+
+# target to invoke single ONU Flows Check scenarios in DT workflow
+voltha-onu-flows-check-single-kind-dt: ROBOT_MISC_ARGS += -v workflow:DT -v techprofile:1T8GEM
+voltha-onu-flows-check-single-kind-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
+voltha-onu-flows-check-single-kind-dt: voltha-onu-flows-check-tests
+
+# target to invoke single ONU Flows Check scenarios in TT workflow
+voltha-onu-flows-check-single-kind-tt: ROBOT_MISC_ARGS += -v workflow:TT -v techprofile:1T4GEM
+voltha-onu-flows-check-single-kind-tt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TT_SINGLE_PON_FILE)
+voltha-onu-flows-check-single-kind-tt: voltha-onu-flows-check-tests
+
+# target to invoke multiple OLTs Flows Check scenarios in ATT workflow
+voltha-onu-flows-check-multiolt-kind-att: ROBOT_MISC_ARGS += -v workflow:ATT
+voltha-onu-flows-check-multiolt-kind-att: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULTIPLE_OLT_FILE)
+voltha-onu-flows-check-multiolt-kind-att: voltha-onu-flows-check-tests
+
+# target to invoke multiple OLTs Flows Check scenarios in DT workflow
+voltha-onu-flows-check-multiolt-kind-dt: ROBOT_MISC_ARGS += -v workflow:DT -v techprofile:1T8GEM
+voltha-onu-flows-check-multiolt-kind-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_MULTIPLE_OLT_FILE)
+voltha-onu-flows-check-multiolt-kind-dt: voltha-onu-flows-check-tests
+
+# target to invoke multiple OLTs Flows Check scenarios in TT workflow
+voltha-onu-flows-check-multiolt-kind-tt: ROBOT_MISC_ARGS += -v workflow:TT -v techprofile:1T4GEM
+voltha-onu-flows-check-multiolt-kind-tt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TT_MULTIPLE_OLT_FILE)
+voltha-onu-flows-check-multiolt-kind-tt: voltha-onu-flows-check-tests
+
+voltha-onu-flows-check-tests: ROBOT_MISC_ARGS += -i functionalOnuGo -e PowerSwitch $(ROBOT_DEBUG_LOG_OPT)
+voltha-onu-flows-check-tests: ROBOT_FILE := Voltha_ONUFlowChecks.robot
+voltha-onu-flows-check-tests: openonu-go-adapter-tests
+
 # ONOS Apps to test for Software Upgrade need to be passed in the 'onos_apps_under_test' variable in format:
 # <app-name>,<version>,<oar-url>*<app-name>,<version>,<oar-url>*
 onos-app-upgrade-test: ROBOT_MISC_ARGS +=  -e notready -i functional
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index 903b656..ff71952 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -233,6 +233,57 @@
     ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
     Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
 
+Do Onu Subscriber Add Per OLT
+    [Documentation]    Add Subscriber per OLT
+    [Arguments]    ${of_id}    ${olt_serial_number}    ${print2console}=False
+    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}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
+        ...    Execute ONOS CLI Command use single connection    ${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}    ${print2console}=False
+    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
+    [Documentation]    Removes per OLT subscribers in ONOS and Voltha
+    [Arguments]    ${of_id}    ${olt_serial_number}    ${print2console}=False
+    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
+        ...    Get ONU Port in ONOS    ${src['onu']}    ${of_id}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
+        ...    Execute ONOS CLI Command use single connection    ${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
+
 Validate Resource Instances Used Gem Ports
     [Documentation]    This keyword validates resource instances data stored in etcd.
     ...                It checks checks the number of gemport-ids which has matched with used Tech Profile
diff --git a/tests/data/bbsim-kind-2OLTx2ONUx2PON-dt.yaml b/tests/data/bbsim-kind-2OLTx2ONUx2PON-dt.yaml
index 67a82d8..287f435 100755
--- a/tests/data/bbsim-kind-2OLTx2ONUx2PON-dt.yaml
+++ b/tests/data/bbsim-kind-2OLTx2ONUx2PON-dt.yaml
@@ -65,26 +65,26 @@
       uni_id: '1'
     -
       onu: 'BBSM000b0001'
-      c_tag: '4097'
+      c_tag: '4096'
       s_tag: '900'
       olt: 'BBSIM_OLT_11'
       uni_id: '1'
     -
       onu: 'BBSM000b0002'
-      c_tag: '4097'
+      c_tag: '4096'
       s_tag: '904'
       olt: 'BBSIM_OLT_11'
       uni_id: '1'
     -
       onu: 'BBSM000b0101'
       olt: 'BBSIM_OLT_11'
-      c_tag: '4097'
+      c_tag: '4096'
       s_tag: '908'
       uni_id: '1'
     -
       onu: 'BBSM000b0102'
       olt: 'BBSIM_OLT_11'
-      c_tag: '4097'
+      c_tag: '4096'
       s_tag: '912'
       uni_id: '1'
   dst:
diff --git a/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot b/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot
new file mode 100755
index 0000000..0650198
--- /dev/null
+++ b/tests/openonu-go-adapter/Voltha_ONUFlowChecks.robot
@@ -0,0 +1,235 @@
+# Copyright 2021 - 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.
+# FIXME Can we use the same test against BBSim and Hardware?
+
+*** Settings ***
+Documentation     Test of open ONU go adapter Flows
+Suite Setup       Setup Suite
+Test Setup        Setup
+Test Teardown     Teardown
+Suite Teardown    Teardown Suite
+Library           Collections
+Library           String
+Library           OperatingSystem
+Library           XML
+Library           RequestsLibrary
+Library           ../../libraries/DependencyLibrary.py
+Resource          ../../libraries/onos.robot
+Resource          ../../libraries/voltctl.robot
+Resource          ../../libraries/voltha.robot
+Resource          ../../libraries/utils.robot
+Resource          ../../libraries/k8s.robot
+Resource          ../../variables/variables.robot
+Resource          ../../libraries/power_switch.robot
+Resource          ../../libraries/onu_utilities.robot
+
+*** Variables ***
+${namespace}      voltha
+${timeout}        60s
+${of_id}          0
+${logical_id}     0
+${has_dataplane}    True
+${external_libs}    True
+${teardown_device}    True
+${scripts}        ../../scripts
+# Per-test logging on failure is turned off by default; set this variable to enable
+${container_log_dir}    ${None}
+# determines the environment workflow: DT, TT or ATT (default)
+# example: -v workflow:DT
+${workflow}    ATT
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:True
+${logging}    False
+# used tech profile, can be passed via the command line too, valid values: default (=1T1GEM), 1T4GEM, 1T8GEM
+# example: -v techprofile:1T4GEM
+${techprofile}    default
+# 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
+${data_dir}    ../data
+
+*** Test Cases ***
+Flows Test
+    [Documentation]    Validates onu vlan rules in etcd:
+    [Tags]    functionalOnuGo    FlowsTest
+    [Setup]    Start Logging    FlowsTest
+    ${onu_tags_dict}=    Collect Tags Per ONU
+    # Check and store vlan rules
+    Wait Until Keyword Succeeds    ${timeout}    2s    Run Keyword And Continue On Failure
+    ...    Validate Etcd Vlan Rules Added Subscriber    ${onu_tags_dict}    defaultkvstoreprefix=${kvstoreprefix}
+    #log flows for verification
+    ${flowsresult}=    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s
+    log     ${flowsresult}
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        # Remove subscriber
+        Do Onu Subscriber Remove Per OLT    ${of_id}    ${olt_serial_number}
+    END
+    #log flows for verification
+    ${flowsresult}=    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s
+    log     ${flowsresult}
+    Wait Until Keyword Succeeds    ${timeout}    2s    Run Keyword And Continue On Failure    Run Keyword And Continue On Failure
+    ...    Validate Etcd Vlan Rules Removed Subscriber   defaultkvstoreprefix=${kvstoreprefix}
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        Do Onu Subscriber Add Per OLT    ${of_id}    ${olt_serial_number}
+    END
+    #log flows for verification
+    ${flowsresult}=    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s
+    log     ${flowsresult}
+    Wait Until Keyword Succeeds    ${timeout}    2s    Run Keyword And Continue On Failure    Run Keyword And Continue On Failure
+    ...    Validate Etcd Vlan Rules Added Subscriber    ${onu_tags_dict}    defaultkvstoreprefix=${kvstoreprefix}
+    [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
+    ...           AND    Stop Logging    FlowsTest
+
+*** Keywords ***
+Setup Suite
+    [Documentation]    Set up the test suite inclusive enable device and sanity test of given workflow
+    Common Test Suite Setup
+    ${techprofile}=    Set Variable If    "${techprofile}"=="1T1GEM"    default    ${techprofile}
+    Set Suite Variable    ${techprofile}
+    Run Keyword If    "${techprofile}"=="default"   Log To Console    \nTechProfile:default (1T1GEM)
+    ...    ELSE IF    "${techprofile}"=="1T4GEM"    Set Tech Profile    1T4GEM
+    ...    ELSE IF    "${techprofile}"=="1T8GEM"    Set Tech Profile    1T8GEM
+    ...    ELSE    Fail    The TechProfile (${techprofile}) is not valid!
+    ${switch_type}=    Get Variable Value    ${web_power_switch.type}
+    Run Keyword If  "${switch_type}"!=""    Set Global Variable    ${powerswitch_type}    ${switch_type}
+    Setup
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
+    Run Keyword If    "${workflow}"=="DT"    Perform Sanity Test DT
+    ...    ELSE IF    "${workflow}"=="TT"    Perform Sanity Tests TT
+    ...    ELSE       Perform Sanity Test
+
+Teardown Suite
+    [Documentation]    Replaces the Suite Teardown in utils.robot.
+    ...    Cleans up and checks all ONU ports disabled in ONOS.
+    ...    Furthermore gives the possibility to pause the execution.
+    Run Keyword If    ${pausebeforecleanup}    Import Library    Dialogs
+    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
+    Wait Until Keyword Succeeds    ${timeout}    1s    Validate Onu Data In Etcd    0    ${kvstoreprefix}    without_pm_data=False
+    Wait for Ports in ONOS for all OLTs      ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}  0   BBSM    ${timeout}
+    Close All ONOS SSH Connections
+    Remove Tech Profile
+
+Validate Etcd Vlan Rules Added Subscriber
+    [Documentation]    This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
+    ...                It checks the match_vid (=4096) and set_vid when subscriber are added.
+    [Arguments]    ${onu_tags_dict}    ${reqmatchvid}=4096    ${defaultkvstoreprefix}=voltha_voltha
+    ${kvstoreprefix}=    Get Kv Store Prefix    ${defaultkvstoreprefix}
+    ${etcddata}=    Get ONU Go Adapter ETCD Data    ${kvstoreprefix}    True    True
+    #prepare result for json convert
+    ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
+    ${jsondata}=    To Json    ${result}
+    ${length}=    Get Length    ${jsondata}
+    log    ${jsondata}
+    FOR    ${INDEX}    IN RANGE    0    ${length}
+        ${value}=    Get From List    ${jsondata}    ${INDEX}
+        ${flowparams}=    Get From Dictionary    ${value['uni_config'][0]}    flow_params
+        ${onu}=    Get From Dictionary    ${value}    serial_number
+        Validate Flow Params Vlan Rules    ${flowparams}    ${onu_tags_dict}    ${onu}    ${reqmatchvid}
+    END
+
+Validate Flow Params Vlan Rules
+    [Documentation]    This keyword validates Vlan rules of openonu-go-adapter Data iterating over passed flow params.
+    ...                It checks the match_vid (=4096) and set_vid when subscriber are added.
+    [Arguments]    ${flowparams}    ${onu_tags_dict}    ${onu}    ${reqmatchvid}=4096
+    ${length}=    Get Length    ${flowparams}
+    ${nbofexpectedrules}=    Set Variable If
+    ...    "${workflow}"=="TT" and ${has_dataplane}        4
+    ...    "${workflow}"=="TT" and not ${has_dataplane}    3
+    ...    "${workflow}"=="DT" or "${workflow}"=="ATT"     1
+    Should Be Equal As Numbers    ${length}    ${nbofexpectedrules}
+    ...    msg=wrong number of vlan rules (${length} != ${nbofexpectedrules})!
+    FOR    ${INDEX}    IN RANGE    0    ${length}
+        ${value}=    Get From List    ${flowparams}    ${INDEX}
+        ${matchvid}=    Get From Dictionary    ${value['vlan_rule_params']}
+        ...    match_vid
+        Should Be Equal As Integers    ${matchvid}    ${reqmatchvid}
+        ${setvid}=    Get From Dictionary    ${value['vlan_rule_params']}
+        ...    set_vid
+        ${c_tags_list}=    Get From Dictionary    ${onu_tags_dict['${onu}']}    c_tags
+        ${tagindex}=    Get Index From List    ${c_tags_list}   ${setvid}
+        Should Not Be Equal As Integers    ${tagindex}    -1    msg=set_vid out of range (${setvid})!
+    END
+
+Validate Etcd Vlan Rules Removed Subscriber
+    [Documentation]    This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
+    ...                It checks the match_vid (=4096) and set_vid when subscriber are removed.
+    [Arguments]    ${reqmatchvid}=4096    ${defaultkvstoreprefix}=voltha_voltha
+    ${kvstoreprefix}=    Get Kv Store Prefix    ${defaultkvstoreprefix}
+    ${etcddata}=    Get ONU Go Adapter ETCD Data    ${kvstoreprefix}        True    True
+    #prepare result for json convert
+    ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
+    ${jsondata}=    To Json    ${result}
+    ${length}=    Get Length    ${jsondata}
+    log    ${jsondata}
+    ${vlan_rules}=    Create Dictionary
+    FOR    ${INDEX}    IN RANGE    0    ${length}
+        ${value}=    Get From List    ${jsondata}    ${INDEX}
+        @{result_values}=    Run Keyword And Ignore Error
+        ...    Get From Dictionary    ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}    match_vid
+        ${result}=       Set Variable    @{result_values}[0]
+        ${matchvid}=     Set Variable    @{result_values}[1]
+        Run Keyword If    "${workflow}"=="ATT"    Should Be Equal As Integers    ${matchvid}    ${reqmatchvid}
+        ...    ELSE       Should Be Equal As Strings    ${result}    FAIL
+        @{result_values}=    Run Keyword And Ignore Error
+        ...    Get From Dictionary    ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}   set_vid
+        ${result}=       Set Variable    @{result_values}[0]
+        ${setvid}=       Set Variable    @{result_values}[1]
+        ${evalresult}=    Run Keyword If    "${workflow}"=="ATT"    Evaluate    ${setvid} == 4091
+        ...               ELSE              Evaluate    "${result}" == "FAIL"
+        Should Be True    ${evalresult}    msg=set_vid out of range (${setvid})!
+    END
+
+Collect Tags Per ONU
+    [Documentation]    This keyword collects the s- and c-tags per ONU.
+    ${onu_tags_dict}=     Create Dictionary
+    FOR    ${I}    IN RANGE    0    ${num_all_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${onu_tags_dict}=    Run Keyword If  '${src['onu']}' in ${onu_tags_dict}   Update ONU Tags Dict    ${onu_tags_dict}
+        ...                                  ${src['onu']}    ${src['c_tag']}    ${src['s_tag']}
+        ...    ELSE    Append To ONU Tags Dict    ${onu_tags_dict}
+        ...                                  ${src['onu']}    ${src['c_tag']}    ${src['s_tag']}
+    END
+    log    ${onu_tags_dict}
+    [return]    ${onu_tags_dict}
+
+Update ONU Tags Dict
+    [Documentation]    This keyword update passed dictionary with the s- and c-tags for passed ONU.
+    [Arguments]    ${onu_tags_dict}    ${onu}    ${c_tag}    ${s_tag}
+    ${c_tag}=    Convert To Integer    ${c_tag}
+    ${s_tag}=    Convert To Integer    ${s_tag}
+    ${c_tags_list}=    Get From Dictionary    ${onu_tags_dict['${onu}']}    c_tags
+    Append To List    ${c_tags_list}    ${c_tag}
+    ${s_tags_list}=    Get From Dictionary    ${onu_tags_dict['${onu}']}    s_tags
+    Append To List    ${s_tags_list}    ${s_tag}
+    Set To Dictionary    ${onu_tags_dict['${onu}']}    c_tags    ${c_tags_list}    s_tags    ${s_tags_list}
+    [return]    ${onu_tags_dict}
+
+Append To ONU Tags Dict
+    [Documentation]    This keyword append the s- and c-tags of passed ONU to passed dictionary .
+    [Arguments]    ${onu_tags_dict}    ${onu}    ${c_tag}    ${s_tag}
+    ${c_tag}=    Convert To Integer    ${c_tag}
+    ${s_tag}=    Convert To Integer    ${s_tag}
+    ${c_tags_list}=    Create List    ${c_tag}
+    ${s_tags_list}=    Create List    ${s_tag}
+    ${onu_dict}=    Create Dictionary    c_tags    ${c_tags_list}    s_tags    ${s_tags_list}
+    Set To Dictionary    ${onu_tags_dict}    ${onu}    ${onu_dict}
+    [return]    ${onu_tags_dict}
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index 4f653de..53cffea 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -327,16 +327,12 @@
     ...    defaultkvstoreprefix=${kvstoreprefix}
     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}
-        # Verify Default Meter in ONOS (valid only for ATT)
-        Do Onu Subscriber Add Per OLT    ${of_id}    ${olt_serial_number}   ${onu_count}
+        Do Onu Subscriber Add Per OLT    ${of_id}    ${olt_serial_number}   ${print2console}
     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}
@@ -344,7 +340,7 @@
         ...    Get NNI Port in ONOS    ${of_id}
         Set Global Variable    ${nni_port}
         # Verify Default Meter in ONOS (valid only for ATT)
-        Do Onu 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}   ${print2console}
     END
     #log flows for verification
     ${flowsresult}=    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    flows -s
@@ -356,15 +352,9 @@
     ...    prevvlanrules=${firstvlanrules}    defaultkvstoreprefix=${kvstoreprefix}
     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 Remove Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}   ${onu_count}
+        Do Onu Subscriber Remove Per OLT    ${of_id}    ${olt_serial_number}   ${print2console}
     END
     #check  for previous state is kept (normally omci-flows-pushed)
     Sleep    10s
@@ -374,57 +364,6 @@
     Run Keyword And Continue On Failure    Validate Vlan Rules In Etcd    prevvlanrules=${firstvlanrules}
     ...                                    setvidequal=True    defaultkvstoreprefix=${kvstoreprefix}
 
-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}]}
-        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}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
-        ...    Execute ONOS CLI Command use single connection    ${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
-    [Documentation]    Removes per OLT subscribers 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}]}
-        ${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
-        ...    Get ONU Port in ONOS    ${src['onu']}    ${of_id}
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2
-        ...    Execute ONOS CLI Command use single connection    ${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
-
 Do Check Tech Profile
     [Documentation]    This keyword checks the loaded TechProfile
     ${namespace}=    Set Variable    default