@@ -160,6 +160,7 @@ def test_CmisManagerTask_task_run_with_exception(self):
160
160
@patch ('xcvrd.xcvrd_utilities.port_mapping.subscribe_port_update_event' , MagicMock (return_value = (None , None )))
161
161
@patch ('xcvrd.xcvrd_utilities.port_mapping.handle_port_update_event' , MagicMock ())
162
162
@patch ('xcvrd.xcvrd.CmisManagerTask.wait_for_port_config_done' , MagicMock ())
163
+ @patch ('xcvrd.xcvrd.is_fast_reboot_enabled' , MagicMock (return_value = (False )))
163
164
@patch ('xcvrd.xcvrd.get_cmis_application_desired' , MagicMock (side_effect = KeyError ))
164
165
@patch ('xcvrd.xcvrd.log_exception_traceback' )
165
166
@patch ('xcvrd.xcvrd.XcvrTableHelper.get_status_tbl' )
@@ -1437,6 +1438,277 @@ def test_CmisManagerTask_task_worker(self, mock_chassis, mock_get_status_tbl):
1437
1438
assert task .post_port_active_apsel_to_db .call_count == 1
1438
1439
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
1439
1440
1441
+ @patch ('xcvrd.xcvrd.XcvrTableHelper.get_status_tbl' )
1442
+ @patch ('xcvrd.xcvrd.platform_chassis' )
1443
+ @patch ('xcvrd.xcvrd.is_fast_reboot_enabled' , MagicMock (return_value = (True )))
1444
+ @patch ('xcvrd.xcvrd_utilities.port_mapping.subscribe_port_update_event' , MagicMock (return_value = (None , None )))
1445
+ @patch ('xcvrd.xcvrd_utilities.port_mapping.handle_port_update_event' , MagicMock ())
1446
+ @patch ('xcvrd.xcvrd._wrapper_get_sfp_type' , MagicMock (return_value = 'QSFP_DD' ))
1447
+ @patch ('xcvrd.xcvrd.CmisManagerTask.wait_for_port_config_done' , MagicMock ())
1448
+ @patch ('xcvrd.xcvrd.is_cmis_api' , MagicMock (return_value = True ))
1449
+ def test_CmisManagerTask_task_worker_fastboot (self , mock_chassis , mock_get_status_tbl ):
1450
+ mock_get_status_tbl = Table ("STATE_DB" , TRANSCEIVER_STATUS_TABLE )
1451
+ mock_xcvr_api = MagicMock ()
1452
+ mock_xcvr_api .set_datapath_deinit = MagicMock (return_value = True )
1453
+ mock_xcvr_api .set_datapath_init = MagicMock (return_value = True )
1454
+ mock_xcvr_api .tx_disable_channel = MagicMock (return_value = True )
1455
+ mock_xcvr_api .set_lpmode = MagicMock (return_value = True )
1456
+ mock_xcvr_api .set_application = MagicMock (return_value = True )
1457
+ mock_xcvr_api .is_flat_memory = MagicMock (return_value = False )
1458
+ mock_xcvr_api .is_coherent_module = MagicMock (return_value = True )
1459
+ mock_xcvr_api .get_tx_config_power = MagicMock (return_value = 0 )
1460
+ mock_xcvr_api .get_laser_config_freq = MagicMock (return_value = 0 )
1461
+ mock_xcvr_api .get_module_type_abbreviation = MagicMock (return_value = 'QSFP-DD' )
1462
+ mock_xcvr_api .get_datapath_init_duration = MagicMock (return_value = 60000.0 )
1463
+ mock_xcvr_api .get_module_pwr_up_duration = MagicMock (return_value = 70000.0 )
1464
+ mock_xcvr_api .get_datapath_deinit_duration = MagicMock (return_value = 600000.0 )
1465
+ mock_xcvr_api .get_cmis_rev = MagicMock (return_value = '5.0' )
1466
+ mock_xcvr_api .get_dpinit_pending = MagicMock (return_value = {
1467
+ 'DPInitPending1' : True ,
1468
+ 'DPInitPending2' : True ,
1469
+ 'DPInitPending3' : True ,
1470
+ 'DPInitPending4' : True ,
1471
+ 'DPInitPending5' : True ,
1472
+ 'DPInitPending6' : True ,
1473
+ 'DPInitPending7' : True ,
1474
+ 'DPInitPending8' : True
1475
+ })
1476
+ mock_xcvr_api .get_application_advertisement = MagicMock (return_value = {
1477
+ 1 : {
1478
+ 'host_electrical_interface_id' : '400GAUI-8 C2M (Annex 120E)' ,
1479
+ 'module_media_interface_id' : '400GBASE-DR4 (Cl 124)' ,
1480
+ 'media_lane_count' : 4 ,
1481
+ 'host_lane_count' : 8 ,
1482
+ 'host_lane_assignment_options' : 1 ,
1483
+ 'media_lane_assignment_options' : 1
1484
+ },
1485
+ 2 : {
1486
+ 'host_electrical_interface_id' : '100GAUI-2 C2M (Annex 135G)' ,
1487
+ 'module_media_interface_id' : '100G-FR/100GBASE-FR1 (Cl 140)' ,
1488
+ 'media_lane_count' : 1 ,
1489
+ 'host_lane_count' : 2 ,
1490
+ 'host_lane_assignment_options' : 85 ,
1491
+ 'media_lane_assignment_options' : 15
1492
+ }
1493
+ })
1494
+ mock_xcvr_api .get_module_state = MagicMock (return_value = 'ModuleReady' )
1495
+ mock_xcvr_api .get_config_datapath_hostlane_status = MagicMock (return_value = {
1496
+ 'ConfigStatusLane1' : 'ConfigSuccess' ,
1497
+ 'ConfigStatusLane2' : 'ConfigSuccess' ,
1498
+ 'ConfigStatusLane3' : 'ConfigSuccess' ,
1499
+ 'ConfigStatusLane4' : 'ConfigSuccess' ,
1500
+ 'ConfigStatusLane5' : 'ConfigSuccess' ,
1501
+ 'ConfigStatusLane6' : 'ConfigSuccess' ,
1502
+ 'ConfigStatusLane7' : 'ConfigSuccess' ,
1503
+ 'ConfigStatusLane8' : 'ConfigSuccess'
1504
+ })
1505
+ mock_xcvr_api .get_datapath_state = MagicMock (side_effect = [
1506
+ {
1507
+ 'DP1State' : 'DataPathDeactivated' ,
1508
+ 'DP2State' : 'DataPathDeactivated' ,
1509
+ 'DP3State' : 'DataPathDeactivated' ,
1510
+ 'DP4State' : 'DataPathDeactivated' ,
1511
+ 'DP5State' : 'DataPathDeactivated' ,
1512
+ 'DP6State' : 'DataPathDeactivated' ,
1513
+ 'DP7State' : 'DataPathDeactivated' ,
1514
+ 'DP8State' : 'DataPathDeactivated'
1515
+ },
1516
+ {
1517
+ 'DP1State' : 'DataPathInitialized' ,
1518
+ 'DP2State' : 'DataPathInitialized' ,
1519
+ 'DP3State' : 'DataPathInitialized' ,
1520
+ 'DP4State' : 'DataPathInitialized' ,
1521
+ 'DP5State' : 'DataPathInitialized' ,
1522
+ 'DP6State' : 'DataPathInitialized' ,
1523
+ 'DP7State' : 'DataPathInitialized' ,
1524
+ 'DP8State' : 'DataPathInitialized'
1525
+ },
1526
+ {
1527
+ 'DP1State' : 'DataPathActivated' ,
1528
+ 'DP2State' : 'DataPathActivated' ,
1529
+ 'DP3State' : 'DataPathActivated' ,
1530
+ 'DP4State' : 'DataPathActivated' ,
1531
+ 'DP5State' : 'DataPathActivated' ,
1532
+ 'DP6State' : 'DataPathActivated' ,
1533
+ 'DP7State' : 'DataPathActivated' ,
1534
+ 'DP8State' : 'DataPathActivated'
1535
+ }
1536
+ ])
1537
+ mock_sfp = MagicMock ()
1538
+ mock_sfp .get_presence = MagicMock (return_value = True )
1539
+ mock_sfp .get_xcvr_api = MagicMock (return_value = mock_xcvr_api )
1540
+
1541
+ mock_chassis .get_all_sfps = MagicMock (return_value = [mock_sfp ])
1542
+ mock_chassis .get_sfp = MagicMock (return_value = mock_sfp )
1543
+
1544
+ port_mapping = PortMapping ()
1545
+ stop_event = threading .Event ()
1546
+ task = CmisManagerTask (DEFAULT_NAMESPACE , port_mapping , stop_event )
1547
+ task .port_mapping .logical_port_list = ['Ethernet0' ]
1548
+ task .xcvr_table_helper .get_status_tbl .return_value = mock_get_status_tbl
1549
+ task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
1550
+ task .task_worker ()
1551
+ 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_UNKNOWN
1552
+
1553
+ task .port_mapping .logical_port_list = MagicMock ()
1554
+ port_change_event = PortChangeEvent ('PortConfigDone' , - 1 , 0 , PortChangeEvent .PORT_SET )
1555
+ task .on_port_update_event (port_change_event )
1556
+ assert task .isPortConfigDone
1557
+
1558
+ port_change_event = PortChangeEvent ('Ethernet0' , 1 , 0 , PortChangeEvent .PORT_SET ,
1559
+ {'speed' :'400000' , 'lanes' :'1,2,3,4,5,6,7,8' })
1560
+ task .on_port_update_event (port_change_event )
1561
+ assert len (task .port_dict ) == 1
1562
+ 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_INSERTED
1563
+
1564
+ task .get_host_tx_status = MagicMock (return_value = 'false' )
1565
+ task .get_port_admin_status = MagicMock (return_value = 'up' )
1566
+ task .get_configured_tx_power_from_db = MagicMock (return_value = - 13 )
1567
+ task .get_configured_laser_freq_from_db = MagicMock (return_value = 193100 )
1568
+ task .configure_tx_output_power = MagicMock (return_value = 1 )
1569
+ task .configure_laser_frequency = MagicMock (return_value = 1 )
1570
+
1571
+ task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
1572
+ task .task_worker ()
1573
+
1574
+ 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
1575
+
1576
+ @patch ('xcvrd.xcvrd.XcvrTableHelper.get_status_tbl' )
1577
+ @patch ('xcvrd.xcvrd.platform_chassis' )
1578
+ @patch ('xcvrd.xcvrd.is_fast_reboot_enabled' , MagicMock (return_value = (False )))
1579
+ @patch ('xcvrd.xcvrd_utilities.port_mapping.subscribe_port_update_event' , MagicMock (return_value = (None , None )))
1580
+ @patch ('xcvrd.xcvrd_utilities.port_mapping.handle_port_update_event' , MagicMock ())
1581
+ @patch ('xcvrd.xcvrd._wrapper_get_sfp_type' , MagicMock (return_value = 'QSFP_DD' ))
1582
+ @patch ('xcvrd.xcvrd.CmisManagerTask.wait_for_port_config_done' , MagicMock ())
1583
+ @patch ('xcvrd.xcvrd.is_cmis_api' , MagicMock (return_value = True ))
1584
+ def test_CmisManagerTask_task_worker_host_tx_ready_false (self , mock_chassis , mock_get_status_tbl ):
1585
+ mock_get_status_tbl = Table ("STATE_DB" , TRANSCEIVER_STATUS_TABLE )
1586
+ mock_xcvr_api = MagicMock ()
1587
+ mock_xcvr_api .set_datapath_deinit = MagicMock (return_value = True )
1588
+ mock_xcvr_api .set_datapath_init = MagicMock (return_value = True )
1589
+ mock_xcvr_api .tx_disable_channel = MagicMock (return_value = True )
1590
+ mock_xcvr_api .set_lpmode = MagicMock (return_value = True )
1591
+ mock_xcvr_api .set_application = MagicMock (return_value = True )
1592
+ mock_xcvr_api .is_flat_memory = MagicMock (return_value = False )
1593
+ mock_xcvr_api .is_coherent_module = MagicMock (return_value = True )
1594
+ mock_xcvr_api .get_tx_config_power = MagicMock (return_value = 0 )
1595
+ mock_xcvr_api .get_laser_config_freq = MagicMock (return_value = 0 )
1596
+ mock_xcvr_api .get_module_type_abbreviation = MagicMock (return_value = 'QSFP-DD' )
1597
+ mock_xcvr_api .get_datapath_init_duration = MagicMock (return_value = 60000.0 )
1598
+ mock_xcvr_api .get_module_pwr_up_duration = MagicMock (return_value = 70000.0 )
1599
+ mock_xcvr_api .get_datapath_deinit_duration = MagicMock (return_value = 600000.0 )
1600
+ mock_xcvr_api .get_cmis_rev = MagicMock (return_value = '5.0' )
1601
+ mock_xcvr_api .get_dpinit_pending = MagicMock (return_value = {
1602
+ 'DPInitPending1' : True ,
1603
+ 'DPInitPending2' : True ,
1604
+ 'DPInitPending3' : True ,
1605
+ 'DPInitPending4' : True ,
1606
+ 'DPInitPending5' : True ,
1607
+ 'DPInitPending6' : True ,
1608
+ 'DPInitPending7' : True ,
1609
+ 'DPInitPending8' : True
1610
+ })
1611
+ mock_xcvr_api .get_application_advertisement = MagicMock (return_value = {
1612
+ 1 : {
1613
+ 'host_electrical_interface_id' : '400GAUI-8 C2M (Annex 120E)' ,
1614
+ 'module_media_interface_id' : '400GBASE-DR4 (Cl 124)' ,
1615
+ 'media_lane_count' : 4 ,
1616
+ 'host_lane_count' : 8 ,
1617
+ 'host_lane_assignment_options' : 1 ,
1618
+ 'media_lane_assignment_options' : 1
1619
+ },
1620
+ 2 : {
1621
+ 'host_electrical_interface_id' : '100GAUI-2 C2M (Annex 135G)' ,
1622
+ 'module_media_interface_id' : '100G-FR/100GBASE-FR1 (Cl 140)' ,
1623
+ 'media_lane_count' : 1 ,
1624
+ 'host_lane_count' : 2 ,
1625
+ 'host_lane_assignment_options' : 85 ,
1626
+ 'media_lane_assignment_options' : 15
1627
+ }
1628
+ })
1629
+ mock_xcvr_api .get_module_state = MagicMock (return_value = 'ModuleReady' )
1630
+ mock_xcvr_api .get_config_datapath_hostlane_status = MagicMock (return_value = {
1631
+ 'ConfigStatusLane1' : 'ConfigSuccess' ,
1632
+ 'ConfigStatusLane2' : 'ConfigSuccess' ,
1633
+ 'ConfigStatusLane3' : 'ConfigSuccess' ,
1634
+ 'ConfigStatusLane4' : 'ConfigSuccess' ,
1635
+ 'ConfigStatusLane5' : 'ConfigSuccess' ,
1636
+ 'ConfigStatusLane6' : 'ConfigSuccess' ,
1637
+ 'ConfigStatusLane7' : 'ConfigSuccess' ,
1638
+ 'ConfigStatusLane8' : 'ConfigSuccess'
1639
+ })
1640
+ mock_xcvr_api .get_datapath_state = MagicMock (side_effect = [
1641
+ {
1642
+ 'DP1State' : 'DataPathDeactivated' ,
1643
+ 'DP2State' : 'DataPathDeactivated' ,
1644
+ 'DP3State' : 'DataPathDeactivated' ,
1645
+ 'DP4State' : 'DataPathDeactivated' ,
1646
+ 'DP5State' : 'DataPathDeactivated' ,
1647
+ 'DP6State' : 'DataPathDeactivated' ,
1648
+ 'DP7State' : 'DataPathDeactivated' ,
1649
+ 'DP8State' : 'DataPathDeactivated'
1650
+ },
1651
+ {
1652
+ 'DP1State' : 'DataPathInitialized' ,
1653
+ 'DP2State' : 'DataPathInitialized' ,
1654
+ 'DP3State' : 'DataPathInitialized' ,
1655
+ 'DP4State' : 'DataPathInitialized' ,
1656
+ 'DP5State' : 'DataPathInitialized' ,
1657
+ 'DP6State' : 'DataPathInitialized' ,
1658
+ 'DP7State' : 'DataPathInitialized' ,
1659
+ 'DP8State' : 'DataPathInitialized'
1660
+ },
1661
+ {
1662
+ 'DP1State' : 'DataPathActivated' ,
1663
+ 'DP2State' : 'DataPathActivated' ,
1664
+ 'DP3State' : 'DataPathActivated' ,
1665
+ 'DP4State' : 'DataPathActivated' ,
1666
+ 'DP5State' : 'DataPathActivated' ,
1667
+ 'DP6State' : 'DataPathActivated' ,
1668
+ 'DP7State' : 'DataPathActivated' ,
1669
+ 'DP8State' : 'DataPathActivated'
1670
+ }
1671
+ ])
1672
+ mock_sfp = MagicMock ()
1673
+ mock_sfp .get_presence = MagicMock (return_value = True )
1674
+ mock_sfp .get_xcvr_api = MagicMock (return_value = mock_xcvr_api )
1675
+
1676
+ mock_chassis .get_all_sfps = MagicMock (return_value = [mock_sfp ])
1677
+ mock_chassis .get_sfp = MagicMock (return_value = mock_sfp )
1678
+
1679
+ port_mapping = PortMapping ()
1680
+ stop_event = threading .Event ()
1681
+ task = CmisManagerTask (DEFAULT_NAMESPACE , port_mapping , stop_event )
1682
+ task .port_mapping .logical_port_list = ['Ethernet0' ]
1683
+ task .xcvr_table_helper .get_status_tbl .return_value = mock_get_status_tbl
1684
+ task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
1685
+ task .task_worker ()
1686
+ 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_UNKNOWN
1687
+
1688
+ task .port_mapping .logical_port_list = MagicMock ()
1689
+ port_change_event = PortChangeEvent ('PortConfigDone' , - 1 , 0 , PortChangeEvent .PORT_SET )
1690
+ task .on_port_update_event (port_change_event )
1691
+ assert task .isPortConfigDone
1692
+
1693
+ port_change_event = PortChangeEvent ('Ethernet0' , 1 , 0 , PortChangeEvent .PORT_SET ,
1694
+ {'speed' :'400000' , 'lanes' :'1,2,3,4,5,6,7,8' })
1695
+ task .on_port_update_event (port_change_event )
1696
+ assert len (task .port_dict ) == 1
1697
+ 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_INSERTED
1698
+
1699
+ task .get_host_tx_status = MagicMock (return_value = 'false' )
1700
+ task .get_port_admin_status = MagicMock (return_value = 'up' )
1701
+ task .get_configured_tx_power_from_db = MagicMock (return_value = - 13 )
1702
+ task .get_configured_laser_freq_from_db = MagicMock (return_value = 193100 )
1703
+ task .configure_tx_output_power = MagicMock (return_value = 1 )
1704
+ task .configure_laser_frequency = MagicMock (return_value = 1 )
1705
+
1706
+ task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
1707
+ task .task_worker ()
1708
+
1709
+ assert mock_xcvr_api .tx_disable_channel .call_count == 1
1710
+ 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
1711
+
1440
1712
@pytest .mark .parametrize ("lport, expected_dom_polling" , [
1441
1713
('Ethernet0' , 'disabled' ),
1442
1714
('Ethernet4' , 'disabled' ),
0 commit comments