Repository navigation
acceptance: capture more behavior of databricks api before changing it - #8192
Conversation
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>
Regression test report ✅Commit: Selected 18 changed tests (limit=20, 0 not selected) 18 tests: regression=0 unreleased=1 coverage=17 failing=0
TestAccept/cmd/api/debug: branch ✅ | main (18fb21e) ✅ | latest (v1.28.0) ❌latest (v1.28.0): |
✅ Integration test reportCommit: cd0327b
Top 3 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
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.
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>
Changes
Acceptance tests that record what
databricks apidoes today, as preparation for changing how the command sends its requests. New tests underacceptance/cmd/api/:methods: the request sent for every method, with and without--json, including theAcceptandContent-Typeheaders and where the JSON lands (query string for GET, HEAD and DELETE; body otherwise).json: the shapes of--jsoninput: 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--debugoutput for a GET, a POST and a 404.The existing
request-handlingandresponse-handlingtests are folded intojsonand the tworesponse-*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 apito 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
--jsonvalues on a GET are serialized with Go's%v([x y],map[k:true]);--jsonon a path that already has a query string producesa=1?b=2;Content-Type: application/jsonis 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.