@@ -764,6 +764,89 @@ def get_host_lane_assignment_option_side_effect(app):
764764 appl = task .get_cmis_application_desired (mock_xcvr_api , host_lane_count , speed )
765765 assert task .get_cmis_host_lanes_mask (mock_xcvr_api , appl , host_lane_count , subport ) == expected
766766
767+ def test_CmisManagerTask_post_port_active_apsel_to_db (self ):
768+ mock_xcvr_api = MagicMock ()
769+ mock_xcvr_api .get_active_apsel_hostlane = MagicMock (side_effect = [
770+ {
771+ 'ActiveAppSelLane1' : 1 ,
772+ 'ActiveAppSelLane2' : 1 ,
773+ 'ActiveAppSelLane3' : 1 ,
774+ 'ActiveAppSelLane4' : 1 ,
775+ 'ActiveAppSelLane5' : 1 ,
776+ 'ActiveAppSelLane6' : 1 ,
777+ 'ActiveAppSelLane7' : 1 ,
778+ 'ActiveAppSelLane8' : 1
779+ },
780+ {
781+ 'ActiveAppSelLane1' : 2 ,
782+ 'ActiveAppSelLane2' : 2 ,
783+ 'ActiveAppSelLane3' : 2 ,
784+ 'ActiveAppSelLane4' : 2 ,
785+ 'ActiveAppSelLane5' : 2 ,
786+ 'ActiveAppSelLane6' : 2 ,
787+ 'ActiveAppSelLane7' : 2 ,
788+ 'ActiveAppSelLane8' : 2
789+ },
790+ NotImplementedError
791+ ])
792+ mock_xcvr_api .get_application_advertisement = MagicMock (side_effect = [
793+ {
794+ 1 : {
795+ 'media_lane_count' : 4 ,
796+ 'host_lane_count' : 8
797+ }
798+ },
799+ {
800+ 2 : {
801+ 'media_lane_count' : 1 ,
802+ 'host_lane_count' : 2
803+ }
804+ }
805+ ])
806+
807+ int_tbl = Table ("STATE_DB" , TRANSCEIVER_INFO_TABLE )
808+
809+ port_mapping = PortMapping ()
810+ stop_event = threading .Event ()
811+ task = CmisManagerTask (DEFAULT_NAMESPACE , port_mapping , stop_event )
812+ task .xcvr_table_helper .get_intf_tbl = MagicMock (return_value = int_tbl )
813+
814+ # case: partial lanes update
815+ lport = "Ethernet0"
816+ host_lanes_mask = 0xc
817+ ret = task .post_port_active_apsel_to_db (mock_xcvr_api , lport , host_lanes_mask )
818+ assert int_tbl .getKeys () == ["Ethernet0" ]
819+ assert dict (int_tbl .mock_dict ["Ethernet0" ]) == {'active_apsel_hostlane3' : '1' ,
820+ 'active_apsel_hostlane4' : '1' ,
821+ 'host_lane_count' : '8' ,
822+ 'media_lane_count' : '4' }
823+ # case: full lanes update
824+ lport = "Ethernet8"
825+ host_lanes_mask = 0xff
826+ task .post_port_active_apsel_to_db (mock_xcvr_api , lport , host_lanes_mask )
827+ assert int_tbl .getKeys () == ["Ethernet0" , "Ethernet8" ]
828+ assert dict (int_tbl .mock_dict ["Ethernet0" ]) == {'active_apsel_hostlane3' : '1' ,
829+ 'active_apsel_hostlane4' : '1' ,
830+ 'host_lane_count' : '8' ,
831+ 'media_lane_count' : '4' }
832+ assert dict (int_tbl .mock_dict ["Ethernet8" ]) == {'active_apsel_hostlane1' : '2' ,
833+ 'active_apsel_hostlane2' : '2' ,
834+ 'active_apsel_hostlane3' : '2' ,
835+ 'active_apsel_hostlane4' : '2' ,
836+ 'active_apsel_hostlane5' : '2' ,
837+ 'active_apsel_hostlane6' : '2' ,
838+ 'active_apsel_hostlane7' : '2' ,
839+ 'active_apsel_hostlane8' : '2' ,
840+ 'host_lane_count' : '2' ,
841+ 'media_lane_count' : '1' }
842+
843+ # case: NotImplementedError
844+ int_tbl = Table ("STATE_DB" , TRANSCEIVER_INFO_TABLE ) # a new empty table
845+ lport = "Ethernet0"
846+ host_lanes_mask = 0xf
847+ ret = task .post_port_active_apsel_to_db (mock_xcvr_api , lport , host_lanes_mask )
848+ assert int_tbl .getKeys () == []
849+
767850 @patch ('xcvrd.xcvrd.platform_chassis' )
768851 @patch ('xcvrd.xcvrd_utilities.port_mapping.subscribe_port_update_event' , MagicMock (return_value = (None , None )))
769852 @patch ('xcvrd.xcvrd_utilities.port_mapping.handle_port_update_event' , MagicMock ())
0 commit comments