
Currently overall sync-state (/sync/sync-status/sync-state) represents degraded (HOLDOVER/FREERUN) when any state is degraded: os-clock-sync- state, ptp-status/lock-state, gnss-status/gnss-sync-status. This commit changes overall sync-state to represent whether the os-clock is synced or not to the timing source. Overall sync-state should only be degraded if the timing sources involved in providing the end-to-end timing is degraded or lost (i.e. it should represent the overall timing chain status). ptp4l instances that perform timing distribution only and are not part of the host timing chain must not impact the overall sync-state. os-clock-state should only represent the status of the OS clock sync state to the primary clock source in an HA configuration. Unit tests has been added and unit test's python interpreter has been changed to python3.9 to inline with base-image's python version (3.9.2). TEST PLAN: PASS: T-GM deployment with two ptp4l instances trigger different events (stop/start ptp4l/phc2sys/ts2phc instances, change clockClass, skew clocks, disable GNSS) overall sync-state is not affected by ptp-inst1 and ptp-inst2 states. PASS: T-BC deployment with two ptp4l instances trigger different events (stop/start ptp4l/phc2sys instances, change clockClass, skew clocks) overall sync-state is not affected by secondary ptp instance state. PASS: Hybrid (T-GM/T-BC) HA deployement: HA with GNSS and PTP source trigger different events overall sync-state is result of chained relation to chosen primary source Story: 2011370 Task: 51774 Change-Id: Ibfb7fa0f9f8ad09584a5f28b60b0e4649976932c Signed-off-by: Tara Nath Subedi <tara.subedi@windriver.com>
46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
#
|
|
# Copyright (c) 2025 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
import mock
|
|
import os
|
|
import unittest
|
|
|
|
from trackingfunctionsdk.common.helpers.gnss_monitor import GnssMonitor
|
|
|
|
testpath = os.environ.get("TESTPATH", "")
|
|
|
|
|
|
class GnssMonitorTests(unittest.TestCase):
|
|
|
|
def test_check_config_file_interfaces(self):
|
|
cgu_path = testpath + "test_input_files/mock_cgu_output_logan_beach"
|
|
gnss_config = testpath + "test_input_files/ts2phc_valid.conf"
|
|
self.gnssmon = GnssMonitor(gnss_config, cgu_path = cgu_path)
|
|
self.assertEqual(self.gnssmon._check_config_file_interfaces(), ['ens1f0', 'ens2f0'])
|
|
|
|
def test_set_ptp_devices(self):
|
|
cgu_path = testpath + "test_input_files/mock_cgu_output_logan_beach"
|
|
gnss_config = testpath + "test_input_files/ts2phc_valid.conf"
|
|
with mock.patch('trackingfunctionsdk.common.helpers.ptpsync.glob',
|
|
return_value=[]):
|
|
self.gnssmon = GnssMonitor(gnss_config, cgu_path = cgu_path)
|
|
self.assertEqual(self.gnssmon.get_ptp_devices(),[])
|
|
|
|
with mock.patch('trackingfunctionsdk.common.helpers.ptpsync.glob',
|
|
side_effect=[['/hostsys/class/net/ens1f0/device/ptp/ptp0'],
|
|
['/hostsys/class/net/ens2f0/device/ptp/ptp1']
|
|
]):
|
|
self.gnssmon.set_ptp_devices()
|
|
|
|
self.assertEqual(set(self.gnssmon.get_ptp_devices()),set(['ptp0','ptp1']))
|
|
|
|
with mock.patch('trackingfunctionsdk.common.helpers.ptpsync.glob',
|
|
side_effect=[['/hostsys/class/net/ens1f0/device/ptp/ptp0'],
|
|
['/hostsys/class/net/ens2f0/device/ptp/ptp0']
|
|
]):
|
|
self.gnssmon.set_ptp_devices()
|
|
|
|
self.assertEqual(self.gnssmon.get_ptp_devices(),['ptp0'])
|