Repository navigation
Conversation
✅ Integration test reportCommit: 333332a
Top 3 slowest tests (at least 2 minutes):
|
Regression test report ✅Commit: Selected 2 changed tests (limit=20, 0 not selected) 5 tests: regression=0 unreleased=0 coverage=5 failing=0
|
…icks#8172) ## Changes The acceptance test proxy (`libs/testproxy`) no longer retries. It forwards what upstream answered, failures included: - 429/503/504 are passed to the client after one attempt. - If the upstream connection fails before a response, the proxy resets the client's connection. - If the upstream response body is cut short, the client's body is cut short too. The request recorder treats a response it never got (status 0) as transient, so the CLI's retry is dropped from `out.requests.txt` as it already is for 5xx. ## Why The proxy forwards through an SDK `ApiClient`, which retries 429, 503, some 504s and connection errors itself. Those failures never reached the CLI under test, so a `Proxy = true` test or a cloud recording run could not show whether the CLI handles them. This came up in [databricks#8133](databricks#8133), where an injected fault hidden by the proxy would count as a pass. The SDK retries some connection errors by message no matter what `ErrorRetriable` returns, so the proxy's transport replaces their message. Go's `net/http` still repeats an idempotent request that fails on a reused connection, as it does without the proxy. ## Tests New unit tests in `libs/testproxy`: retriable statuses, a connection reset and a truncated body each reach the client after exactly one upstream call. `acceptance/selftest` passes locally. Not run on cloud. 🤖 AI agent (opus5.5, isaac_claude) This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
…ricks#8193) ## Changes `acceptance/bin/replay_tfstate.py` now pushes the remote copy of the replayed terraform state with its own `api()` helper (`POST /api/2.0/workspace/mkdirs` and `POST /api/2.0/workspace/import`), instead of running `$CLI workspace mkdirs` and `$CLI workspace import`. It sends the same two requests, so no goldens change. ## Why The script sets up state for a test; it isn't the CLI under test. All of its other calls already go to the API directly, and these two were the only ones that went through the CLI. This is a prep step for [databricks#8133](databricks#8133), which injects backend errors into the CLI's requests. Setup that the CLI performs would get those faults too, and the script does not retry. ## Tests All 51 acceptance test dirs that use the script pass locally (`bundle/migrate`, `bundle/invariant/{migrate,auto-migrate}`, `bundle/config-remote-sync/terraform_state`, `bundle/state/state_present`), with unchanged goldens. This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
…ries Co-authored-by: Isaac <no-reply@databricks.com>
Helpers that set up state or play the user's browser (replay_tfstate.py, browser.py, the selftest curls) send X-Databricks-Test-No-Fault. The testserver neither counts nor fails such requests, and -faultlog reports how many each test sent. replay_tfstate.py now pushes the remote state with its own API calls instead of the CLI, so its setup is never faulted. Co-authored-by: Isaac <no-reply@databricks.com>
A fault now targets a request key (method and path with the test's replacements applied, plus an occurrence) instead of a position in the request sequence, which shifts when the CLI calls in parallel. Plan keys may leave out EnvMatrix segments to cover all matching variants. fault_sweep.py gains --mode exhaustive (every request x every kind), --plan FILE (lists of faults per test), and writes failures.plan.json. Tests that assert their own retry warnings are left out by default. Co-authored-by: Isaac <no-reply@databricks.com>
Each test that passes reruns as subtests fault=1..N, one request failed in each. The faults are drawn from the clean run's requests by a hash of the seed, the test name and the request key, so fault=k is the same fault on every run whatever N is. -faultcount and -faultseed replace -faultplan, -faultlog and tools/fault_sweep.py. Tests opt out with FaultInjection = false or skip requests with FaultSkip. Co-authored-by: Isaac <no-reply@databricks.com>
c11ec08 to
3c3e8c4
Compare
Add the test-faults job and the task behind it: one fault per test on each push to main, ten per changed test on pull requests, seeded by the head commit. The job is not in test-result's needs, so it does not block merging while the CLI still fails on some faults. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: denis.bilenko <denis.bilenko@databricks.com>
There was a problem hiding this comment.
Automated review at 952fa4b. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR adds a -faultcount mode to the acceptance harness. Each passing test reruns with one testserver request failed (5xx, reset or truncated body), and a non-blocking test-faults CI job runs it. The mechanism holds together. One new unit test asserts a Unix-only error string and will fail on the Windows task test cells. A few smaller issues remain: a stray -faultseed is silently ignored, the printed rerun command is less reproducible than the docs claim, and fault reruns go parallel in the in-process and benchmark paths.
Questions
- The
test-faultsjob runs on every PR and every push to main, but the description already lists failures it hits, including this PR's own selftests andbundle/resources/jobs/update. Notest.tomlin the change setsFaultInjection = falseorFaultSkipfor the known gaps, so the check is expected to be red from the start, and a new gap won't stand out. Should it run on the existing nightlyscheduletrigger or locally until the known cases are opted out? The alternative is to add those opt-outs in this PR. (non-blocking)
| if kind == testserver.FaultTruncatedLate { | ||
| assert.ErrorContains(t, err, wantErr) | ||
| } else { | ||
| assert.Regexp(t, wantErr+"|EOF", err.Error()) |
There was a problem hiding this comment.
[blocking] On Windows, an RST from SetLinger(0) surfaces as wsarecv: An existing connection was forcibly closed by the remote host.. That matches neither connection reset by peer nor EOF, so the reset and reset-after subtests fail in the Windows task test cells (AGENTS.md: tests also run on Windows). Can you check errors.Is(err, syscall.ECONNRESET) instead? Go maps WSAECONNRESET to it. Keep io.EOF as the timing fallback, or just require a non-nil error.
| // ParseFaultFlags parses -faultcount and -faultseed. It must run before any test starts. | ||
| func ParseFaultFlags() error { | ||
| switch FaultCountFlag { | ||
| case "", "0": |
There was a problem hiding this comment.
[nice to have] When -faultcount is empty or 0, ParseFaultFlags returns before it looks at FaultSeedFlag. So go test ./acceptance -run ... -faultseed abc123 with -faultcount edited out of a copied rerun command runs a normal pass and reports no error. AGENTS.md asks for an error when a flag can't be honored. Can this return -faultseed requires -faultcount when FaultSeedFlag != "" and fault mode is off?
| } | ||
|
|
||
| // FaultReproFlags returns the flags that rerun fault=k with the same fault. | ||
| func FaultReproFlags(k int) string { |
There was a problem hiding this comment.
[nice to have] FaultReproFlags reproduces a fault by its index k in the hash-sorted list of the clean run's requests. If the local clean run makes one more or one fewer request than CI, every later index moves, and the printed command fails a different request. A timing-dependent poll (GET .../runs/get #5) is enough to cause that. On pull requests, CI also builds the merge commit (actions/checkout) while the seed is the head SHA (push.yml), so a local run on the head commit can draw from a different list once main has moved. Could the rerun command name the fault directly, for example a -fault 'GET /api/... #3 503' flag, instead of an index?
| for i, fault := range faults { | ||
| k := i + 1 | ||
| t.Run(fmt.Sprintf("fault=%d", k), func(t *testing.T) { | ||
| if !InprocessMode { |
There was a problem hiding this comment.
[nice to have] This checks the global InprocessMode, but testAccept decides parallelism from its inprocessMode argument and from benchmarkMode. TestInprocessMode calls testAccept(t, true, ...) while the flag stays false, so go test ./acceptance -faultcount 3 without -run '^TestAccept$' runs the fault=k reruns of selftest/basic in parallel through the single in-process cmd server. Benchmark dirs that are deliberately kept serial also get parallel fault reruns. Can runTest take runParallel as a parameter from testAccept instead?
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: denis.bilenko <denis.bilenko@databricks.com>
|
Example: what the The PR changes two selftests, so the job ran them with 10 faults per variant.
Each fault run logs the command that reruns it, for example: An earlier sweep over all tests, with 2 faults per test, found the same classes of failure in many more places: unretried 502, 504 and truncated bodies on common reads such as This comment was written by Isaac. |
| // NoFaultHeader marks a request that a test helper sends, such as replay_tfstate.py setting up | ||
| // remote state, rather than the CLI under test. Such requests are not counted or failed: the | ||
| // point is to check that the CLI retries, and the helpers do not. | ||
| const NoFaultHeader = "X-Databricks-Test-No-Fault" |
There was a problem hiding this comment.
The well-known config curl in setup_custom_host and its copy in strict_profile_match's script.prepare don't send this header, so a fault there breaks setup, not the CLI. Should both send it?
Key request faults on the test's token, as the shared testserver already does for fake workspaces, kill rules and fault rules, so fault mode no longer gives each test a testserver of its own and its clean run is the normal run. Requests without a token, such as host metadata, belong to no test on the shared server and are not failed; tests with a testserver of their own still cover them. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: denis.bilenko <denis.bilenko@databricks.com>
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Sonnet 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.
Design, could be simpler: runTest, PrepareServerAndClient and runTestOnce pass the planned fault and its RequestFaults scope to each other through two package-level sync.Maps keyed by *testing.T. If the fault were passed into PrepareServerAndClient/startLocalServer and the scope returned from runTestOnce, both maps would go, along with PlanFault, PlannedFault, faultScope and FiredFault. DrawFaults would then take the keys.
| return nil, fmt.Errorf("%w: FaultInjection = false", ErrNoFaults) | ||
| } | ||
| // Such a test asserts the retries it causes itself, so an extra retry changes its output. | ||
| if pattern, set := config.SuppressLines["warn_retry"]; set && pattern == "" { |
There was a problem hiding this comment.
[AI Generated] Tests using kill_after.py, fault.py or /__testserver still get fault runs; in selftest/kill_caller/offset a retried fault shifts the kill window. Could these tests opt out, or be excluded automatically like warn_retry = ""?
| switch kind { | ||
| case FaultGatewayTimeoutLate: | ||
| s.writeResponse(w, request, faultStatusResponses[FaultGatewayTimeout]) | ||
| case FaultReset, FaultResetLate: |
There was a problem hiding this comment.
[AI Generated] reset and eof-after reimplement testproxy's resetConnection, truncateResponse and hijack (libs/testproxy/server.go:294-323), and testproxy already imports testserver. Could testserver export one shared helper that both use?
Changes
A fault mode for acceptance tests that checks that the CLI and the tests survive a single backend error. With
go test ./acceptance -faultcount N, each test that passes runs again as subtestsfault=1tofault=N, each with one request failed, and must produce the same outputs.-faultcount allruns every request with every fault kind.SuppressLines.warn_retry, and the failed attempt is dropped fromout.requests.txt, as the cloud proxy already does.GET /api/2.0/workspace/get-status #3. The pairs of request and kind are ordered by a hash of the seed, the test name and the pair. Sofault=kis the same fault on every run, whatever N is and whatever order the test made its requests in.-faultseeddefaults to the current git commit. Each fault run logs its fault and the exact command that reruns it.test.toml, inherited like other settings:FaultInjection = falsefor a test that pins the exact request sequence or injects faults itself;FaultSkip = ["GET /api/..."]for requests that must not be failed.SuppressLines.warn_retry = ""are left out automatically.[[Server]]stubs,RecordRequests) can have any request failed.replay_tfstate.py,browser.py, the selftest curls) sendX-Databricks-Test-No-Fault, and their requests are never failed.Why
Backend errors on real workspaces are the main source of flaky cloud tests, and of user-visible failures that a retry would have hidden. This finds requests the CLI does not retry without waiting for them to show up on cloud. A sweep over all tests found unretried 5xx and truncated-body errors on common calls, and non-idempotent retries in deployment history and in resource creates; #8253 addresses the GET 500 part.
CI runs it in a new
test-faultsjob (./task test-faults): on each push to main, one fault for every test; on pull requests, ten faults for each test the PR changes. The seed is the head commit, sogo test ./acceptance -run ... -faultcount Non that commit reproduces a failure. The job is not intest-result's needs, so it does not block merging while the CLI still fails on some faults.Tests
-faultcount 3onbundle/resources/jobs/update(4 variants): 11 fault runs pass. 1 fails on a 502 toGET bundle/enrollments:check, a real gap, and its printed rerun command reproduces it alone.-faultcount.-faultcount allon three tests on the shared testserver (cmd/workspace/import-export,create-scope,clusters-list): 1737 fault runs. 429, 503 and a reset before the request are retried every time. 500, 502, 504, 504 after the request and truncated bodies fail every time. A reset after the request fails 35 of 193 runs. No request without a token was failed.DATABRICKS_TEST_SELECT_CHANGED=50 ./task test-faults(as on PRs) on this branch selects the two changed selftests; see the example in the comments.This pull request and its description were written by Isaac.