-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix VDM freeze and unfreeze needed for PM stats collection (#402)
* In order to collect PM stats without loss of data following vdm freeze and unfreeze request needs to be followed. VDM freeze PM stats collection VDM unfreeze * Signed-off-by: Jaganathan Anbalagan <[email protected]> Addressing PR comments. Removed VDM statistics freeze/unfreeze performed inside standard APIs. It should be performed by xcvrd explicitly. * test code correction * code coverage
- Loading branch information
1 parent
cb80f17
commit 2efe97e
Showing
7 changed files
with
222 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from mock import MagicMock | ||
from mock import patch | ||
import pytest | ||
from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase | ||
from sonic_platform_base.sonic_xcvr.api.public.c_cmis import CCmisApi | ||
from sonic_platform_base.sonic_xcvr.api.public.cmis import CmisApi | ||
from sonic_platform_base.sonic_xcvr.mem_maps.public.c_cmis import CCmisMemMap | ||
from sonic_platform_base.sonic_xcvr.xcvr_eeprom import XcvrEeprom | ||
from sonic_platform_base.sonic_xcvr.codes.public.cmis import CmisCodes | ||
|
||
class TestSfpOptoeBase(object): | ||
|
||
codes = CmisCodes | ||
mem_map = CCmisMemMap(codes) | ||
reader = MagicMock(return_value=None) | ||
writer = MagicMock() | ||
eeprom = XcvrEeprom(reader, writer, mem_map) | ||
sfp_optoe_api = SfpOptoeBase() | ||
ccmis_api = CCmisApi(eeprom) | ||
cmis_api = CmisApi(eeprom) | ||
|
||
@pytest.mark.parametrize("mock_response1, mock_response2, expected", [ | ||
(0, ccmis_api, 0), | ||
(1, ccmis_api, 1), | ||
(None, None, False), | ||
(None, cmis_api, False), | ||
]) | ||
def test_freeze_vdm_stats(self, mock_response1, mock_response2, expected): | ||
self.sfp_optoe_api.get_xcvr_api = MagicMock() | ||
self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 | ||
self.ccmis_api.freeze_vdm_stats = MagicMock() | ||
self.ccmis_api.freeze_vdm_stats.return_value = mock_response1 | ||
|
||
result = self.sfp_optoe_api.freeze_vdm_stats() | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize("mock_response1, mock_response2, expected", [ | ||
(0, ccmis_api, 0), | ||
(1, ccmis_api, 1), | ||
(None, None, False), | ||
(None, cmis_api, False), | ||
]) | ||
def test_unfreeze_vdm_stats(self, mock_response1, mock_response2, expected): | ||
self.sfp_optoe_api.get_xcvr_api = MagicMock() | ||
self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 | ||
self.ccmis_api.unfreeze_vdm_stats = MagicMock() | ||
self.ccmis_api.unfreeze_vdm_stats.return_value = mock_response1 | ||
|
||
result = self.sfp_optoe_api.unfreeze_vdm_stats() | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize("mock_response1, mock_response2, expected", [ | ||
(0, ccmis_api, 0), | ||
(1, ccmis_api, 1), | ||
(None, None, False), | ||
(None, cmis_api, False), | ||
]) | ||
def test_get_vdm_freeze_status(self, mock_response1, mock_response2, expected): | ||
self.sfp_optoe_api.get_xcvr_api = MagicMock() | ||
self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 | ||
self.ccmis_api.get_vdm_freeze_status = MagicMock() | ||
self.ccmis_api.get_vdm_freeze_status.return_value = mock_response1 | ||
|
||
result = self.sfp_optoe_api.get_vdm_freeze_status() | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize("mock_response1, mock_response2, expected", [ | ||
(0, ccmis_api, 0), | ||
(1, ccmis_api, 1), | ||
(None, None, False), | ||
(None, cmis_api, False), | ||
]) | ||
def test_get_vdm_unfreeze_status(self, mock_response1, mock_response2, expected): | ||
self.sfp_optoe_api.get_xcvr_api = MagicMock() | ||
self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 | ||
self.ccmis_api.get_vdm_unfreeze_status = MagicMock() | ||
self.ccmis_api.get_vdm_unfreeze_status.return_value = mock_response1 | ||
|
||
result = self.sfp_optoe_api.get_vdm_unfreeze_status() | ||
assert result == expected | ||
|