Skip to content

Test: add msdms milestone logging field validation autest#12899

Merged
bryancall merged 8 commits intoapache:masterfrom
bryancall:add-milestone-logging-autest
Mar 23, 2026
Merged

Test: add msdms milestone logging field validation autest#12899
bryancall merged 8 commits intoapache:masterfrom
bryancall:add-milestone-logging-autest

Conversation

@bryancall
Copy link
Contributor

@bryancall bryancall commented Feb 19, 2026

Problem

The msdms milestone timing log fields had no end-to-end test coverage.
Bugs like the epoch leak in #12897 and the missing UA_BEGIN_WRITE
milestone in #12898 went undetected until manual inspection.

Changes

  • New autest log-milestone-fields -- sends a cacheable request
    twice (cache miss then cache hit) and validates all Phase 1 msdms
    timing fields in the resulting log output.
  • Validation script verify_milestone_fields.py -- reusable Python
    script that parses key=value log lines and checks: all 16 fields
    present, values are integers with no epoch-length garbage, miss-path
    chain sums to c_ttfb within 2 ms, and hit-path fields are
    non-negative.
  • Timing jitter tolerance -- allows up to −10 ms on the dns field
    to handle millisecond-granularity overlap between
    SERVER_FIRST_CONNECT and CACHE_OPEN_READ_END.

Testing

  • The autest itself validates correctness for both cache-miss and
    cache-hit paths
  • CI green on all 15 platforms

difference_msec() only checked whether ms_end was zero (unset).
When ms_start was unset (zero) but ms_end was set, the subtraction
produced a large epoch-relative value instead of returning the
missing sentinel. Check both milestones before computing the delta.
Mark TS_MILESTONE_UA_BEGIN_WRITE in the SERVER_READ and SERVE_FROM_CACHE
paths of handle_api_return(). Previously this milestone was only set in
the API_SEND_RESPONSE_HDR hook path, which requires a plugin to hook
TS_HTTP_SEND_RESPONSE_HDR_HOOK. Without plugins the milestone stayed
at zero, causing msdms log fields that reference UA_BEGIN_WRITE
(c_ttfb, o_proc, o_body, hit_proc, hit_xfer) to report -1.
New end-to-end test that sends a cacheable request twice (miss then hit)
and validates all Phase 1 msdms timing fields in the resulting log:

- All 16 key=value fields present on every line
- Values are integers with no epoch-length garbage
- Cache miss: origin-phase chain sums to c_ttfb within 2ms
- Cache hit: hit_proc and hit_xfer are non-negative

Includes a reusable verify_milestone_fields.py validation script.

Depends on apache#12897 (difference_msec fix) and apache#12898 (UA_BEGIN_WRITE fix).
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a comprehensive end-to-end test for the msdms milestone timing fields in ATS logging. The test validates that milestone timing calculations produce correct values for both cache miss and cache hit paths, catching issues like the epoch leak bug that was fixed in PR #12897.

Changes:

  • Adds a new autest (log-milestone-fields.test.py) that exercises both cache miss and cache hit paths with milestone logging
  • Includes a Python validation script (verify_milestone_fields.py) that parses log output and verifies timing field correctness
  • Includes fixes from PRs #12897 and #12898 for the difference_msec epoch leak and unconditional UA_BEGIN_WRITE milestone marking (to be rebased once those PRs merge)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/gold_tests/logging/log-milestone-fields.test.py New autest that sends cache miss and hit requests, configures milestone logging, and validates the output
tests/gold_tests/logging/verify_milestone_fields.py Python script that validates log output: checks field presence, integer values, no epoch leaks, and timing chain correctness
src/proxy/http/HttpSM.cc Marks UA_BEGIN_WRITE milestone unconditionally in SERVER_READ and SERVE_FROM_CACHE cases (from PR #12898)
include/proxy/Milestones.h Fixes epoch leak by checking both start and end milestones are non-zero in difference_msec (from PR #12897)

These lists were development artifacts not referenced by the test.
The validation logic lives in verify_milestone_fields.py which has
its own field definitions.
@bryancall bryancall closed this Feb 20, 2026
@bryancall bryancall reopened this Feb 20, 2026
@bryancall
Copy link
Contributor Author

/retest

@bryancall bryancall closed this Feb 20, 2026
@bryancall bryancall reopened this Feb 20, 2026
@bryancall
Copy link
Contributor Author

[approve ci ubuntu]

The dns field (SERVER_FIRST_CONNECT - CACHE_OPEN_READ_END) can have
small negative values due to millisecond-granularity timing overlap.
Allow up to -10ms jitter instead of rejecting anything below -1.
@bryancall
Copy link
Contributor Author

[approve ci autest 1]

@bryancall
Copy link
Contributor Author

[approve ci clang-analyzer]

@bryancall
Copy link
Contributor Author

[approve ci freebsd]

@bryancall
Copy link
Contributor Author

[approve ci]

@bryancall bryancall requested a review from bneradt February 21, 2026 21:05
@bryancall bryancall requested a review from bneradt March 16, 2026 16:20
@bryancall bryancall merged commit b7db7b8 into apache:master Mar 23, 2026
15 checks passed
@bneradt bneradt modified the milestones: 10.2.0, 11.0.0 Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants