Repository navigation
urtest: Convert AuTest tests to pytest - #13545
Conversation
1b8339e to
678cb46
Compare
bryancall
left a comment
There was a problem hiding this comment.
Leaving this as a comment rather than a formal review since it is still a draft. There is a lot of good work here, and two things that I think need to come out of this PR before it goes further.
First the good, because the framework itself is well built:
- Replay manifests are collected as first-class pytest items, so each scenario gets its own result and sandbox instead of hiding behind a thin registration wrapper.
- Validation parity with AuTest is preserved rather than quietly dropped.
diags.logis still scanned forERROR:,FATAL:and unrecognized configuration values, background processes are checked for premature exit, and_validate_goldreproduces the{}and backtick wildcard semantics of the old matcher. - Cross-worker port allocation uses a flock'd counter plus a bind probe, which is a genuine improvement over a per-process allocator.
- Sandbox paths are deliberately short and hashed with the rationale tied to
sockaddr_un.sun_path's 108-character limit written down, andprepare_sandboxrefuses tormtreeanything that is not a direct child of the sandbox root. - The consolidation is real rather than lossy, and the framework ships its own unit tests instead of being validated only by the suite it runs.
Two production changes are buried in the test migration
This is my main concern and it is a process point rather than a code-quality one. Copilot declined to analyze this PR because it exceeds its file limit, so these two changes have had no automated review either, and at 2414 files no human is going to find them by reading.
src/api/InkAPI.cc:8240 TSSslClientCertUpdate()'s lookup key changes from swoc::bwprint("{}:{}", cert_path, key_path) to key.assign(cert_path).
I traced this rather than assuming. The inner map is keyed by certificate path alone: SSLConfig.cc:952 sets ctx_key = client_cert, and the only producer of that key, SSLSNIConfig.cc:185, stores a fully resolved absolute path, which is what the cert_update plugin passes via traffic_ctl plugin msg. So on master the composed cert:key string can never match, the API always falls through and returns TS_ERROR without touching anything. After this change it locates the bucket, calls SSLCreateClientContext and swaps the shared context under ctxMapLock.
That is a dead-to-live transition on a public TSAPI affecting shared outbound TLS state. The fix looks correct to me. The problem is that its only covering test, cert_update.test.py, is deleted and rewritten in the same commit range, so a green run cannot distinguish "the API fix works" from "the rewritten test no longer asserts the same thing". This needs to land in its own PR against an unmodified test.
src/proxy/http/HttpTransact.cc:6399-6410 A new proxy.config.http.cache.max_stale_age_percent record, added end to end: RecordsConfig.cc:663, HttpConfig.h:708, OverridableConfigDefs.h:255, a new TS_CONFIG_HTTP_CACHE_MAX_STALE_AGE_PERCENT inserted before TS_CONFIG_LAST_ENTRY in apidefs.h.in:921, cripts/Configs.hpp:104, and the clamp logic in is_stale_cache_response_returnable(). None of it exists on the base and none of the seven commit messages or the PR body mention it.
In fairness: the default is 0 and the arithmetic collapses to the exact master expression at 0, so no behavior change ships. It is still a new proxy.config.* record and a new TSOverridableConfigKey, which is API surface the project supports forever, and it touches the stale-serving threshold used by negative revalidating and open_write_fail_action, which is load-shedding-critical.
One substantive note on the logic itself if it does get its own PR: get_max_age() returns 0, not -1, when a max-age directive is present but zero. So with the percent knob enabled, max_stale_age becomes 0 and any nonzero age fails the returnability test. An origin sending Cache-Control: max-age=0, which is common in front of revalidating origins, stops being served stale entirely during an outage. The documentation covers the absent case but not the present-and-zero case.
The Jenkins entry point is left in a non-working state
ci/jenkins/bin/autest.sh:123
The entire change to this file is one line, -D ./tests/gold_tests to -D ./tests/uranium_tests. Lines 107-108 still resolve AUTEST=/usr/bin/autest and line 123 still executes it. I counted the new tree: tests/uranium_tests has 0 files matching *.test.py, which is AuTest's only collection pattern, against 233 *.test.yaml and 303 test_*.py, and tests/gold_tests no longer exists. tests/pyproject.toml also drops the autest dependency.
So this script either runs a discovery pass over an inventory it cannot see and reports green having executed nothing, or fails for a reason unrelated to the change under test. ci/coverage and ci/regression were correctly updated to call tests/urtest.sh; this one was missed. A CI job that silently runs zero tests is worse than one that fails.
The deprecation story does not hold
CMakeLists.txt:164-165
The PR body says temporary deprecated aliases retain ci-fedora-autest, autest.sh, the old CMake options and targets. I checked each: option(ENABLE_AUTEST) and option(ENABLE_AUTEST_UDS) are replaced outright, the three gates now test ENABLE_URTEST only, and tests/CMakeLists.txt renames the autest, autest_no_install and autest-uds targets with no ALIAS or forwarding target. CMakePresets.json has only ci-fedora-urtest, and there is no tests/autest.sh. The only deprecation shims are AUTEST_SANDBOX, AUTEST_OPTIONS and PYTEST_OPTIONS, and those live inside if(ENABLE_URTEST), so they never fire for a caller passing the old option.
CMake treats an unconsumed -DENABLE_AUTEST=ON as an unused-variable notice, not an error, so an external pipeline configured that way configures successfully, silently skips add_subdirectory(tests), and produces no test target at all. A job using the old preset fails loudly instead, which is the better outcome. Either add real aliases or state plainly in the body that the cut-over is not backward compatible.
Framework items worth fixing while it is still a draft
tests/tools/uranium/runner.py:225is_official_test_container()requires an exactID == "fedora"andVERSION_ID == "44"match, andchoose_docker_mode()defaults to Docker when that fails. When the CI image is bumped to Fedora 45 in some unrelated PR, urtest inside that container stops recognizing it, defaults to Docker mode, finds no docker client, and every shard dies. The safe default when already inside any container is to run directly.tests/tools/uranium/replay.py:657-668_check_metricssleeps a fixed interval then reads each metric exactly once with no retry._check_filesin the same file already does this correctly with a 100ms deadline poll. 17 manifests usemetric_checks, and sleep-then-assert-once under 8-way xdist is precisely the flake pattern this migration is meant to leave behind.tests/tools/uranium/runtime.py:38class RuntimeError(ValueError)shadows the builtin for the whole module, whileprocess.py:29definesProcessError(RuntimeError)against the real builtin. Two unrelated hierarchies with the same spelling in one package.tests/tools/uranium/replay.py:749and:793read_text()with no existence check, so a missing diags or gold file surfaces as a raw traceback into framework internals rather than the intended message. Every sibling path in the same class already guards withif path.exists().
One claim I checked and am withdrawing before anyone chases it: I initially thought ReplayItem.runtest hardcoding is_exclusive=False broke serial_tests.txt for replay manifests. On re-reading it is latent rather than live, so it is worth tidying but it is not causing anything today.
c654ac4 to
c680be9
Compare
|
Thanks for the detailed review. I addressed the feedback and force-pushed the amended commit.
I also normalized direct replay placement, fixed the stale documentation includes, and reran the relevant validation: the documentation build passes with warnings treated as errors, all 371 replay variants passed or reached expected capability skips, and the 51 framework unit tests pass. |
|
[approve ci autest] |
|
I benchmarked this migration on dedicated hardware rather than reasoning about it, because a harness swap of this size deserves numbers. Summary up front: Uranium is 7.4x faster at 32-way parallelism, loses no code coverage, uses less memory, and has fewer flaky tests. Details and methodology below, including the parts that do not favour the new harness. MethodologyTwo hosts, both 32 hardware threads, 30 GB RAM, Fedora, gcc 16.1.1, Proxy Verifier v3.1.3 on both sides (verified identical, checksum
The proxy binary is the same on both sides. I checked this rather than assuming it, because the whole comparison depends on it. After normalizing embedded build paths, both binaries disassemble to 1,341,244 instructions and the instruction streams are identical once addresses are masked. The residual byte differences are relocation displacements from embedded path and timestamp strings of different lengths, spread across 1,265 unrelated symbols in single-byte runs. So every number below is harness overhead, not a proxy change. PerformanceFull suite, same host, same binary:
The gap widens with worker count, which points at the mechanism:
AuTest's worker durations at The cause is that AuTest's load balancing never engages. Uranium's per-test distribution for reference: p50 1.13s, p95 9.17s, max 90.6s. Code coveragegcov plus gcovr 8.6, identical flags and exclusions on both sides, integration suite only:
No coverage is lost. Uranium is fractionally ahead on all three measures. This is the number that matters most, since a 7.4x speedup naturally raises the question of whether the suite is simply doing less. It is not. The denominators are identical on both sides, which independently corroborates the binary-equivalence check above. MemoryPeak resident memory across the whole process tree:
Uranium uses less memory at every level, with the gap widening to about 31% at 16 workers. Neither harness came close to exhausting 30 GB. Caveat worth stating: these are summed RSS across all processes, which double counts pages shared between the many concurrent Traffic Server instances, so treat them as upper bounds. The idle baseline was 0.97 GB, so roughly 92% of each figure is genuine workload. I am re-measuring with proportional set size to remove the double counting and will follow up if it changes the picture. FlakinessSeven AuTest runs and six Uranium runs, across all parallelism levels:
Two observations that only a repeated run surfaces. A flaky test was distorting the timing. AuTest at AuTest does not run a deterministic set of tests. Executed totals across runs were 586, 586, 586, 586, 586, 583, 581. At Test inventoryI mapped all 564 master Exactly one test has no successor: Everything else is verified consolidation, and the counts hold up: the 18 Other findings
OverallThe performance and determinism case is strong and I would not have predicted the margin. The two things I would want resolved before this leaves draft are the Happy to share the raw logs, per-test timing data, or the gcovr HTML reports for either side. |
7fcbc9d to
f3d4785
Compare
New upstream connection-pool regressions would be undiscovered in their AuTest form, and the converted retry test needs the upstream protection against reusing an origin connection before its close is observed. This patch registers the three pool cases as direct replay tests, with opt-in origin shutdown before metric checks to preserve their lifecycle. It carries the early-reset session-sharing policy into the pytest scenario. Co-authored-by: GPT-6 Astra Medium
Test migrations can silently lose assertions or change process lifetimes even when their replacements pass. Contributors need the lessons from the Uranium migration available in the repository. This patch adds a shared conversion skill covering test selection, semantic parity, rebase audits, and focused verification. Co-authored-by: GPT-6 Astra Medium
The new upstream rate-limit regression would not run as an AuTest wrapper in the pytest suite. This patch expresses the excluded and ordinary SNI requests as a self-contained replay, preserving TLS admission checks and the client-IP exclusion diagnostic. Co-authored-by: GPT-6 Astra Medium
4d94215 to
dc60550
Compare
bryancall
left a comment
There was a problem hiding this comment.
❌ Request changes
I re-reviewed deb7f8e70..dc60550ea. git range-diff c8935543e..deb7f8e70 7f49e4c6b..dc60550ea pairs all 28 commits I last reviewed: 20 are identical, and 8 carry only rebase resolution (master's AuTest edits moved into their Uranium files). The response is five new commits, 116 files, +2,601/-5,020. The rebase onto current master is thorough and I checked it file by file. None of the five asks I left open on 10-06 moved, though: plugin.py, runtime.py, test_virtualhost_remap.py, config_reload_helpers.py and the slice assertion are byte-identical to deb7f8e70. I also found one PR-wide gap that I missed in earlier rounds.
Fixed: conflicts with master
GitHub now reports the branch mergeable, and its merge-base is 7f49e4c6b, the tip of master. git ls-tree -r HEAD tests/gold_tests is empty, and no *.test.py remains under tests/uranium_tests.
I checked all 179 entries in git diff --name-status c8935543e 7f49e4c6b -- tests/gold_tests (121 added, 58 modified) against their counterparts at dc60550ea. 170 carry master's change faithfully. That includes all 20 new AuTests I listed last time, the TLS resumption tests, the pool_lock backoff line (#13874) in the global and hybrid manifests only, and the 127.0.0.1 origins in all 14 cookie_remap tests (#13875). Of the other nine, one is an AuTest helper that needs no counterpart, and the rest are in the non-blocking sections below.
Still blocking: the virtualhost conversion lost its "refused reload fails" assertion
Unchanged since deb7f8e70. tests/uranium_tests/remap/test_virtualhost_remap.py:110-112 still runs the conflicting reload without -m, requires exit 0, and calls wait_for_status(ats, "vhost-conflict", "virtualhost", "fail"). That substring check passes whether or not the task failed, and my 10-06 mutation (ctx.fail changed to ctx.complete at src/proxy/VirtualHost.cc:545) left it green.
What would change my mind: assert the virtualhost task status from the JSON-RPC response, as test_config_reload_rpc.py does, or restore -m with expected_return_codes=(2,).
Still blocking: procedural tests no longer check diags.log for errors
This one predates this push, and I should have caught it earlier. AuTest's MakeATSProcess failed any test whose diags.log contained ERROR:, FATAL: or Unrecognized configuration value, unless the test set disable_log_checks (tests/gold_tests/autest-site/trafficserver.test.ext:253-258 on master). Uranium keeps that default only for replay manifests (tests/tools/uranium/replay.py:805-811). A procedural test's ATS.close() checks only FATAL: (tests/tools/uranium/services/ats.py:649), and nothing else in tests/tools/uranium looks for ERROR: or Unrecognized configuration value.
The result is that a misspelled record name, or an ERROR: the old test would have caught, now passes in every procedural test that does not scan diags itself. Of the 350 test_*.py files under tests/uranium_tests, 14 mention ERROR: at all. It also makes disable_log_checks= a silent no-op: h2/origin_test_helpers.py:30 documents it as "Replace default error checks", and 10 procedural files pass it to ats_factory.create, which drops it. The new conversion guide in .claude/skills/convert-autest-to-urtest/SKILL.md does not mention the difference, so future conversions will repeat it.
What would change my mind: ATS.close() applying the same three exclusions as replay.py unless disable_log_checks is set, plus a framework self-test where a procedural test with ERROR: in diags goes red. Expect some procedural tests to need disable_log_checks=True once the check is live. That is the point.
I found this by reading the source, not by running it.
Half done: ask 5, the dead parameter and the test that does not cover the shipped line
Unchanged. runtime.py is byte-identical to deb7f8e70, so item_sandbox still never reads replay_path, and reverting parent= in replay.py still leaves the self-tests green.
Half done: ask 6, the collision guard still crashes under -n
Unchanged. plugin.py:123-128 still raises UsageError from pytest_collection_modifyitems on every worker, which ends a -n 2 run in INTERNALERROR / assert not crashitem.
Half done: ask 8, ENOLCK and cross-file names
Unchanged. plugin.py:105 still catches only BlockingIOError, and runtime.py still drops the file path from the sandbox name.
Not addressed: ask 12, the slice alternation
Unchanged at test_slice_stale_generation.py:258-261. The alternation is still unbracketed.
Not addressed: five Copilot threads from 10-01
All five are still open, and each file is byte-identical to deb7f8e70: the ENABLE_AUTEST fatal guard against contrib/docker/ubuntu/resolute/Dockerfile, the dead rat-exclude.txt path, config-reload-ext.en.rst documenting Test.AddConfigReload(), TSHttpHookAdd.en.rst:148-149 naming test_hooks.test.py, and the jax_fingerprint README saying AuTests.
Non-blocking: remap_https lost its header checks and its chunked path
This dates from the original conversion. The AuTest checked curl's stderr against gold files on eight runs (remap_https.test.py:76-124 at c8935543e). tests/uranium_tests/remap/replay/remap_https.test.yaml:63-90 checks status codes only. #13763 then framed only the TLS origin, with the comment "the plaintext origin exercises ATS chunking". The manifest sends Content-Length: 0 from every origin, so the chunked response that remap-https-200.gold asserted is no longer exercised at all. Both copies of remap-https-200_2.gold are now referenced by nothing.
Non-blocking: changes in this push worth a second look
tls/test_tls_sni_groups.py:116-121,129-134. It now forces-tls1_2and-tls1_3on the client. The old curl check (SSL connection using TLSv1.2 / ...) proved the server enforcedvalid_tls_versions_in. With the client pinned, a broken version restriction passes.tls/replay/dual_cert_default_ec_rsa.replay.yaml:24. Thedest_ip: ""entry is nowsigned-san-ec.pem,signed-san.pem. Master hassigned-san.pem,signed-san-ec.pem, which gave a mixed layout. If the reorder is intended, say so in the commit, because the mixed case is no longer tested.pluginTest/slice/replay/slice_body_headers.test.yaml:68-70addsConnection: closeto the/dup_terequest, which master's replay does not have. What did it fix? I want to be sure it is not hiding a Uranium-only problem.tls/test_tls_resumption_scope.py:221-224,261-262check only thetraffic_ctlexit code, where the AuTests also required thesni.yamlandssl_multicert.yamlreload tasks (expect_tasks). In the same file, the client-CA scope case now counts only^200 bbb.example.com$in squid.log, where the AuTest allowed nobbb.example.comline at all, so a non-200 entry for it now passes.rate_limit_sni_exclude.test.yamlcannot tell an excluded SNI from a limited one on admission, since each SNI makes one connection underlimit: 1. The "excluded via List=loopback" check carries it. An exclude forLimiter on limited.example.com is excludedwould close that, and the gap came over from the AuTest.tests/tools/uranium/tests/test_replay.py:29parametrizesstop_after_clientasFalseandTrueonly, so the default with the key absent is never exercised. Thereplay.py:120-121change itself is correct.- Orphans.
timeout/slow_server_uds.yamlis referenced by nothing, so nothing selects the UDS replay thatinactive_client_timeout.test.pyused underCurlUsingUnixDomainSocket().session_sharing/gold/200_two.goldandh2/gold/h2o-pool-reuse-metrics.goldare unreferenced too. Wire them up or delete them.
Not verified by execution
I did not build or run anything this round, since the asks above stand either way. Everything here comes from reading the source at dc60550ea and from my 10-06 runs on files that have not changed since.
bryancall
left a comment
There was a problem hiding this comment.
✅ Approve
Agreed: merge now, follow up in #13877
Approving so this lands before master drifts again. CI is green on dc60550ea, and the trafficserver-ci pipelines already switch to Uranium when tests/urtest.sh is present. I moved everything still open from my reviews into #13877. Please take the diags ERROR: check first: every procedural test written before it lands is one more to sort out once it does.
The supported 10.2.x branch still relies on AuTest while master uses pytest, making test maintenance and CI behavior diverge between releases. This patch backports the Uranium framework and converted tests from apache#13545, preserving the branch-specific coverage and configuration formats. It includes the Bash 3 compatibility fix from apache#13884 and adapts the build, documentation, and test helpers for the release branch. The migration also includes the outbound connection-accounting fix carried by apache#13545. Pending connections retain their tracker reservation until the resulting session takes ownership, preserving per-origin connection counts and limits when transactions share a connection attempt. The converted connection-limit tests exercise this production behavior. Co-authored-by: GPT-6 Astra Medium
The supported 10.2.x branch still relies on AuTest while master uses pytest, making test maintenance and CI behavior diverge between releases. This patch backports the Uranium framework and converted tests from apache#13545, preserving the branch-specific coverage and configuration formats. It includes the Bash 3 compatibility fix from apache#13884 and adapts the build, documentation, and test helpers for the release branch. The migration also includes the outbound connection-accounting fix carried by apache#13545. Pending connections retain their tracker reservation until the resulting session takes ownership, preserving per-origin connection counts and limits when transactions share a connection attempt. The converted connection-limit tests exercise this production behavior. Co-authored-by: GPT-6 Astra Medium
The supported 10.2.x branch still relies on AuTest while master uses pytest, making test maintenance and CI behavior diverge between releases. This patch backports the Uranium framework and converted tests from formats. It includes the Bash 3 compatibility fix from apache#13884 and adapts the build, documentation, and test helpers for the release branch. The migration also includes the outbound connection-accounting fix carried by apache#13545. Pending connections retain their tracker reservation until the resulting session takes ownership, preserving per-origin connection counts and limits when transactions share a connection attempt. Co-authored-by: GPT-6 Astra Medium
The supported 10.2.x branch still relies on AuTest while master uses pytest, making test maintenance and CI behavior diverge between releases. This patch backports the Uranium framework and converted tests from apache#13545, preserving branch-specific coverage and configuration formats. It includes the Bash 3 compatibility fix from apache#13884 and adapts the build, documentation, and test helpers for the release branch. Explicit replay comparisons and native checks preserve the original assertions. The migration also includes the outbound connection-accounting fix carried by apache#13545. Pending connections retain their tracker reservation until the resulting session takes ownership, preserving per-origin connection counts and limits when transactions share a connection attempt. HTTP/2 closes its network connection before session-close hooks run. This patch preserves the peer, effective client, and local endpoints so those hooks can still inspect valid addresses, including PROXY protocol addresses. Regression checks exercise ordinary and PROXY HTTP/2 sessions. Co-authored-by: GPT-6 Astra Medium
* Backport Uranium tests to 10.2.x The supported 10.2.x branch still relies on AuTest while master uses pytest, making test maintenance and CI behavior diverge between releases. This patch backports the Uranium framework and converted tests from #13545, preserving branch-specific coverage and configuration formats. It includes the Bash 3 compatibility fix from #13884 and adapts the build, documentation, and test helpers for the release branch. Explicit replay comparisons and native checks preserve the original assertions. The migration also includes the outbound connection-accounting fix carried by #13545. Pending connections retain their tracker reservation until the resulting session takes ownership, preserving per-origin connection counts and limits when transactions share a connection attempt. HTTP/2 closes its network connection before session-close hooks run. This patch preserves the peer, effective client, and local endpoints so those hooks can still inspect valid addresses, including PROXY protocol addresses. Regression checks exercise ordinary and PROXY HTTP/2 sessions. Co-authored-by: GPT-6 Astra Medium * Isolate nested Uranium test sandboxes An exported sandbox path makes the collision-diagnostic self-test reuse the enclosing pytest session's locked sandbox, preventing the intended collection diagnostic from running. This patch gives the child session an explicit private sandbox and exercises both serial and parallel collection with an inherited, locked parent sandbox. The shared-sandbox safety lock remains unchanged. Co-authored-by: GPT-6 Astra Medium --------- Co-authored-by: bneradt <[email protected]>
This replaces Traffic Server's AuTest end-to-end suite with Uranium, a pytest
test framework for Proxy Verifier replays and native Python scenarios. There is
no AuTest compatibility backend in the resulting test suite.
Summary
<scenario>.test.yaml; eachmanifest contains both its
urtestconfiguration and replay sessionspytest scenario classes with an explicit
run()entry pointand shared/exclusive scenarios
under
tests/tools/uraniumurtest.sh, Uranium CMakeoptions and targets, and
urtestreplay metadataDirect replay manifests live in an existing
replay/orreplays/directorywhen a test tree has one. The
at_headersmanifest intentionally remains nextto its plugin assets.
Developer workflow
Run selected tests with pytest's normal selection and parallelism options:
A configured tree generates
<build>/tests/urtest.shfor running against itsinstalled ATS tree. Manual tests are skipped by default and can be selected
explicitly with
--run-manual -k <expression>.Container behavior
The source-tree runner defaults to
ci.trafficserver.apache.org/ats/fedora:44, performs an incremental dedicatedbuild/install, and runs pytest there. It avoids nested Docker whenever it is
already inside any container.
--run-in-dockerand--no-run-in-dockeroverride that choice.
The official Fedora image also enables the optional
cdifflibacceleration forlarge gold-file comparisons. Other environments use it when installed and
fall back to the standard-library
difflibimplementation otherwise.Compatibility
This is an intentional cutover rather than a deprecation shim. The AuTest
runner, backend, CMake targets, presets, and options are removed. CMake reports
a fatal migration message if removed
ENABLE_AUTEST,ENABLE_AUTEST_UDS,AUTEST_SANDBOX,AUTEST_OPTIONS, orPYTEST_OPTIONSvariables are supplied.Existing CI scripts now invoke Uranium and pass pytest's
-kand-noptions.SHARDandSHARDCNTcontinue to distribute pytest items across CI shards.Validation
failure for the pre-existing
TSSslClientCertUpdatedefectchecks passed