Skip to content

Fix overridable configuration testing - #13516

Open
bneradt wants to merge 2 commits into
apache:masterfrom
bneradt:overridable-config-catch-tests
Open

Fix overridable configuration testing#13516
bneradt wants to merge 2 commits into
apache:masterfrom
bneradt:overridable-config-catch-tests

Conversation

@bneradt

@bneradt bneradt commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The overridable configuration regression test writes arbitrary values to
each setting and expects exact round trips. That forced the server match
converter to retain out-of-range enum values, which can break
connection-group hashing and equality in production.

This patch replaces the regression test with Catch coverage that checks
the full name/key/type map and representative public setter and getter
paths with valid values. It also adds focused converter coverage
and clamps server match values to its documented enum range, removing
the production workaround for the flawed test.

Fixes: #4210

The overridable configuration regression test writes arbitrary values to
each setting and expects exact round trips. That forced the server match
converter to retain out-of-range enum values, which can break
connection-group hashing and equality in production.

This patch replaces the regression test with Catch coverage that checks
the full name/key/type map and representative public setter and getter
paths with valid values. It also adds focused converter coverage
and clamps server match values to its documented enum range, removing
the production workaround for the flawed test.

Fixes: apache#4210
Copilot AI lite review requested due to automatic review settings August 7, 2026 18:53
@bneradt bneradt added this to the 11.0.0 milestone Aug 7, 2026
@bneradt bneradt self-assigned this Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes a flawed overridable-configuration regression test that required preserving out-of-range enum values, which in turn prevented proper range checking and could break connection-group hashing/equality in production. It replaces that coverage with Catch2 unit tests that validate the overridable config name/key/type map and representative setter/getter paths using valid values, and it restores correct clamping behavior for the per-server connection match converter.

Changes:

  • Add Catch2 unit tests for the HTTP overridable configuration lookup and representative set/get APIs.
  • Add focused unit test coverage for ConnectionTracker server-match conversion, and clamp invalid integer values to the documented enum range.
  • Remove the legacy InkAPITest regression that enforced invalid round-trips and add the new API unit test target to the build.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/iocore/net/unit_tests/test_ConnectionTracker.cc Adds Catch2 coverage for server match converter round-trips and clamping behavior.
src/iocore/net/ConnectionTracker.cc Restores correct clamping of server match values in SERVER_MATCH_CONV.
src/iocore/net/CMakeLists.txt Includes the new ConnectionTracker unit test source in the net test target.
src/api/unit_tests/test_HttpOverridableConfig.cc Adds Catch2 tests for overridable config discovery and representative int/float/string set/get paths (including clamped enum).
src/api/InkAPITest.cc Removes the legacy overridable-config regression test that depended on accepting arbitrary out-of-range values.
src/api/CMakeLists.txt Adds a new Catch2 test executable/ctest entry for the overridable-config API unit tests.

@bryancall
bryancall requested a review from moonchen August 10, 2026 22:21
The API Catch test loaded libtsapi on macOS, where unresolved core
symbols are resolved by traffic_server at runtime. The standalone test
therefore aborted in dyld before Catch ran because ET_UDP was absent.

This patch builds the API implementation as reusable position-independent
objects and links those objects into both libtsapi and the unit test. The
test now exercises production API code while allowing platform linkers to
resolve all static ATS dependencies directly.
Copilot AI review requested due to automatic review settings August 11, 2026 00:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@moonchen moonchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The production fix is right — server_match feeds Group::Key hashing and MATCH_TYPE_NAME is sized MATCH_BOTH + 1, so an out-of-range value was reachable from a plugin.

Two things on the test side.

The old regression test round-tripped set/get over all 137 OVERRIDABLE_CONFIGS entries; the new one covers four. #4210 asks for in-range values, not for fewer variables. Dropping the loop also leaves nothing checking that a row's declared DATA_TYPE matches the member's actual C++ type — the new Find case compares type against descriptor.type, and both come from the same X-macro row. Could the loop stay, reading each config's current value and writing it back? That round-trips every converter with a value that is valid by construction.

OverridableConfigDefs.h still lists SDK_Overridable_Configs test array (InkAPITest.cc) as a generation target; that array is gone after this change.

// *static_cast<decltype(TxnConfig::match) *>(data) = std::clamp(static_cast<decltype(TxnConfig::match)>(i), MATCH_IP,
// MATCH_BOTH);
*static_cast<decltype(TxnConfig::server_match) *>(data) = static_cast<decltype(TxnConfig::server_match)>(i);
auto const value = std::clamp(i, static_cast<MgmtInt>(MATCH_IP), static_cast<MgmtInt>(MATCH_BOTH));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The string setter below rejects an unknown tag and calls Warning_Bad_Match_Type(), leaving the value alone. Here an out-of-range int is silently coerced and TSHttpTxnConfigIntSet() still returns TS_SUCCESS, so match: 95 quietly becomes both while match: "bogus" warns. Intentional?

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.

Overrideable configuration testing

3 participants