@@ -2002,6 +2002,32 @@ def test_CmisManagerTask_post_port_active_apsel_to_db(self):
2002
2002
'host_lane_count' : '2' ,
2003
2003
'media_lane_count' : '1' }
2004
2004
2005
+ # case: partial lanes update (reset to 'N/A')
2006
+ lport = "Ethernet16"
2007
+ host_lanes_mask = 0xc
2008
+ ret = task .post_port_active_apsel_to_db (mock_xcvr_api , lport , host_lanes_mask , reset_apsel = True )
2009
+ assert int_tbl .getKeys () == ["Ethernet0" , "Ethernet8" , "Ethernet16" ]
2010
+ assert dict (int_tbl .mock_dict ["Ethernet16" ]) == {'active_apsel_hostlane3' : 'N/A' ,
2011
+ 'active_apsel_hostlane4' : 'N/A' ,
2012
+ 'host_lane_count' : 'N/A' ,
2013
+ 'media_lane_count' : 'N/A' }
2014
+
2015
+ # case: full lanes update (reset to 'N/A')
2016
+ lport = "Ethernet32"
2017
+ host_lanes_mask = 0xff
2018
+ task .post_port_active_apsel_to_db (mock_xcvr_api , lport , host_lanes_mask , reset_apsel = True )
2019
+ assert int_tbl .getKeys () == ["Ethernet0" , "Ethernet8" , "Ethernet16" , "Ethernet32" ]
2020
+ assert dict (int_tbl .mock_dict ["Ethernet32" ]) == {'active_apsel_hostlane1' : 'N/A' ,
2021
+ 'active_apsel_hostlane2' : 'N/A' ,
2022
+ 'active_apsel_hostlane3' : 'N/A' ,
2023
+ 'active_apsel_hostlane4' : 'N/A' ,
2024
+ 'active_apsel_hostlane5' : 'N/A' ,
2025
+ 'active_apsel_hostlane6' : 'N/A' ,
2026
+ 'active_apsel_hostlane7' : 'N/A' ,
2027
+ 'active_apsel_hostlane8' : 'N/A' ,
2028
+ 'host_lane_count' : 'N/A' ,
2029
+ 'media_lane_count' : 'N/A' }
2030
+
2005
2031
# case: NotImplementedError
2006
2032
int_tbl = Table ("STATE_DB" , TRANSCEIVER_INFO_TABLE ) # a new empty table
2007
2033
lport = "Ethernet0"
@@ -2413,10 +2439,13 @@ def test_CmisManagerTask_task_worker_fastboot(self, mock_chassis, mock_get_statu
2413
2439
task .get_configured_laser_freq_from_db = MagicMock (return_value = 193100 )
2414
2440
task .configure_tx_output_power = MagicMock (return_value = 1 )
2415
2441
task .configure_laser_frequency = MagicMock (return_value = 1 )
2442
+ task .post_port_active_apsel_to_db = MagicMock ()
2416
2443
2417
2444
task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
2418
2445
task .task_worker ()
2419
2446
2447
+ assert mock_xcvr_api .tx_disable_channel .call_count == 1
2448
+ assert task .post_port_active_apsel_to_db .call_count == 1
2420
2449
assert get_cmis_state_from_state_db ('Ethernet0' , task .xcvr_table_helper .get_status_tbl (task .port_mapping .get_asic_id_for_logical_port ('Ethernet0' ))) == CMIS_STATE_READY
2421
2450
2422
2451
@patch ('xcvrd.xcvrd.XcvrTableHelper.get_status_tbl' )
@@ -2548,10 +2577,12 @@ def test_CmisManagerTask_task_worker_host_tx_ready_false(self, mock_chassis, moc
2548
2577
task .get_configured_laser_freq_from_db = MagicMock (return_value = 193100 )
2549
2578
task .configure_tx_output_power = MagicMock (return_value = 1 )
2550
2579
task .configure_laser_frequency = MagicMock (return_value = 1 )
2580
+ task .post_port_active_apsel_to_db = MagicMock ()
2551
2581
2552
2582
task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
2553
2583
task .task_worker ()
2554
2584
2585
+ assert task .post_port_active_apsel_to_db .call_count == 1
2555
2586
assert mock_xcvr_api .tx_disable_channel .call_count == 1
2556
2587
assert get_cmis_state_from_state_db ('Ethernet0' , task .xcvr_table_helper .get_status_tbl (task .port_mapping .get_asic_id_for_logical_port ('Ethernet0' ))) == CMIS_STATE_READY
2557
2588
0 commit comments