Skip to content

acceptance: capture more behavior of databricks api before changing it - #8192

Merged
pietern merged 3 commits into
mainfrom
api-pin-wire-behavior
Nov 30, 2026
Merged

pietern merged 3 commits into
mainfrom
api-pin-wire-behavior

Conversation

@pietern

@pietern pietern commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Changes

Acceptance tests that record what databricks api does today, as preparation for changing how the command sends its requests. New tests under acceptance/cmd/api/:

  • methods: the request sent for every method, with and without --json, including the Accept and Content-Type headers and where the JSON lands (query string for GET, HEAD and DELETE; body otherwise).
  • json: the shapes of --json input: inline, @file, @-, null, non-object values, a path that already has a query string, and how scalars and nested values are serialized on a GET.
  • response-json: how a JSON body is rendered, including empty bodies, 201 and 204, and -o text.
  • response-text: what happens to bodies that are not JSON (HTML, truncated JSON, CSV, an event stream). Today each is an error.
  • errors: how HTTP errors are rendered and their exit codes, and that 429 and 503 are retried while 500 is not.
  • url: how the PATH argument becomes a URL: absolute URLs are re-pointed at the profile host, percent-encoding is preserved, fragments are dropped.
  • flags: flag validation, and that curl-style flags (-H, --data, --query, -i) are rejected.
  • debug: the full --debug output for a GET, a POST and a 404.

The existing request-handling and response-handling tests are folded into json and the two response-* tests. The first commit only renames the existing tests so the directory reads as a table of contents (routing-*, profile-*); their goldens are unchanged.

Why

We want databricks api to cover the requests our docs show with curl today: a body on any method, non-JSON and streaming responses, response status and headers, custom headers. That means replacing the HTTP layer under the command. These goldens pin the current behavior first, so every change in later PRs shows up as a reviewed golden diff instead of a silent regression.

Several current behaviors that the goldens make visible, and that later PRs will change on purpose: nested --json values on a GET are serialized with Go's %v ([x y], map[k:true]); --json on a path that already has a query string produces a=1?b=2; Content-Type: application/json is sent on bodiless GET and HEAD requests; a non-JSON response is reported as an SDK bug.

Tests

The new tests and the existing api tests pass locally (go test ./acceptance -run TestAccept/cmd/api). No code changes, so no changelog fragment.

This pull request and its description were written by Isaac.

pietern and others added 2 commits November 30, 2026 10:03
Group the routing tests under a `routing-` prefix and the profile tests under
`profile-`, and name the --json flag test `json`. The scripts and goldens are
unchanged.

Co-authored-by: Isaac <no-reply@databricks.com>
Before the HTTP layer under `databricks api` is replaced, record what the
command does today: the request sent for every method with and without
--json (methods), the shapes of --json input (json), how JSON bodies are
rendered (response-json) and what happens to other bodies (response-text),
how HTTP errors are rendered and which are retried (errors), how the PATH
argument becomes a URL (url), flag validation (flags), and the --debug
output (debug).

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the test-only-fix PRs that update failing of flaky tests without changing CLI code. label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: cd0327b1b | Workflow run

Selected 18 changed tests (limit=20, 0 not selected)

18 tests: regression=0 unreleased=1 coverage=17 failing=0
test branch main (18fb21e) latest (v1.28.0)
TestAccept/cmd/api/debug ✅ ✅ ❌
TestAccept/cmd/api/errors ✅ ✅ ✅
TestAccept/cmd/api/flags ✅ ✅ ✅
TestAccept/cmd/api/json ✅ ✅ ✅
TestAccept/cmd/api/methods ✅ ✅ ✅
TestAccept/cmd/api/profile-default ✅ ✅ ✅
TestAccept/cmd/api/profile-default-vs-env ✅ ✅ ✅
TestAccept/cmd/api/response-json ✅ ✅ ✅
TestAccept/cmd/api/response-text ✅ ✅ ✅
TestAccept/cmd/api/routing-account-flag ✅ ✅ ✅
TestAccept/cmd/api/routing-account-path ✅ ✅ ✅
TestAccept/cmd/api/routing-accounts-proxy-path ✅ ✅ ✅
TestAccept/cmd/api/routing-workspace-id-flag ✅ ✅ ✅
TestAccept/cmd/api/routing-workspace-id-none ✅ ✅ ✅
TestAccept/cmd/api/routing-workspace-id-query-o ✅ ✅ ✅
TestAccept/cmd/api/routing-workspace-id-query-w ✅ ✅ ✅
TestAccept/cmd/api/routing-workspace-path ✅ ✅ ✅
TestAccept/cmd/api/url ✅ ✅ ✅
TestAccept/cmd/api/debug: branch ✅ | main (18fb21e) ✅ | latest (v1.28.0) ❌

latest (v1.28.0):

acceptance_test.go:1348: Suppressed from output.txt:
        HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/echo, --json, {\"id\": 7}, --debug"
        HH:MM:SS Info: completed execution pid=PID exit_code=0
        HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, post, /api/2.0/test/echo, --json, {\"id\": 7}, --debug"
        HH:MM:SS Info: completed execution pid=PID exit_code=0
        HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/err404, --debug"
        HH:MM:SS Info: failed execution pid=PID exit_code=1 error="Not found"
    acceptance_test.go:1348: Suppressed from output.txt:
        HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID
        HH:MM:SS Debug: [Local Cache] cache hit pid=PID
        HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID
        HH:MM:SS Debug: [Local Cache] cache hit pid=PID
        HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID
        HH:MM:SS Debug: [Local Cache] cache hit pid=PID
    acceptance_test.go:1348: Suppressed from output.txt:
        HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true
        HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true
        HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true
        HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true
        HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true
        HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true
        HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true
        HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true
        HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true
    acceptance_test.go:1348: Suppressed from output.txt:
        HH:MM:SS Debug: no telemetry logs to upload pid=PID
        HH:MM:SS Debug: no telemetry logs to upload pid=PID
        HH:MM:SS Debug: no telemetry logs to upload pid=PID
    acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== GET with --json\n\n>>> [CLI] api get /api/2.0/test/echo --json {\"id\": 7} --debug\nHH:MM:SS Debug: GET /api/2.0/test/echo?id=7\n< HTTP/1.1 200 OK\n< {\n<   \"ok\": true\n< } pid=PID sdk=true\n{\n  \"ok\": true\n}\n\n=== POST with --json\n\n>>> [CLI] api post /api/2.0/test/echo --json {\"id\": 7} --debug\nHH:MM:SS Debug: POST /api/2.0/test/echo\n> {\n>   \"id\": 7\n> }\n< HTTP/1.1 200 OK\n< {\n<   \"ok\": true\n< } pid=PID sdk=true\n{\n  \"ok\": true\n}\n\n=== Error response\nHH:MM:SS Debug: GET /api/2.0/test/err404\n< HTTP/1.1 404 Not Found\n< {\n<   \"error_code\": \"RESOURCE_DOES_NOT_EXIST\",\n<   \"message\": \"Not found\"\n< } pid=PID sdk=true\nHH:MM:SS Debug: non-retriable error: Not found pid=PID sdk=true\nError: Not found\n"
        	            	actual  : "\n=== GET with --json\n\n>>> [CLI] api get /api/2.0/test/echo --json {\"id\": 7} --debug\nHH:MM:SS Debug: GET /api/2.0/test/echo?id=7\n< HTTP/1.1 200 OK\n< {\n<   \"ok\": true\n< } pid=PID sdk=true\n{\n  \"ok\": true\n}\nHH:MM:SS Debug: auto-install: skipped: already_ran pid=PID\n\n=== POST with --json\n\n>>> [CLI] api post /api/2.0/test/echo --json {\"id\": 7} --debug\nHH:MM:SS Debug: POST /api/2.0/test/echo\n> {\n>   \"id\": 7\n> }\n< HTTP/1.1 200 OK\n< {\n<   \"ok\": true\n< } pid=PID sdk=true\n{\n  \"ok\": true\n}\nHH:MM:SS Debug: auto-install: skipped: already_ran pid=PID\n\n=== Error response\nHH:MM:SS Debug: GET /api/2.0/test/err404\n< HTTP/1.1 404 Not Found\n< {\n<   \"error_code\": \"RESOURCE_DOES_NOT_EXIST\",\n<   \"message\": \"Not found\"\n< } pid=PID sdk=true\nHH:MM:SS Debug: non-retriable error: Not found pid=PID sdk=true\nError: Not found\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -12,2 +12,3 @@
        	            	 }
        	            	+HH:MM:SS Debug: auto-install: skipped: already_ran pid=PID
        	            	 
        	            	@@ -27,2 +28,3 @@
        	            	 }
        	            	+HH:MM:SS Debug: auto-install: skipped: already_ran pid=PID
        	            	 
        	Test:       	TestAccept/cmd/api/debug
        	Messages:   	cmd/api/debug/output.txt vs /tmp/TestAcceptcmdapidebug1560984899/002/output.txt

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: cd0327b

Run: 46406400302

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 118 28 2:41
💚​ aws-windows-latest-4core-16gb 1 118 28 2:54
💚​ azure linux-2core-8gb 1 117 28 2:56
💚​ azure-windows-latest-4core-16gb 1 117 28 2:52
💚​ gcp linux-2core-8gb 1 118 28 2:45
💚​ gcp-windows-latest-4core-16gb 1 118 28 3:07
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:05 gcp-windows-latest-4core-16gb TestAccept
2:52 aws-windows-latest-4core-16gb TestAccept
2:51 azure-windows-latest-4core-16gb TestAccept

@pietern
pietern marked this pull request as ready for review November 30, 2026 10:50
@pietern
pietern requested a review from a team as a code owner November 30, 2026 10:50
@pietern
pietern enabled auto-merge November 30, 2026 10:50

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 2efc3be. Each finding was verified against the code.

No blocking issues found. 3 non-blocking comment(s) below.

This PR reorganizes the databricks api acceptance tests and adds goldens for methods, --json shapes, response rendering, errors, URL handling, flags and --debug, so a later rewrite of the HTTP layer shows up as golden diffs. It changes no production code. A few cases can't catch the regressions they're named for: the Content-Type contrast in response-json doesn't exist, the percent-encoding case only sees decoded values, and the debug golden mostly pins SDK log lines. Fixing these would make the safety net hold where the follow-up will need it.

Comment thread acceptance/cmd/api/url/script Resolved
Comment thread acceptance/cmd/api/debug/output.txt Resolved
Review follow-ups. The JSON fixtures set Content-Type explicitly: a string
body gets no header from the test server and net/http sniffs it as text/plain,
so the text/plain case was no contrast. The percent-encoding case is retitled
to what the decoded recording can show. The debug golden keeps only the
request and response dump; the CLI lifecycle, local cache, resolved config and
telemetry lines go to the test log, and the host-metadata cache is warmed so
the discovery exchange does not appear in the first case only.

Co-authored-by: Isaac <no-reply@databricks.com>
@pietern
pietern added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 3d6d09a Nov 30, 2026
27 checks passed
@pietern
pietern deleted the api-pin-wire-behavior branch November 30, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-only-fix PRs that update failing of flaky tests without changing CLI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants