Skip to content

acc: cover workspace import/export on cloud, drop the integration equivalents - #8066

Merged
denik merged 3 commits into
mainfrom
denik/intdep-workspace-port
Nov 30, 2026
Merged

denik merged 3 commits into
mainfrom
denik/intdep-workspace-port

Conversation

@denik

@denik denik commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 is Cloud = true with no CloudEnvs, so it runs locally against the testserver and on every cloud. It reuses the integration tests' import_dir fixtures 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.

deleted integration test verdict covered by
TestWorkspaceList PORTED import-export: workspace list / header, empty stderr
TestWorkpaceExportPrintsContents PORTED import-export: export to stdout is byte-identical, empty stderr
TestExport PORTED import-export: file and notebook export are byte-identical, --format JUPYTER has cells/metadata
TestExportWithFileFlag PORTED import-export: --file for file, notebook, JUPYTER; empty stdout
TestExportDir PORTED import-export: export-dir log lines, contents per language, header-only notebooks, empty stderr
TestExportDirDoesNotOverwrite PORTED import-export: (skipped; already exists), local file kept
TestExportDirWithOverwriteFlag PORTED import-export: --overwrite replaces the local file
TestImportDir PORTED import-export: import-dir log lines, type, language and content of all 7 objects (incl. .ipynb), empty stderr with --log-level=debug
TestImportDirDoesNotOverwrite PORTED import-export: seeds read back, skips, all 7 objects read after
TestImportDirWithOverwriteFlag PORTED import-export: seeds read back, replaced, all 7 objects read after
TestImportFileUsingContentFormatSource PORTED import-export: --content + --language creates notebooks
TestImportFileUsingContentFormatAuto PORTED import-export: AUTO file vs notebook by extension and content
TestImportFileFormatSource PORTED import-export: --file + --language; without either, The zip archive contains no items.
TestImportFileFormatAuto PORTED import-export: --file AUTO file vs notebook

Why

integration/ is deprecated (see integration/README.md and .agents/rules/testing.md). Acceptance tests with Cloud = true keep the cloud check and also run locally on every PR. Earlier batches: #6113, #6140, #6223, #6316, #7251.

Coverage proof

Method:

  • Blocks: each integration test was run alone on AWS with -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.
  • Assertions: every assertion of the deleted tests is mapped to a line of the new test's output (details below).
integration test verdict product blocks covered acceptance tests (minimal set)
TestExport PORTED 1023 all but 3 bundle/run/app-with-job, cmd/aitools/telemetry/hint (+ import-export for the assertions)
TestExportDir PORTED 986 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestExportDirDoesNotOverwrite PORTED 963 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestExportDirWithOverwriteFlag PORTED 972 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestExportWithFileFlag PORTED 899 all but 3 bundle/sync/zip-extract, cmd/workspace/import-export, cmd/aitools/telemetry/hint
TestImportDir PORTED 1040 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestImportDirDoesNotOverwrite PORTED 1002 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestImportDirWithOverwriteFlag PORTED 992 all but 3 cmd/workspace/import-export, bundle/resources/job_runs/wait, cmd/aitools/telemetry/hint
TestImportFileFormatAuto PORTED 915 all but 3 bundle/invariant/migrate, cmd/aitools/telemetry/hint, cmd/workspace/import-export
TestImportFileFormatSource PORTED 945 all but 3 bundle/generate/auto-bind, cmd/workspace/import-export, cmd/aitools/telemetry/hint
TestImportFileUsingContentFormatAuto PORTED 913 all but 3 bundle/invariant/migrate, cmd/aitools/telemetry/hint, cmd/workspace/import-export
TestImportFileUsingContentFormatSource PORTED 913 all but 3 bundle/invariant/migrate, cmd/aitools/telemetry/hint, cmd/workspace/import-export
TestWorkpaceExportPrintsContents PORTED 920 all but 3 bundle/sync/zip-extract, cmd/aitools/telemetry/hint (+ import-export for the assertions)
TestWorkspaceList PORTED 894 all but 3 cmd/workspace/import-export, cmd/aitools/telemetry/hint, cmd/sync/upload-504

("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: the factory == nil return in bindHostMetadataLogger. Only main.go registers the factory, so only in-process test binaries (internal/testcli) take this branch. Acceptance tests run the built CLI.
  • cmd/root/tree.go:54 and :57: Tree.SetOut and Tree.SetErr. Only internal/testcli/runner.go calls them, to capture output in-process.
Assertion map
integration test fact acceptance check where
TestWorkspaceList list / succeeds, header ID/Type/Language/Path, stderr empty ID Type Language Path, assert_empty local + cloud
TestWorkpaceExportPrintsContents export prints the file byte for byte, stderr empty cmp fixtures/script.sh, assert_empty local + cloud
TestExport file abc exact; notebook # Databricks notebook source\n exact; JUPYTER has cells/metadata cmp x2, {"has_cells":true,"has_metadata":true} local + cloud
TestExportWithFileFlag --file writes content, stdout empty (file, notebook, JUPYTER) assert_empty on stdout, cmp, jq local + cloud
TestExportDir log lines in order, notebook extensions, contents, header-only notebooks, stderr empty export-dir block, cat of each file, cmp of header-only fixtures local + cloud
TestExportDirDoesNotOverwrite / WithOverwriteFlag local file kept / replaced (skipped; already exists) + local content; cmp fixtures/file-a local + cloud
TestImportDir log lines, contents of all objects incl. .ipynb as source, stderr empty with debug logging import-dir block, show of 7 objects, debug log to --log-file, assert_empty local + cloud
TestImportDirDoesNotOverwrite / WithOverwriteFlag seeds present before; others imported; seeds kept / replaced show before and after for all 7 objects local + cloud
TestImportFileUsingContent* / TestImportFileFormat* notebook vs file by --language, AUTO, extension and content; zip error show (type, language, content), musterr + error text local + cloud
cleanup test dir removed workspace delete --recursive, then musterr workspace get-status local + cloud

The 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's os.Stderr. The new test sends the debug log to --log-file and 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:

  • Windows: the test runs on Windows with a \\ -> / replacement for the local paths that export-dir and import-dir print.
  • Cloud: the integration tests have no per-cloud branches. This PR's cloud CI (cloud: line in the last commit) ran the test on AWS, Azure and GCP, on Linux and Windows, and it passed everywhere.
  • Mutation check: making export-dir or import-dir ignore --overwrite fails 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.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: d74b85186 | Workflow run

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

1 tests: regression=0 unreleased=0 coverage=1 failing=0
test branch main (18fb21e) latest (v1.28.0)
TestAccept/cmd/workspace/import-export ✅ ✅ ✅

@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: d74b851

Run: 46406892600

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 105 10 3:01
💚​ aws-windows-latest-4core-16gb 1 105 10 5:15
💚​ azure linux-2core-8gb 1 104 10 3:18
💚​ azure-windows-latest-4core-16gb 1 104 10 5:07
💚​ gcp linux-2core-8gb 1 105 10 3:05
💚​ gcp-windows-latest-4core-16gb 1 105 10 4:34
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 5 slowest tests (at least 2 minutes):
duration env testname
3:01 aws-windows-latest-4core-16gb TestAccept
2:52 azure-windows-latest-4core-16gb TestAccept
2:32 gcp-windows-latest-4core-16gb TestAccept
2:12 azure-windows-latest-4core-16gb TestAccept/cmd/workspace/import-export
2:11 aws-windows-latest-4core-16gb TestAccept/cmd/workspace/import-export

@denik
denik force-pushed the denik/intdep-workspace-port branch 2 times, most recently from 8b7c755 to bd14bfc Compare November 26, 2026 16:13
@denik
denik marked this pull request as ready for review November 26, 2026 16:36
@denik
denik requested review from a team as code owners November 26, 2026 16:36
@denik
denik requested review from Sankalp-Mittal, andrewnester and rauchy and removed request for rauchy November 26, 2026 16:36

@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 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

  1. 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 own mkdirs subdirectory, 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)

@denik
denik force-pushed the denik/intdep-workspace-port branch from bd14bfc to 037ac7b Compare November 26, 2026 16:48
@denik

denik commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

🤖 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 set -e still points at the exact step in the golden diff, and the sections run in a fixed order, so a second failure shows up on the rerun. If you'd rather have them split, I can do that in a follow-up. AI agent (opus5.5, isaac_claude)

@denik
denik requested a review from andrewnester November 26, 2026 17:14
@denik
denik force-pushed the denik/intdep-workspace-port branch from 20b5db0 to b07dcfc Compare November 26, 2026 23:58
Base automatically changed from denik/intdep-workspace-testserver to main November 30, 2026 11:06
denik and others added 3 commits November 30, 2026 11:07
…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>
@denik
denik force-pushed the denik/intdep-workspace-port branch from b07dcfc to d74b851 Compare November 30, 2026 11:10
@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
@denik
denik enabled auto-merge November 30, 2026 11:10
@denik
denik added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit dd0570d Nov 30, 2026
27 checks passed
@denik
denik deleted the denik/intdep-workspace-port branch November 30, 2026 11:44
stevenayers pushed a commit to stevenayers/cli that referenced this pull request Nov 30, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory-generated 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