Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tests/gold_tests/logging/log-milestone-fields.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MilestoneFieldsTest:
cache result code. A validation script then parses the log and checks:

- Every expected key=value pair is present on each line
- All values are integers (>= 0 or -1 for unset milestones)
- All values are integers, with "-" for unset milestones
- Cache miss line: ms > 0, origin-phase fields present
- Cache hit line: hit_proc >= 0 and hit_xfer >= 0
- No epoch-length garbage values (> 1_000_000_000)
Expand Down Expand Up @@ -155,9 +155,12 @@ def _sendCacheHit(self):
tr.StillRunningAfter = self._ts

def _waitForLog(self):
tr = Test.AddTestRun('Wait for log file to be written')
tr.Processes.Default.Command = (os.path.join(Test.Variables.AtsTestToolsDir, 'condwait') + f' 60 1 -f {self._log_path}')
tr.Processes.Default.ReturnCode = 0
tr = Test.AddAwaitFileContainsTestRun(
'Wait for milestone log lines to be written',
self._log_path,
r'^crc=.* hit_xfer=',
desired_count=2,
)
tr.StillRunningAfter = self._server
tr.StillRunningAfter = self._ts

Expand Down
12 changes: 7 additions & 5 deletions tests/gold_tests/logging/verify_milestone_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
MISS_CHAIN = ['c_hdr', 'c_proc', 'cache', 'dns', 'o_tcp', 'o_wait', 'o_hdr', 'o_proc']

EPOCH_THRESHOLD = 1_000_000_000
# Each msdms field is truncated independently to integer milliseconds.
# Allow one truncated millisecond per component in the miss chain.
CHAIN_TOLERANCE = len(MISS_CHAIN)


def parse_line(line: str) -> dict[str, str]:
Expand Down Expand Up @@ -116,16 +119,16 @@ def validate_line(fields: dict[str, str], line_num: int) -> list[str]:
if val < -10:
errors.append(f'line {line_num}: miss field "{name}" has unexpected value: {val}')

# Verify chain sum approximates c_ttfb (within tolerance for rounding).
# Verify the signed chain sum approximates c_ttfb within a tolerance
# for per-field millisecond truncation.
chain_vals = []
for name in MISS_CHAIN:
val_str = fields.get(name)
if val_str is None or val_str == '-':
chain_vals.append(0)
continue
try:
v = int(val_str)
chain_vals.append(v if v >= 0 else 0)
chain_vals.append(int(val_str))
except ValueError:
chain_vals.append(0)

Expand All @@ -134,8 +137,7 @@ def validate_line(fields: dict[str, str], line_num: int) -> list[str]:
if c_ttfb_str and c_ttfb_str != '-':
try:
c_ttfb_val = int(c_ttfb_str)
# Allow 2ms tolerance for rounding across multiple sub-millisecond fields.
if c_ttfb_val >= 0 and abs(chain_sum - c_ttfb_val) > 2:
if c_ttfb_val >= 0 and abs(chain_sum - c_ttfb_val) > CHAIN_TOLERANCE:
errors.append(
f'line {line_num}: chain sum ({chain_sum}) != c_ttfb ({c_ttfb_val}), '
f'diff={abs(chain_sum - c_ttfb_val)}ms')
Expand Down