Skip to content

Commit

Permalink
add failure missing test samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunyez committed Oct 27, 2023
1 parent c64b213 commit af2e2ba
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vse_sync_pp/analyzers/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ def _timestamp_from_dec(self, dec):
# relative time
return dec

@staticmethod
def _check_missing_samples(data, result, reason):
if reason is None:
if len(data.timestamp.diff().astype(float).round(0).tail(-1).unique()) > 1:
return (False, "missing test samples")
return result, reason

@property
def result(self):
"""The boolean result from this analyzer's test of the collected data"""
Expand Down Expand Up @@ -379,6 +386,8 @@ def _test_common(self, data):
return (False, "short test duration")
if len(data) - 1 < self._duration_min:
return (False, "short test samples")
if len(data.timestamp.diff().astype(float).round(0).tail(-1).unique()) > 1:
return (False, "missing test samples")
return None

def _explain_common(self, data):
Expand Down
9 changes: 9 additions & 0 deletions src/vse_sync_pp/analyzers/phc2sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ class TimeErrorAnalyzer(TimeErrorAnalyzerBase):
parser = id_
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))


class TimeDeviationAnalyzer(TimeDeviationAnalyzerBase):
"""Analyze time deviation"""
id_ = 'phc2sys/time-deviation'
parser = 'phc2sys/time-error'
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))


class MaxTimeIntervalErrorAnalyzer(MaxTimeIntervalErrorAnalyzerBase):
"""Analyze max time interval error"""
id_ = 'phc2sys/mtie'
parser = 'phc2sys/time-error'
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))
9 changes: 9 additions & 0 deletions src/vse_sync_pp/analyzers/ts2phc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@ class TimeErrorAnalyzer(TimeErrorAnalyzerBase):
parser = id_
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))


class TimeDeviationAnalyzer(TimeDeviationAnalyzerBase):
"""Analyze time deviation"""
id_ = 'ts2phc/time-deviation'
parser = 'ts2phc/time-error'
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))


class MaxTimeIntervalErrorAnalyzer(MaxTimeIntervalErrorAnalyzerBase):
"""Analyze max time interval error"""
id_ = 'ts2phc/mtie'
parser = 'ts2phc/time-error'
locked = frozenset({'s2'})

def test(self, data):
return self._check_missing_samples(data, *super().test(data))
32 changes: 32 additions & 0 deletions tests/vse_sync_pp/analyzers/test_phc2sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder):
},
},
},
{
'requirements': 'workload/RAN',
'parameters': {
'time-error-limit/%': 100,
'transient-period/s': 1,
'min-test-duration/s': 4,
},
'rows': (
TERR(Decimal(0), 0, 's2', 620),
TERR(Decimal(1), 0, 's2', 620),
TERR(Decimal(2), 0, 's2', 620),
TERR(Decimal(3), 0, 's2', 620),
# oops, missing sample
TERR(Decimal(5), 0, 's2', 620),
TERR(Decimal(6), 0, 's2', 620),
),
'result': False,
'reason': "missing test samples",
'timestamp': Decimal(1),
'duration': Decimal(5),
'analysis': {
'terror': {
'units': 'ns',
'min': 0,
'max': 0,
'range': 0,
'mean': 0,
'stddev': 0,
'variance': 0,
},
},
},
{
'requirements': 'workload/RAN',
'parameters': {
Expand Down
32 changes: 32 additions & 0 deletions tests/vse_sync_pp/analyzers/test_ts2phc.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder):
},
},
},
{
'requirements': 'G.8272/PRTC-A',
'parameters': {
'time-error-limit/%': 100,
'transient-period/s': 1,
'min-test-duration/s': 4,
},
'rows': (
TERR(Decimal(0), 0, 's2'),
TERR(Decimal(1), 0, 's2'),
TERR(Decimal(2), 0, 's2'),
TERR(Decimal(3), 0, 's2'),
# oops, missing sample
TERR(Decimal(5), 0, 's2'),
TERR(Decimal(6), 0, 's2'),
),
'result': False,
'reason': "missing test samples",
'timestamp': Decimal(1),
'duration': Decimal(5),
'analysis': {
'terror': {
'units': 'ns',
'min': 0,
'max': 0,
'range': 0,
'mean': 0,
'stddev': 0,
'variance': 0,
},
},
},
{
'requirements': 'G.8272/PRTC-A',
'parameters': {
Expand Down

0 comments on commit af2e2ba

Please sign in to comment.