Add load balance group flood test

Change-Id: Ibde8753e22c3dba7e926689df1aafe733d8b16c2
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 78d183e..eb62241 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -309,7 +309,7 @@
     ctrl.message_send(request)
     return request
 
-def add_l2_flood_group_with_gids(ctrl, gids, vlanid, id):
+def add_l2_flood_group_with_gids(ctrl, gids, vlanid, id, send_barrier=False):
     buckets=[]
     for gid in gids:
         action=[ofp.action.group(gid)]
@@ -321,6 +321,10 @@
                                     buckets=buckets
                                    )
     ctrl.message_send(request)
+
+    if send_barrier:
+        do_barrier(ctrl)
+
     return request
 
 def mod_l2_flood_group(ctrl, ports, vlanid, id):
diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index 004edd9..9f2cd23 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -3538,6 +3538,65 @@
             delete_all_groups( self.controller )
 
 @disabled
+class FloodLb( base_tests.SimpleDataPlane ):
+    """
+    Checks L2 flood group pointing to L2 load balance group with 2 buckets (unfiltered).
+    The packet from in_port should not be seen on the out_port
+    """
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
+        try:
+            if len( config[ "port_map" ] ) < 2:
+                logging.info( "Port count less than 2, can't run this case" )
+                return
+
+            ports = sorted(config[ "port_map" ].keys( ))
+            in_port = ports[0]
+            out_port = ports[1]
+            vlan_in_port_untagged = 31
+
+            # add l2 unfiltered interface group for outport
+            l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True)
+            l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
+
+            # create l2 load-balance group
+            lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_i_gid, l2_o_gid], True)
+
+            # create l2 flood group with mix of l2i and l2-loadbal
+            floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0, send_barrier=True )
+            Groups.put( l2_i_gid )
+            Groups.put( l2_o_gid )
+            Groups.put( lag_gid )
+            Groups.put( floodmsg.group_id )
+
+            # table 10 flows for untagged input
+            add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
+                                     send_barrier=True)
+            add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
+                                     send_barrier=True)
+
+            # add bridging flows for flooding groups
+            add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
+            # unknown dstmac packet will hit flood group
+            un_mac_dst_str = '00:11:22:ff:ff:ff'
+
+            # check one direction -> packet enters through inport should not be seen on the outport
+            pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
+            self.dataplane.send( in_port, pkt )
+            verify_no_other_packets( self )
+
+            # check other direction -> packet enters through outport should not be seen on the inport
+            pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
+            self.dataplane.send( out_port, pkt )
+            verify_no_other_packets( self )
+
+        finally:
+            #print("done")
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
+
+@disabled
 class FloodMix( base_tests.SimpleDataPlane ):
     """
     Checks the combination of L2 filtered and L2 load balancing (LAG) groups