[VOL-4991] Voltha System Test for TIM Mcast Service Model

Change-Id: I5a8ead125773542d8e7c37738b23a7f991c97b23
diff --git a/Makefile b/Makefile
index 01ff850..75f58a1 100644
--- a/Makefile
+++ b/Makefile
@@ -67,6 +67,8 @@
 ROBOT_SANITY_TIM_SINGLE_PON_MULTI_ONU_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-tim-OLTxPONx2ONU.yaml
 ROBOT_SANITY_TIM_MULTI_PON_MULTI_ONU_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-tim-OLTx2PONx2ONU.yaml
 ROBOT_SANITY_TIM_MULTI_OLT_MULTI_PON_MULTI_ONU_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-tim-2OLTx2PONx2ONU.yaml
+ROBOT_SANITY_TIM_MCAST_SINGLE_PON_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-tim-Mcast.yaml
+ROBOT_SANITY_TIM_MCAST_MULTI_OLT_MULTI_PON_MULTI_ONU_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-tim-Mcast-2OLTx2PONx2UNI-single_multi_Sub.yaml
 ROBOT_SANITY_BBF_ADPATER_SINGLE_PON_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-bbf-adapter.yaml
 ROBOT_SANITY_BBF_ADPATER_ADD_DELETE_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-bbf-adapter_addDelete_tests.yaml
 ROBOT_SANITY_DT_SINGLE_PON_MULTI_ONU_FILE    ?= $(ROOT_DIR)/tests/data/bbsim-kind-dt-1OLTx1PONx2ONU.yaml
@@ -191,6 +193,15 @@
 sanity-kind-tim-multi-olt-multi-pon-multi-onu: ROBOT_FILE := Voltha_TIM_PODTests.robot
 sanity-kind-tim-multi-olt-multi-pon-multi-onu: voltha-tim-test
 
+sanity-kind-tim-mcast: ROBOT_MISC_ARGS += -i sanityTIM-MCast $(ROBOT_DEBUG_LOG_OPT)
+sanity-kind-tim-mcast: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TIM_MCAST_SINGLE_PON_FILE)
+sanity-kind-tim-mcast: ROBOT_FILE := Voltha_TIM_PODTests.robot
+sanity-kind-tim-mcast: voltha-tim-test
+
+sanity-kind-tim-mcast-multi-olt-multi-pon-multi-onu: ROBOT_MISC_ARGS += -i sanityTIM-MCast $(ROBOT_DEBUG_LOG_OPT)
+sanity-kind-tim-mcast-multi-olt-multi-pon-multi-onu: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TIM_MCAST_MULTI_OLT_MULTI_PON_MULTI_ONU_FILE)
+sanity-kind-tim-mcast-multi-olt-multi-pon-multi-onu: ROBOT_FILE := Voltha_TIM_PODTests.robot
+sanity-kind-tim-mcast-multi-olt-multi-pon-multi-onu: voltha-tim-test
 
 # target to invoke multiple OLTs Functional scenarios
 functional-multi-olt: ROBOT_MISC_ARGS += -i sanityORfunctional -e PowerSwitch $(ROBOT_DEBUG_LOG_OPT)
diff --git a/VERSION b/VERSION
index e464374..ae93586 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.12.6
+2.12.7
diff --git a/libraries/flows.robot b/libraries/flows.robot
index acb4a63..b053506 100644
--- a/libraries/flows.robot
+++ b/libraries/flows.robot
@@ -135,11 +135,20 @@
     Return From Keyword     ${flow_count}
 
 Calculate Tim flows
-    [Documentation]  Calculate the flow for the Tim workflow
+    [Documentation]  Calculate the number of flow rules for the Tim workflow in a single OLT,
+    ...     at the variation of the number of ONis provisioned
+    ...     Case 1: ( 1 LLDP + 1 PPPoE + 1 IGMP) for each OLTs before provisioning
+    ...     Case 2: ( 2 Any VLAN) + ( UNIs * 8 ) + (1 LLDP + 1 PPPoE + 1 IGMP) for each OLTs after provisioning
     [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}  ${withPppoe}     ${withIgmp}    ${withLldp}
-    # (1 LLDP + 1 PPPoE + 1 IGMP) for each OLTs before provisioning
-    # 1 Any VLAN + (4 * UNIs) * (1 LLDP + 1 PPPoE + 1 IGMP) for each OLTs after provisioning
-    ${anyVlanFlowsCount}=   Evaluate    1
+
+    #Define the any Vlan Number Flows in a OLT after the subscription of almost one subscriber
+    #One Any Vlan roule for each service ( HSIA , VoD )
+    ${anyVlanFlowsCount}=   Evaluate    2
+
+    #Define the number of flows for single UNIs where there are a subscriber
+    # 4 Flow Rules for HSIA Service and 4 Flow Rules for VoD Service
+    ${uniUpDownFlowsCount}=   Evaluate    8
+
     ${pppoeFlowsCount}=   Run Keyword If   $withPppoe=='true'
     ...     Evaluate     1
     ...     ELSE
@@ -155,8 +164,9 @@
     ${pppoeFlowsCount}=   Evaluate   ${olt_count} * ${pppoeFlowsCount}
     ${totalLldpFlows}=   Evaluate   ${olt_count} * ${lldpFlowsCount}
     ${totalIgmpFlows}=   Evaluate   ${olt_count} * ${igmpFlowsCount}
+    ${totalPppoeLlldpIgmpFlows}=    Evaluate    ${pppoeFlowsCount} + ${totalLldpFlows} + ${totalIgmpFlows}
     ${flow_count}=  Run Keyword If  $provisioned=='false'
-    ...     Evaluate     ${pppoeFlowsCount} + ${totalLldpFlows} + ${totalIgmpFlows}
+    ...     Set Variable    ${totalPppoeLlldpIgmpFlows}
     ...     ELSE
-    ...     Evaluate    ${anyVlanFlowsCount} + (${uni_count} * 4) + ${pppoeFlowsCount} + ${totalLldpFlows} + ${totalIgmpFlows}
+    ...     Evaluate    ${anyVlanFlowsCount} + (${uniUpDownFlowsCount} * ${uni_count}) + ${totalPppoeLlldpIgmpFlows}
     Return From Keyword     ${flow_count}
\ No newline at end of file
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 69dc95e..4cf61b3 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -527,9 +527,10 @@
     ...    ${downstream_lldp_cmd}
     Should Not Be Empty    ${downstream_lldp}
 
-Verify Subscriber Access Flows Added for Single ONU Port TIM
+Verify Subscriber Access Flows Added For HSIA Service Single ONU Port TIM
     [Arguments]    ${ip}    ${port}    ${olt_of_id}    ${onu_port}    ${nni_port}    ${c_tag}   ${uni_tag}
-    [Documentation]    Verifies if the Subscriber Access Flows are added in ONOS for the ONU
+    [Documentation]    Verifies if the Subscriber Access Flows for the HSIA Service are
+    ...     added in ONOS in the manner way for the single consider ONU
 
     # Verify upstream pppoed flow from UNI port to CONTROLLER
     ${upstream_flow_pppoed_added_cmd}=   Catenate    SEPARATOR=
@@ -571,6 +572,72 @@
     ...    ${downstream_form_NNI_to_UNI_in_table_1_cmd}
     Should Not Be Empty    ${downstream_form_NNI_to_UNI_in_table_1}
 
+Verify Subscriber Access Flows Added For VoD Service On Single ONU Port TIM
+    [Arguments]    ${ip}    ${port}    ${olt_of_id}    ${onu_port}    ${nni_port}    ${c_tag}   ${uni_tag}
+    [Documentation]    Verifies if the Subscriber Access Flows for the VoD Service are
+    ...     added in ONOS in the manner way for the single consider ONU
+
+    # Verify upstream igmp flow from UNI port to CONTROLLER
+    ${upstream_flow_igmp_added_cmd}=   Catenate    SEPARATOR=
+    ...     flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
+    ...     grep IP_PROTO:2 |grep VLAN_VID:${uni_tag} | grep OUTPUT:CONTROLLER
+    ${upstream_flow_igmp_added}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${upstream_flow_igmp_added_cmd}
+    Should Not Be Empty    ${upstream_flow_igmp_added}
+
+    # Verify upstream table=0 flow, from UNI to TABLE 1
+    ${upstream_flow_0_added_cmd}=     Catenate    SEPARATOR=
+    ...     flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${uni_tag} |
+    ...     grep VLAN_ID:${c_tag}  | grep transition=TABLE:1
+    ${upstream_flow_0_added}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${upstream_flow_0_added_cmd}
+    Should Not Be Empty    ${upstream_flow_0_added}
+
+    # Verify upstream table=1 flow, from UNI to NNI
+    ${flow_vlan_UNI_to_NNI_cmd}=     Catenate    SEPARATOR=
+    ...    flows -s ADDED ${olt_of_id} | grep table=1 | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
+    ...    grep OUTPUT:${nni_port}
+    ${flow_vlan_UNI_to_NNI}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${flow_vlan_UNI_to_NNI_cmd}
+    Should Not Be Empty    ${flow_vlan_UNI_to_NNI}
+
+    # Verify downstream table=0 flow, from NNI to TABLE 1
+    ${downstream_flow_0_added_cmd}=     Catenate    SEPARATOR=
+    ...    flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:Any |
+    ...    grep transition=TABLE:1
+    ${downstream_flow_0_added}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${downstream_flow_0_added_cmd}
+    Should Not Be Empty    ${downstream_flow_0_added}
+
+    # Verify downstream table=1 flow, from NNI to UNI
+    ${downstream_from_NNI_to_UNI_in_table_1_cmd}=     Catenate    SEPARATOR=
+    ...    flows -s ADDED ${olt_of_id} | grep table=1 | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
+    ...    grep VLAN_ID:${uni_tag} | grep OUTPUT:${onu_port}
+    ${downstream_from_NNI_to_UNI_in_table_1}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${downstream_from_NNI_to_UNI_in_table_1_cmd}
+    Should Not Be Empty    ${downstream_from_NNI_to_UNI_in_table_1}
+
+Verify Mcast Flow Rule Subscription
+    [Arguments]    ${ip}    ${port}    ${olt_of_id}    ${mcastIP}
+    [Documentation]    Verfy the creation of the Flow rule trigger by an IGMPJoin
+    ${downstream_flow_mcast_added_cmd}=   Catenate    SEPARATOR=
+    ...     flows -s ADDED ${olt_of_id} | grep ETH_TYPE:ipv4 | grep IPV4_DST:${mcastIP}
+    ${downstram_flow_mcast_added}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${downstream_flow_mcast_added_cmd}
+    Should Not Be Empty    ${downstram_flow_mcast_added}
+    [Return]    ${downstram_flow_mcast_added}
+
+Verify Mcast Groups Rules generation
+    [Arguments]    ${ip}    ${port}    ${onu_port}      ${groupID}
+    [Documentation]    Verfy the creation of the Group rule trigger by an IGMPJoin
+    ${downstream_flow_mcast_added_cmd}=   Catenate    SEPARATOR=
+    ...     groups | grep id=${groupID} | grep OUTPUT:${onu_port}
+    #Ricorda ADDED sopra in production
+    #Prova poi a prenderti con il $5 o qualcosa così il gruppo
+    ${downstram_flow_mcast_added}=    Execute ONOS CLI Command use single connection    ${ip}    ${port}
+    ...    ${downstream_flow_mcast_added_cmd}
+    Should Not Be Empty    ${downstram_flow_mcast_added}
+
 Get Programmed Subscribers
     [Arguments]    ${ip}    ${port}    ${olt_of_id}    ${onu_port}    ${filter}=${EMPTY}
     [Documentation]    Retrieves the subscriber details at a given location
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 098896a..4d1d438 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -25,6 +25,7 @@
 Library           CORDRobot
 Library           ImportResource    resources=CORDRobot
 Resource          ./voltctl.robot
+Resource          ./bbsim.robot
 
 *** Keywords ***
 Check CLI Tools Configured
@@ -1727,41 +1728,36 @@
         ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
         ...    ${olt_serial_number}
         Set Global Variable    ${of_id}
-
         #Permorm test on flow rules that are writen inside ONOS, OLT and ONUs
         ${nni_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get NNI Port in ONOS    ${of_id}
         Perform Sanity Test TIM Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}
         ...    ${supress_add_subscriber}
-
         #Scalability Test
         #Extract the total iphotetical number of UNIs that an OLT controll having multiple ONUs connected
-        ${num_of_provisioned_onus_ports}=      Count Number of UNI ports for OLT
-        ...     ${olt_serial_number}    hsia
-
+        ${num_of_provisioned_onus_ports}=       Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Count Number of UNI ports for OLT       ${olt_serial_number}    hsia
+        ...     ELSE    Set Variable    0
         # Verify ONOS Flows
-        # Number of Access Flows for OLT on ONOS are equals to:
-        # a standard downstream flow for the Any VLAN, that flow exist when there are at least 1 onu,
-        # 4 rules for each single ONU/UNI
-        # and there are 3 default flows lldp, igmp and pppoe flow rules for the OLT
         ${onos_flows_count}=    Run Keyword    Calculate Tim flows
         ...     ${num_of_provisioned_onus_ports}    1   true  true     true    true
-
-        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Verify Subscriber Access Flows Added Count TIM    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
-        ...    ${onos_flows_count}
-
+        Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Wait Until Keyword Succeeds    ${timeout}    5s
+        ...     Verify Subscriber Access Flows Added Count TIM    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
+        ...     ${onos_flows_count}
         # Verify VOLTHA Flows
-        # Number of per OLT Flows are 3 times the Number of Active ONUs
-        # (for downstream and upstream) + 3 on the NNI port the LLDP, IGMP and PPPoE default flows
-        ${olt_flows}=    Evaluate   3 * ${num_of_provisioned_onus_ports} + 3
+        ${olt_flows}=       Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Evaluate   6 * ${num_of_provisioned_onus_ports} + 3
+        ...     ELSE    Set Variable    3
         Run Keyword    Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Flows
         ...    ${olt_flows}    ${olt_device_id}
         ${List_ONU_Serial}    Create List
         Set Suite Variable    ${List_ONU_Serial}
         Build ONU SN List    ${List_ONU_Serial}    ${olt_serial_number}
         Log    ${List_ONU_Serial}
-        # Number of per ONU Flows equals 3
-        ${onu_flows}=    Set Variable    3
+        # Number of per ONU Flows equals 6
+        ${onu_flows}=       Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Set Variable    6
+        ...     ELSE    Set Variable    0
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate ONU Flows
         ...    ${List_ONU_Serial}    ${onu_flows}
     END
@@ -1783,14 +1779,9 @@
     [Arguments]    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}    ${supress_add_subscriber}=False
     [Documentation]    This keyword performs Sanity Test Procedure for TIM Workflow
     ...    Sanity test performs pppoe and flows for all the ONUs (and for each UNIs of a consider ONU)
-    ...    This keyword can be used to call in any other tests where sanity check is required
-    ...    and avoids duplication of code.
-    ...    For repeating sanity test without subscriber changes set flag supress_add_subscriber=True.
-    ...    In all other (common) cases flag has to be set False (default).
     Wait Until Keyword Succeeds    ${timeout}    5s
         ...    Verify Downstream Flows for Single OLT NNI Port TIM    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
         ...    ${nni_port}
-
     FOR    ${I}    IN RANGE    0    ${num_all_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
@@ -1801,27 +1792,128 @@
         # Check ONU port is Enabled in ONOS
         Wait Until Keyword Succeeds   120s   2s
         ...    Verify UNI Port Is Enabled   ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${src['onu']}    ${src['uni_id']}
-
         # Subscribe a RG on a defualt UNI_id=1
         ${add_subscriber_access} =  Set Variable     volt-add-subscriber-access ${of_id} ${onu_port}
         Run Keyword If    '${supress_add_subscriber}' == 'False'
         ...     Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}   ${add_subscriber_access}
-
         # Verify ONU state in voltha
         ${onu_reasons}=  Create List     omci-flows-pushed
-        Run Keyword    Append To List    ${onu_reasons}    onu-reenabled
+        Run Keyword    Append To List    ${onu_reasons}    initial-mib-downloaded
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate Device
         ...    ENABLED    ACTIVE    REACHABLE
         ...    ${src['onu']}    onu=True    onu_reason=${onu_reasons}
-
-        # Verify subscriber access flows are added for a single ONU puniort
-        Wait Until Keyword Succeeds    ${timeout}    5s
-        ...    Verify Subscriber Access Flows Added For Single ONU Port TIM    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
+        # Verify subscriber access flows are added for a single ONU onuport for the HSIA service
+        Run Keyword If    '${supress_add_subscriber}' == 'False' and '${src['service_type']}' == 'hsia'
+        ...    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Verify Subscriber Access Flows Added For HSIA Service Single ONU Port TIM
+        ...    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
         ...    ${onu_port}    ${nni_port}    ${src['c_tag']}    ${src['uni_tag']}
-
+        # Verify subscriber access flows are added for a single ONU onuport for the VOD service
+        Run Keyword If    '${supress_add_subscriber}' == 'False' and '${src['service_type']}' == 'vod'
+        ...    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Verify Subscriber Access Flows Added For VoD Service On Single ONU Port TIM
+        ...    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
+        ...    ${onu_port}    ${nni_port}    ${src['c_tag']}    ${src['uni_tag']}
         # TO DO: Verify Meters in ONOS
-        #Wait Until Keyword Succeeds    ${timeout}    5s
-        #...    Verify Meters in ONOS Ietf    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}    ${onu_port}
+    END
+
+Perform Sanity Test TIM MCAST
+    [Documentation]    This keyword iterate all OLTs and performs Sanity Test Procedure for MCAST TIM workflow
+    ...    Use BBSIM to subscribe on a MCast Group and verify flows and groups rules
+    [Arguments]    ${supress_add_subscriber}=False    ${maclearning_enabled}=False
+    Perform Sanity Test TIM     ${supress_add_subscriber}
+    ...     ${maclearning_enabled}
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
+        ${num_onus}=    Set Variable    ${list_olts}[${J}][onucount]
+        ${olt_device_id}=    Get OLTDeviceID From OLT List    ${olt_serial_number}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        Set Global Variable    ${of_id}
+        #Permorm test on flow rules that are writen inside ONOS, OLT and ONUs
+        ${nni_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get NNI Port in ONOS    ${of_id}
+        ${mCastSubIps}=    Wait Until Keyword Succeeds    ${timeout}    2s
+        ...     Perform Sanity Test TIM MCAST Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}
+        ...    ${supress_add_subscriber}
+        ${number_of_mCastSubIps}    Get Length    ${mCastSubIps}
+        #Scalability Test
+        ${num_of_provisioned_onus_ports}=      Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Count Number of UNI ports for OLT       ${olt_serial_number}    vod
+        ...     ELSE    Set Variable    0
+        # Verify ONOS Flows
+        ${onos_flows_count}=    Run Keyword    Calculate Tim flows
+        ...     ${num_of_provisioned_onus_ports}    1   true  true     true    true
+        #Tot Number of Onos FLows with Mcast Downstream Flows
+        ${onos_flows_count}=    Evaluate    ${number_of_mCastSubIps} + ${onos_flows_count}
+        Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Wait Until Keyword Succeeds    ${timeout}    5s
+        ...     Verify Subscriber Access Flows Added Count TIM    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}    ${of_id}
+        ...    ${onos_flows_count}
+        # Verify VOLTHA Flows
+        ${olt_flows}=       Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Evaluate   6 * ${num_of_provisioned_onus_ports} + 3 + ${number_of_mCastSubIps}
+        ...     ELSE    Set Variable    4
+        Run Keyword    Wait Until Keyword Succeeds    ${timeout}    5s    Validate OLT Flows
+        ...    ${olt_flows}    ${olt_device_id}
+        ${List_ONU_Serial}    Create List
+        Set Suite Variable    ${List_ONU_Serial}
+        Build ONU SN List    ${List_ONU_Serial}    ${olt_serial_number}
+        Log    ${List_ONU_Serial}
+        # Number of per ONU Flows equals 6
+        ${onu_flows}=       Run Keyword If      '${supress_add_subscriber}' == 'False'
+        ...     Set Variable    6
+        ...     ELSE    Set Variable    0
+        Wait Until Keyword Succeeds    ${timeout}    5s    Validate ONU Flows
+        ...    ${List_ONU_Serial}    ${onu_flows}
+    END
+
+Perform Sanity Test TIM MCAST Per OLT
+    [Arguments]    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}    ${supress_add_subscriber}=False
+    [Documentation]    This keyword performs Sanity Test Procedure for TIM Workflow
+    ...    Sanity test performs pppoe and flows for all the ONUs (and for each UNIs of a consider ONU)
+    @{subTotalMcast}=      Create List
+    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']}"
+        Continue For Loop If    "${src['service_type']}"!="vod"
+        ${subMcast}=    Set Variable    ${src['subMcast']}
+        #Maintain all the MCast Group subscribed by all ONU/ONT
+        ${subTotalMcast}=    Combine Lists     ${subTotalMcast}     ${subMcast}
+        ${onu_device_id}=    Get Device ID From SN    ${src['onu']}
+        ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s
+        ...    Get ONU Port in ONOS    ${src['onu']}    ${of_id}    ${src['uni_id']}
+        Wait Until Keyword Succeeds    ${timeout}    2s
+        ...     Perform Sanity Test TIM MCAST Per ONU    ${NAMESPACE}
+        ...     ${olt_serial_number}    ${src['onu']}   ${src['uni_id']}    join    ${subMcast}
+        ...     ${onu_port}     ${of_id}    ${src['c_tag']}
+    END
+    ${subTotalMcast}=    Remove Duplicates    ${subTotalMcast}
+    [Return]    ${subTotalMcast}
+
+Perform Sanity Test TIM MCAST Per ONU
+    [Documentation]  Joins or Leaves Igmp on a BBSim ONU
+    [Arguments]    ${namespace}     ${olt_serial_number}    ${onu}  ${uni}    ${task}    ${group_address_list}
+    ...     ${onu_port}     ${olt_of_id}    ${vlan}
+    #Get the BBSIM, where there are the subscriber
+    ${bbsim_pod_name}=      Set Variable    bbsim
+    FOR    ${J}    IN RANGE    0    ${num_olts}
+        ${bbsim_pod_name}=      Set Variable If    "${olt_serial_number}" == "${list_olts}[${J}][sn]"
+        ...    ${list_olts}[${J}][ip]     ${bbsim_pod_name}
+    END
+    ${num_group_address_list}    Get Length    ${group_address_list}
+    FOR    ${I}    IN RANGE    0    ${num_group_address_list}
+        ${group_address}=   Set Variable    ${group_address_list[${I}]}
+        JoinOrLeave Igmp    ${NAMESPACE}  ${bbsim_pod_name}   ${onu}   0   ${task} ${group_address}   ${vlan}
+        ${downstram_flow_mcast_added}=    Wait Until Keyword Succeeds    ${timeout}    2s
+        ...     Verify Mcast Flow Rule Subscription     ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
+        ...     ${olt_of_id}    ${group_address}
+        ${groupID}=     Set Variable    ${EMPTY}
+        #Get the GroupID of the Downstream Flow from the Downstream Flow Rule
+        ${groupID}=     Get Substring   ${downstram_flow_mcast_added}   147     -2
+        #Verify if in Groups is add the correct groups rules with correct GroupID and UNI Port
+        Verify Mcast Groups Rules generation    ${ONOS_SSH_IP}      ${ONOS_SSH_PORT}
+        ...     ${onu_port}     ${groupID}
     END
 
 Perform Sanity Test of BBFadapter Aggregation
@@ -1833,11 +1925,8 @@
     #Extract from the XML of the Device Aggregation different tipe of data structure
     #One for only OLTs, one for only ONUs and one for Both
     Set Global Variable     ${XML}
-
     ALL DEVICES XML update From BBF     ${XML}  ${scripts}
-
     OLT XML update From BBF     ${XML}  ${scripts}
-
     #Do the verification for each OLT and its ONUs
     FOR    ${J}    IN RANGE    0    ${num_olts}
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
@@ -1858,13 +1947,11 @@
         #Verify if the OLT in BBF have all the features present in VOLTHA
         #Is like a Viceversa Check
         Correct representation check VOLTHA-IETF     ${olt_serial_number}    False
-
         #NNI_port is a place_holder for future tests on services
         #Do a Test for the OLT configuration and its ONUS
         ${nni_port}=    Set Variable    0
         Perform Sanity BBF Per OLT    ${of_id}    ${nni_port}    ${olt_serial_number}    ${num_onus}
         ...    ${supress_add_subscriber}
-
     END
 
 Perform Sanity BBF Per OLT
@@ -1892,9 +1979,7 @@
         #Run Keyword If  ${supress_add_subscriber}   Append To List    ${onu_reasons}    initial-mib-downloaded
         Log   ${onu_reasons}
         Log   ${supress_add_subscriber}
-
         ONU XML update From BBF     ${XML}  ${scripts}
-
         #Validate in VOLTHA if the ONU exist and have the correct states
         Wait Until Keyword Succeeds    ${timeout}    5s    Validate Device
         ...    ENABLED    ACTIVE    REACHABLE
diff --git a/tests/data/bbsim-kind-tim-2OLTx2PONx2ONU.yaml b/tests/data/bbsim-kind-tim-2OLTx2PONx2ONU.yaml
index ec02b87..af2eecd 100644
--- a/tests/data/bbsim-kind-tim-2OLTx2PONx2ONU.yaml
+++ b/tests/data/bbsim-kind-tim-2OLTx2PONx2ONU.yaml
@@ -32,9 +32,9 @@
     ip: '127.0.0.1'
 
 olts:
-  - ip: bbsim0.voltha.svc
+  - ip: bbsim0
     serial: BBSIM_OLT_10
-  - ip: bbsim1.voltha.svc
+  - ip: bbsim1
     serial: BBSIM_OLT_11
 
 hosts:
@@ -47,6 +47,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000a0002'
       olt: 'BBSIM_OLT_10'
       uni_tag: '835'
@@ -55,6 +65,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000a0002'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000a0101'
       olt: 'BBSIM_OLT_10'
       uni_tag: '835'
@@ -63,6 +83,17 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000a0101'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.25
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000a0102'
       olt: 'BBSIM_OLT_10'
       uni_tag: '835'
@@ -71,6 +102,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000a0102'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000b0001'
       olt: 'BBSIM_OLT_11'
       uni_tag: '835'
@@ -79,6 +120,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000b0001'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000b0002'
       olt: 'BBSIM_OLT_11'
       uni_tag: '835'
@@ -87,6 +138,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000b0002'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000b0101'
       olt: 'BBSIM_OLT_11'
       uni_tag: '835'
@@ -95,6 +156,17 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000b0101'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.25
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
     - onu: 'BBSM000b0102'
       olt: 'BBSIM_OLT_11'
       uni_tag: '835'
@@ -103,6 +175,16 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000b0102'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
 
   dst:
     - ip: null
@@ -113,3 +195,11 @@
     - ip: null
     - ip: null
     - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
diff --git a/tests/data/bbsim-kind-tim-Mcast-2OLTx2PONx2UNI-single_multi_Sub.yaml b/tests/data/bbsim-kind-tim-Mcast-2OLTx2PONx2UNI-single_multi_Sub.yaml
new file mode 100644
index 0000000..af2eecd
--- /dev/null
+++ b/tests/data/bbsim-kind-tim-Mcast-2OLTx2PONx2UNI-single_multi_Sub.yaml
@@ -0,0 +1,205 @@
+---
+
+# Copyright 2017-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.
+
+# Automated deployment configuration for systems running BBSim
+
+# Change default values in tests
+workflow: TIM
+has_dataplane: false
+teardown_device: true
+ONOS_REST_PORT: 8181
+ONOS_SSH_PORT: 8101
+OLT_PORT: 50060
+
+# Actual Unused sadis.file but ready to future implementation
+# sadis.file: ../data/tim-sadis-config.json
+
+nodes:
+  -
+    ip: '127.0.0.1'
+
+olts:
+  - ip: bbsim0
+    serial: BBSIM_OLT_10
+  - ip: bbsim1
+    serial: BBSIM_OLT_11
+
+hosts:
+  src:
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0002'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0002'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0101'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0101'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.25
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0102'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0102'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0001'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0001'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0002'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0002'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0101'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0101'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.25
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0102'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000b0102'
+      olt: 'BBSIM_OLT_11'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.24
+      uni_id: 1
+      tp_id: '64'
+
+  dst:
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
+    - ip: null
diff --git a/tests/data/bbsim-kind-tim-Mcast.yaml b/tests/data/bbsim-kind-tim-Mcast.yaml
new file mode 100644
index 0000000..35efe20
--- /dev/null
+++ b/tests/data/bbsim-kind-tim-Mcast.yaml
@@ -0,0 +1,61 @@
+---
+
+# Copyright 2017-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.
+
+# Automated deployment configuration for systems running BBSim
+
+# Change default values in tests
+workflow: TIM
+has_dataplane: false
+teardown_device: true
+ONOS_REST_PORT: 8181
+ONOS_SSH_PORT: 8101
+OLT_PORT: 50060
+
+# Actual Unused sadis.file but ready to future implementation
+# sadis.file: ../data/tim-sadis-config.json
+
+nodes:
+  -
+    ip: '127.0.0.1'
+
+olts:
+  - ip: bbsim0
+    serial: BBSIM_OLT_10
+
+hosts:
+  src:
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '835'
+      c_tag: '100'
+      s_tag: '4096'
+      service_type: 'hsia'
+      uni_id: 1
+      tp_id: '64'
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      subMcast:
+        - 224.0.0.22
+      uni_id: 1
+      tp_id: '64'
+
+  dst:
+    - ip: null
+    - ip: null
diff --git a/tests/data/bbsim-kind-tim-OLTx2PONx2ONU.yaml b/tests/data/bbsim-kind-tim-OLTx2PONx2ONU.yaml
index 483ad27..ff67227 100644
--- a/tests/data/bbsim-kind-tim-OLTx2PONx2ONU.yaml
+++ b/tests/data/bbsim-kind-tim-OLTx2PONx2ONU.yaml
@@ -32,7 +32,7 @@
     ip: '127.0.0.1'
 
 olts:
-  - ip: bbsim0.voltha.svc
+  - ip: bbsim0
     serial: BBSIM_OLT_10
 
 hosts:
diff --git a/tests/data/bbsim-kind-tim-OLTxPONx2ONU.yaml b/tests/data/bbsim-kind-tim-OLTxPONx2ONU.yaml
index 8a71814..b65a6f7 100644
--- a/tests/data/bbsim-kind-tim-OLTxPONx2ONU.yaml
+++ b/tests/data/bbsim-kind-tim-OLTxPONx2ONU.yaml
@@ -32,7 +32,7 @@
     ip: '127.0.0.1'
 
 olts:
-  - ip: bbsim0.voltha.svc
+  - ip: bbsim0
     serial: BBSIM_OLT_10
 
 hosts:
diff --git a/tests/data/bbsim-kind-tim.yaml b/tests/data/bbsim-kind-tim.yaml
index 79e9769..f2aef1d 100644
--- a/tests/data/bbsim-kind-tim.yaml
+++ b/tests/data/bbsim-kind-tim.yaml
@@ -32,7 +32,7 @@
     ip: '127.0.0.1'
 
 olts:
-  - ip: bbsim0.voltha.svc
+  - ip: bbsim0
     serial: BBSIM_OLT_10
 
 hosts:
@@ -45,6 +45,15 @@
       service_type: 'hsia'
       uni_id: 1
       tp_id: '64'
+    - onu: 'BBSM000a0001'
+      olt: 'BBSIM_OLT_10'
+      uni_tag: '836'
+      c_tag: '101'
+      s_tag: '4096'
+      service_type: 'vod'
+      uni_id: 1
+      tp_id: '64'
 
   dst:
     - ip: null
+    - ip: null
diff --git a/tests/tim-workflow/Voltha_TIM_PODTests.robot b/tests/tim-workflow/Voltha_TIM_PODTests.robot
index ebd2ed5..dd69b3b 100755
--- a/tests/tim-workflow/Voltha_TIM_PODTests.robot
+++ b/tests/tim-workflow/Voltha_TIM_PODTests.robot
@@ -97,15 +97,15 @@
     [Documentation]    Validate the correct construction of the flow rules in ONOS and in the devices:
     ...    Flow rules in accordance with TIM Workflow.
     ...    Verify the correctness of the flow/group rules generated by ONOS and written in
-    ...    the respective devices (OLT and ONU), about IGMP.
+    ...    the respective devices (OLT and ONU) by MCast ONOS App.
     ...    We use a Transparent VLAN approach.
     ...    Perform a scalability test both for flow rules in ONOS and in devices.
-    [Tags]    sanityTIM-MCast    notready
+    [Tags]    sanityTIM-MCast
     [Setup]    Start Logging    sanityTIM-MCast
     [Teardown]    Run Keywords    Run Keyword If    ${logging}    Collect Logs
     ...           AND             Stop Logging    sanityTIM-MCast
+    Run Keyword     Setup    ${SOAK_TEST}
     Run Keyword If    ${has_dataplane}    Clean Up Linux
-    TODO: Yet to Implement below keyword
     Perform Sanity Test TIM MCAST     supress_add_subscriber=${suppressaddsubscriber}
     ...     maclearning_enabled=${maclearningenabled}