Skip to content

Commit 143422b

Browse files
authored
add support to execute new ycable API's, add datetime field to mux_info (sonic-net#297)
This PR does two main things It adds the capability for SONiC CLI to call few API's like operationtime, healthcheck, queue_info, reset cause for it to be displayed via CLI It adds a datetime field inside MUX_CABLE_INFO helpful for tracking last update, and it removes some of the toggle synchronization logic for SONiC telemetry, since SONiC telemetry table MUX_CABLE_INFO is anyways disabled/enabled using CLI config muxcable telemetry enable/disable, it is redundant to have this logic embedded in ycabled and port_instance helper objects, which could be unneccessary Description Motivation and Context How Has This Been Tested? Putting the changes on Arista testbed and UT
1 parent 6522c46 commit 143422b

File tree

3 files changed

+199
-47
lines changed

3 files changed

+199
-47
lines changed

sonic-ycabled/tests/test_y_cable_helper.py

+141
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def test_y_cable_wrapper_get_presence_with_platform_chassis_raise_exception(self
161161
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True))
162162
@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
163163
@patch('ycable.ycable_utilities.y_cable_helper.get_muxcable_info', MagicMock(return_value={'tor_active': 'self',
164+
'time_post': '2022-Sep-23 00:09:16.968812',
164165
'mux_direction': 'self',
165166
'manual_switch_count': '7',
166167
'auto_switch_count': '71',
@@ -3478,6 +3479,146 @@ def test_handle_get_fec_cmd_arg_tbl_notification_get_alive_status(self, port_ins
34783479
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
34793480
assert(rc == None)
34803481

3482+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
3483+
@patch('swsscommon.swsscommon.Table')
3484+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')
3485+
@patch('ycable.ycable_utilities.y_cable_helper.gather_arg_from_db_and_check_for_type', MagicMock(return_value=(0, "health_check", {"modex": "0",
3486+
"lane_mask": "0",
3487+
"direction": "0"})))
3488+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_physical_port_from_logical_port', MagicMock(return_value=(0)))
3489+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_locks', MagicMock(return_value=[0]))
3490+
def test_handle_get_fec_cmd_arg_tbl_notification_get_cable_health(self, port_instance, mock_swsscommon_table, port_instance_helper):
3491+
3492+
mock_table = MagicMock()
3493+
mock_swsscommon_table.return_value = mock_table
3494+
3495+
xcvrd_show_ber_cmd_arg_tbl = mock_swsscommon_table
3496+
xcvrd_show_ber_rsp_tbl = mock_swsscommon_table
3497+
xcvrd_show_ber_cmd_sts_tbl = mock_swsscommon_table
3498+
xcvrd_show_ber_res_tbl = mock_swsscommon_table
3499+
port_instance = MagicMock()
3500+
port_instance.health_check.return_value = True
3501+
3502+
asic_index = 0
3503+
port = "Ethernet0"
3504+
fvp = {"get_ber": True}
3505+
3506+
rc = handle_show_ber_cmd_arg_tbl_notification(
3507+
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
3508+
assert(rc == None)
3509+
3510+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
3511+
@patch('swsscommon.swsscommon.Table')
3512+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')
3513+
@patch('ycable.ycable_utilities.y_cable_helper.gather_arg_from_db_and_check_for_type', MagicMock(return_value=(0, "health_check", {"modex": "0",
3514+
"lane_mask": "0",
3515+
"direction": "0"})))
3516+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_physical_port_from_logical_port', MagicMock(return_value=(0)))
3517+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_locks', MagicMock(return_value=[0]))
3518+
def test_handle_get_fec_cmd_arg_tbl_notification_get_cable_health(self, port_instance, mock_swsscommon_table, port_instance_helper):
3519+
3520+
mock_table = MagicMock()
3521+
mock_swsscommon_table.return_value = mock_table
3522+
3523+
xcvrd_show_ber_cmd_arg_tbl = mock_swsscommon_table
3524+
xcvrd_show_ber_rsp_tbl = mock_swsscommon_table
3525+
xcvrd_show_ber_cmd_sts_tbl = mock_swsscommon_table
3526+
xcvrd_show_ber_res_tbl = mock_swsscommon_table
3527+
port_instance = MagicMock()
3528+
port_instance.health_check.return_value = True
3529+
3530+
asic_index = 0
3531+
port = "Ethernet0"
3532+
fvp = {"get_ber": True}
3533+
3534+
rc = handle_show_ber_cmd_arg_tbl_notification(
3535+
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
3536+
assert(rc == None)
3537+
3538+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
3539+
@patch('swsscommon.swsscommon.Table')
3540+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')
3541+
@patch('ycable.ycable_utilities.y_cable_helper.gather_arg_from_db_and_check_for_type', MagicMock(return_value=(0, "reset_cause", {"modex": "0",
3542+
"lane_mask": "0",
3543+
"direction": "0"})))
3544+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_physical_port_from_logical_port', MagicMock(return_value=(0)))
3545+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_locks', MagicMock(return_value=[0]))
3546+
def test_handle_get_fec_cmd_arg_tbl_notification_get_reset_cause(self, port_instance, mock_swsscommon_table, port_instance_helper):
3547+
3548+
mock_table = MagicMock()
3549+
mock_swsscommon_table.return_value = mock_table
3550+
3551+
xcvrd_show_ber_cmd_arg_tbl = mock_swsscommon_table
3552+
xcvrd_show_ber_rsp_tbl = mock_swsscommon_table
3553+
xcvrd_show_ber_cmd_sts_tbl = mock_swsscommon_table
3554+
xcvrd_show_ber_res_tbl = mock_swsscommon_table
3555+
port_instance = MagicMock()
3556+
port_instance.health_check.return_value = 0
3557+
3558+
asic_index = 0
3559+
port = "Ethernet0"
3560+
fvp = {"get_ber": True}
3561+
3562+
rc = handle_show_ber_cmd_arg_tbl_notification(
3563+
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
3564+
assert(rc == None)
3565+
3566+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
3567+
@patch('swsscommon.swsscommon.Table')
3568+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')
3569+
@patch('ycable.ycable_utilities.y_cable_helper.gather_arg_from_db_and_check_for_type', MagicMock(return_value=(0, "operation_time", {"modex": "0",
3570+
"lane_mask": "0",
3571+
"direction": "0"})))
3572+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_physical_port_from_logical_port', MagicMock(return_value=(0)))
3573+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_locks', MagicMock(return_value=[0]))
3574+
def test_handle_get_fec_cmd_arg_tbl_notification_get_reset_cause(self, port_instance, mock_swsscommon_table, port_instance_helper):
3575+
3576+
mock_table = MagicMock()
3577+
mock_swsscommon_table.return_value = mock_table
3578+
3579+
xcvrd_show_ber_cmd_arg_tbl = mock_swsscommon_table
3580+
xcvrd_show_ber_rsp_tbl = mock_swsscommon_table
3581+
xcvrd_show_ber_cmd_sts_tbl = mock_swsscommon_table
3582+
xcvrd_show_ber_res_tbl = mock_swsscommon_table
3583+
port_instance = MagicMock()
3584+
port_instance.oporation_time.return_value = 0
3585+
3586+
asic_index = 0
3587+
port = "Ethernet0"
3588+
fvp = {"get_ber": True}
3589+
3590+
rc = handle_show_ber_cmd_arg_tbl_notification(
3591+
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
3592+
assert(rc == None)
3593+
3594+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
3595+
@patch('swsscommon.swsscommon.Table')
3596+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')
3597+
@patch('ycable.ycable_utilities.y_cable_helper.gather_arg_from_db_and_check_for_type', MagicMock(return_value=(0, "queue_info", {"modex": "0",
3598+
"lane_mask": "0",
3599+
"direction": "0"})))
3600+
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_physical_port_from_logical_port', MagicMock(return_value=(0)))
3601+
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_locks', MagicMock(return_value=[0]))
3602+
def test_handle_get_fec_cmd_arg_tbl_notification_get_queue_info(self, port_instance, mock_swsscommon_table, port_instance_helper):
3603+
3604+
mock_table = MagicMock()
3605+
mock_swsscommon_table.return_value = mock_table
3606+
3607+
xcvrd_show_ber_cmd_arg_tbl = mock_swsscommon_table
3608+
xcvrd_show_ber_rsp_tbl = mock_swsscommon_table
3609+
xcvrd_show_ber_cmd_sts_tbl = mock_swsscommon_table
3610+
xcvrd_show_ber_res_tbl = mock_swsscommon_table
3611+
port_instance = MagicMock()
3612+
port_instance.queue_info.return_value = 0
3613+
3614+
asic_index = 0
3615+
port = "Ethernet0"
3616+
fvp = {"get_ber": True}
3617+
3618+
rc = handle_show_ber_cmd_arg_tbl_notification(
3619+
fvp, xcvrd_show_ber_cmd_arg_tbl, xcvrd_show_ber_rsp_tbl, xcvrd_show_ber_cmd_sts_tbl, xcvrd_show_ber_res_tbl, asic_index, port)
3620+
assert(rc == None)
3621+
34813622
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances')
34823623
@patch('swsscommon.swsscommon.Table')
34833624
@patch('ycable.ycable_utilities.y_cable_helper.get_ycable_port_instance_from_logical_port')

sonic-ycabled/tests/test_ycable.py

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def test_put_all_values_from_dict_to_db(self):
128128
@patch('ycable.ycable_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True))
129129
@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
130130
@patch('ycable.ycable_utilities.y_cable_helper.get_muxcable_info', MagicMock(return_value={'tor_active': 'self',
131+
'time_post': '2022-Sep-23 00:09:16.968812',
131132
'mux_direction': 'self',
132133
'manual_switch_count': '7',
133134
'auto_switch_count': '71',

0 commit comments

Comments
 (0)