Repository navigation
acc: cover workspace import/export on cloud, drop the integration equivalents - #8066
Conversation
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=0 unreleased=0 coverage=1 failing=0
|
✅ Integration test reportCommit: d74b851
Top 5 slowest tests (at least 2 minutes):
|
8b7c755 to
bd14bfc
Compare
There was a problem hiding this comment.
Automated review at bd14bfc. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) and 1 question(s) below.
This PR swaps the 14 integration/cmd/workspace tests for one Cloud = true acceptance test, acceptance/cmd/workspace/import-export, which reuses the import_dir fixtures. The port looks faithful: the overwrite and no-overwrite paths, the AUTO detection and the zip error are all asserted, and the --log-file change keeps the old empty-stderr check. Four smaller things are left. The global \ → / replacement can hide backslashes in remote paths on Windows, the cleanup trap uses || true, the jq projections are inline where the testing rules want shared helpers, and the header-only export check shows nothing in the golden.
Questions
- The script runs all 14 ported scenarios in one directory under
set -e, so the first failing step hides the results of every later one. The sections share little setup: each makes its ownmkdirssubdirectory, and only export-dir reads what import-dir created. Would splitting it into a few directories (import, export, import-dir, export-dir) be worth it, or is keeping one shared workspace directory per cloud run the better trade-off? (non-blocking)
bd14bfc to
037ac7b
Compare
|
🤖 Addressed the 4 comments of the automated review in 20b5db0. On the question about splitting into several directories: I kept one directory on purpose. export-dir reads what import-dir created, a single workspace directory keeps one setup and cleanup per cloud run, and each cloud run costs about 2 min. A failure under |
20b5db0 to
b07dcfc
Compare
…ivalents Move the 14 tests of integration/cmd/workspace (workspace list, import, export, import-dir, export-dir) to one Cloud = true acceptance test, acceptance/cmd/workspace/import-export, with the same fixtures. It runs locally against the testserver and on every cloud. cloud: TestAccept/cmd/workspace/import-export Co-authored-by: Isaac <no-reply@databricks.com>
…repare The \ -> / replacement now covers only the local paths export-dir and import-dir print, so a backslash in a workspace path still fails the test on Windows. The cleanup trap uses errcode, the jq projections live in helpers in script.prepare, and the header-only export check prints the exported headers. cloud: TestAccept/cmd/workspace/import-export Co-authored-by: Isaac <no-reply@databricks.com>
errcode was removed on main (#7975); best-effort deletes in cleanup traps use || true. cloud: TestAccept/cmd/workspace/import-export Co-authored-by: Isaac <no-reply@databricks.com>
b07dcfc to
d74b851
Compare
…t errors (databricks#8060) ## Changes `libs/testserver` stored a notebook in the format it was imported in and returned it unchanged on export. The real `/api/2.0/workspace/export` converts. The fake also accepted several imports the real API rejects. This PR makes the fake match the real API on these paths. Every expected response below was recorded against a real AWS workspace. Export (`libs/testserver/workspace_export.go`, new): - `format=SOURCE` (or no format) of a notebook imported from `.ipynb` returns source: the header line, cells separated by `COMMAND ----------` lines, and markdown cells and magic-command cells (`%sql`, ...) as `MAGIC` lines. - `format=JUPYTER` of a source notebook returns ipynb: one cell per `COMMAND` block, and `MAGIC %md` blocks become markdown cells. Of an ipynb notebook, it returns the notebook with `language_info.name` in lower case. - `format=SOURCE` of a source notebook imported without the header line adds the header line. - `format=JUPYTER` of a file returns 400 `Exporting a FILE asset at <path> in JUPYTER format is not supported.` Import (`handlers.go`, `fake_workspace.go`): - `format=SOURCE` without a language (which is what `databricks workspace import X --file Y` sends with neither `--language` nor `--format`) returns 400 `The zip archive contains no items.` The real API reads such content as a zip archive of notebooks. A non-empty zip returns an explicit "not supported" 500, since extracting archives is not modeled. - A notebook import over an existing object without overwrite is rejected on every route (`/workspace/import` SOURCE, JUPYTER and AUTO, legacy import-file, zip entries). Before, AUTO and import-file overwrote silently, so `workspace import-dir` without `--overwrite` replaced existing notebooks locally. The check now lives in `storeNotebook`. The messages are the recorded ones: - `/workspace/import`: `<notebook> already exists. Please pass overwrite=true to overwrite it.` - import-file: `Request failed for POST <path>: RESOURCE_ALREADY_EXISTS: <notebook> already exists. ...` - `format=JUPYTER` with a body that is not a Jupyter notebook returns an explicit "not supported" 500 instead of storing it. - A Jupyter notebook's object info (get-status, list) reports `PYTHON` whatever its metadata says, on both the JUPYTER import and import-file. Its exports use the content language instead: `language_info.name`, else the Databricks metadata language, else Python. That language sets the SOURCE comment syntax and the JUPYTER language metadata. Before, the fake reported the metadata language (for example `SQL`) in the object info. The new `Cloud = true` test `acceptance/cmd/workspace/import-jupyter-language` records this for R, Scala, SQL and Python kernels and for Databricks metadata, through both routes. - `GET /workspace/list?path=/` lists the root instead of returning 404. ## Why The next PR in this stack (databricks#8066) moves `integration/cmd/workspace` (14 tests, deprecated tree, see `integration/README.md`) to a `Cloud = true` acceptance test. These behaviors are what its local run needs to produce the same output as the cloud run. ## Tests - New unit tests in `libs/testserver/workspace_test.go`. Each one fails without the change (checked by reverting the production files). - `acceptance/cmd/workspace/import-jupyter-language` (`Cloud = true`): its output is identical locally and on AWS. `TestWorkspaceImportFileJupyter` used to assert `SQL` for a notebook with Databricks SQL metadata; it now asserts `PYTHON`, which is what AWS returned for that notebook. - The full local acceptance suite passes with no golden changes. - The cloud pin for these responses is the stacked acceptance test. Its `output.txt` is identical locally and on AWS. Judgment calls and limits (not modeled, unchanged from before): - a directory at a notebook's path, and `overwrite=true` replacing a FILE with a NOTEBOOK - `format=JUPYTER` export of a directory - formats other than SOURCE and JUPYTER, and cell metadata and outputs - The stored format is detected from the body. A SOURCE notebook whose text is itself a valid ipynb document exports as if it were Jupyter. Recording the import format on `FileEntry` would touch shared state that databricks#8018 rewrites. Dashboard: none (no failing test; prerequisite for the integration test port). This PR was created by the integration-deprecation loop. 🤖 AI agent (opus5.5, isaac_claude) This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
Stacked on #8060 (testserver: notebook export conversions and import errors). Review that one first; this PR's diff is against its branch.
Changes
Delete
integration/cmd/workspace(14 tests and their testdata). Add one acceptance test that covers all of them:acceptance/cmd/workspace/import-export. It isCloud = truewith noCloudEnvs, so it runs locally against the testserver and on every cloud. It reuses the integration tests'import_dirfixtures byte for byte. I added a new directory rather than extending one, because the nearest siblings (export-dir-*) are local-only stubs or dashboard-specific.workspace list /header, empty stderr--format JUPYTERhascells/metadata--filefor file, notebook, JUPYTER; empty stdout(skipped; already exists), local file kept--overwritereplaces the local file.ipynb), empty stderr with--log-level=debug--content+--languagecreates notebooks--file+--language; without either,The zip archive contains no items.--fileAUTO file vs notebookWhy
integration/is deprecated (seeintegration/README.mdand.agents/rules/testing.md). Acceptance tests withCloud = truekeep the cloud check and also run locally on every PR. Earlier batches: #6113, #6140, #6223, #6316, #7251.Coverage proof
Method:
-coverpkg=github.com/databricks/cli/.... Its blocks were compared with the per-test coverage of a full local acceptance run plus an AWS run of the new test.("product blocks" counts the raw blocks, harness blocks included. "all but 3" means every block except harness code and the 3 blocks below.)
Uncovered blocks: the same 3 in every test. All of them are reached only by the in-process test harness:
cmd/root/auth.go:222.3,223.1: thefactory == nilreturn inbindHostMetadataLogger. Onlymain.goregisters the factory, so only in-process test binaries (internal/testcli) take this branch. Acceptance tests run the built CLI.cmd/root/tree.go:54and:57:Tree.SetOutandTree.SetErr. Onlyinternal/testcli/runner.gocalls them, to capture output in-process.Assertion map
list /succeeds, header ID/Type/Language/Path, stderr emptyID Type Language Path,assert_emptycmp fixtures/script.sh,assert_emptyabcexact; notebook# Databricks notebook source\nexact; JUPYTER has cells/metadatacmpx2,{"has_cells":true,"has_metadata":true}--filewrites content, stdout empty (file, notebook, JUPYTER)assert_emptyon stdout,cmp, jqcatof each file,cmpof header-only fixtures(skipped; already exists)+local content;cmp fixtures/file-a.ipynbas source, stderr empty with debug loggingshowof 7 objects, debug log to--log-file,assert_emptyshowbefore and after for all 7 objects--language, AUTO, extension and content; zip errorshow(type, language, content),musterr+ error textworkspace delete --recursive, thenmusterr workspace get-statusThe deleted TestImportDir asserted empty stderr with
--log-level=debug. That only held because the in-process harness captured the command's stderr writer, while logs go to the process'sos.Stderr. The new test sends the debug log to--log-fileand asserts the command's stderr is empty.Runtime: the 14 integration tests took about 65 s of test time on AWS. The new acceptance test takes 84 s on AWS (local run) and about 1 s locally. In this PR's cloud CI it takes about 2 min on Linux and 2.5 min on Windows.
Judgment calls:
\\->/replacement for the local paths that export-dir and import-dir print.cloud:line in the last commit) ran the test on AWS, Azure and GCP, on Linux and Windows, and it passed everywhere.--overwritefails the test.Dashboard: none (the deleted tests were not failing).
This PR was created by the integration-deprecation loop.
🤖 AI agent (opus5.5, isaac_claude)
This pull request and its description were written by Isaac.