From f6c7ebc2b3010246c47841588f242754db65a2d7 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Thu, 26 Nov 2026 17:24:49 +0000 Subject: [PATCH 1/5] acc: cover tag limits, SQL execution and telemetry upload on cloud, drop the integration equivalents Replace integration/libs/tags (6 tests), integration/libs/telemetry (1) and three of the six integration/libs/sqlexec tests with acceptance tests that run locally and, for backend facts, on every cloud. cloud: TestAccept/workspace/jobs/tag-limits TestAccept/telemetry/upload-cloud cloud: TestAccept/experimental/aitools/tools/query TestAccept/experimental/aitools/tools/statement Co-authored-by: Isaac --- .../tools/query/columns-rows/out.test.toml | 1 + .../tools/query/columns-rows/output.txt | 6 + .../aitools/tools/query/columns-rows/script | 1 + .../tools/query/columns-rows/test.toml | 11 + .../query/failed-statement/out.test.toml | 1 + .../tools/query/failed-statement/output.txt | 2 + .../tools/query/failed-statement/script | 6 + .../tools/query/failed-statement/test.toml | 16 ++ .../tools/query/null-parameter/out.test.toml | 1 + .../tools/query/null-parameter/output.txt | 9 + .../aitools/tools/query/null-parameter/script | 5 + .../tools/query/null-parameter/test.toml | 12 + .../tools/query/parameters/out.test.toml | 1 + .../aitools/tools/query/parameters/output.txt | 9 + .../aitools/tools/query/parameters/script | 4 + .../aitools/tools/query/parameters/test.toml | 12 + .../aitools/tools/query/scalar/out.test.toml | 1 + .../aitools/tools/query/scalar/output.txt | 4 + .../aitools/tools/query/scalar/script | 1 + .../aitools/tools/query/scalar/test.toml | 11 + .../aitools/tools/query/script.prepare | 8 + .../aitools/tools/query/test.toml | 3 + .../aitools/tools/statement/script.prepare | 8 + .../statement/submit-cancel/out.test.toml | 1 + .../tools/statement/submit-cancel/output.txt | 25 ++ .../tools/statement/submit-cancel/script | 14 + .../tools/statement/submit-cancel/test.toml | 1 + .../aitools/tools/statement/test.toml | 3 + .../show/failed-statement/out.test.toml | 1 + .../show/failed-statement/output.txt | 3 + .../pipelines/show/failed-statement/script | 4 + .../pipelines/show/failed-statement/test.toml | 1 + .../telemetry/upload-cloud/out.test.toml | 1 + acceptance/telemetry/upload-cloud/output.txt | 11 + acceptance/telemetry/upload-cloud/script | 22 ++ acceptance/telemetry/upload-cloud/test.toml | 4 + .../workspace/jobs/tag-limits/out.test.toml | 1 + .../workspace/jobs/tag-limits/output.txt | 7 + acceptance/workspace/jobs/tag-limits/script | 114 ++++++++ .../workspace/jobs/tag-limits/test.toml | 2 + integration/libs/sqlexec/sqlexec_test.go | 42 --- integration/libs/tags/tags_test.go | 250 ------------------ integration/libs/telemetry/telemetry_test.go | 75 ------ internal/testutil/cloud.go | 7 - internal/testutil/requirement.go | 15 -- 45 files changed, 348 insertions(+), 389 deletions(-) create mode 100644 acceptance/experimental/aitools/tools/query/columns-rows/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/query/columns-rows/output.txt create mode 100644 acceptance/experimental/aitools/tools/query/columns-rows/script create mode 100644 acceptance/experimental/aitools/tools/query/columns-rows/test.toml create mode 100644 acceptance/experimental/aitools/tools/query/failed-statement/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/query/failed-statement/output.txt create mode 100644 acceptance/experimental/aitools/tools/query/failed-statement/script create mode 100644 acceptance/experimental/aitools/tools/query/failed-statement/test.toml create mode 100644 acceptance/experimental/aitools/tools/query/null-parameter/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/query/null-parameter/output.txt create mode 100644 acceptance/experimental/aitools/tools/query/null-parameter/script create mode 100644 acceptance/experimental/aitools/tools/query/null-parameter/test.toml create mode 100644 acceptance/experimental/aitools/tools/query/parameters/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/query/parameters/output.txt create mode 100644 acceptance/experimental/aitools/tools/query/parameters/script create mode 100644 acceptance/experimental/aitools/tools/query/parameters/test.toml create mode 100644 acceptance/experimental/aitools/tools/query/scalar/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/query/scalar/output.txt create mode 100644 acceptance/experimental/aitools/tools/query/scalar/script create mode 100644 acceptance/experimental/aitools/tools/query/scalar/test.toml create mode 100644 acceptance/experimental/aitools/tools/query/script.prepare create mode 100644 acceptance/experimental/aitools/tools/query/test.toml create mode 100644 acceptance/experimental/aitools/tools/statement/script.prepare create mode 100644 acceptance/experimental/aitools/tools/statement/submit-cancel/out.test.toml create mode 100644 acceptance/experimental/aitools/tools/statement/submit-cancel/output.txt create mode 100644 acceptance/experimental/aitools/tools/statement/submit-cancel/script create mode 100644 acceptance/experimental/aitools/tools/statement/submit-cancel/test.toml create mode 100644 acceptance/experimental/aitools/tools/statement/test.toml create mode 100644 acceptance/pipelines/show/failed-statement/out.test.toml create mode 100644 acceptance/pipelines/show/failed-statement/output.txt create mode 100644 acceptance/pipelines/show/failed-statement/script create mode 100644 acceptance/pipelines/show/failed-statement/test.toml create mode 100644 acceptance/telemetry/upload-cloud/out.test.toml create mode 100644 acceptance/telemetry/upload-cloud/output.txt create mode 100644 acceptance/telemetry/upload-cloud/script create mode 100644 acceptance/telemetry/upload-cloud/test.toml create mode 100644 acceptance/workspace/jobs/tag-limits/out.test.toml create mode 100644 acceptance/workspace/jobs/tag-limits/output.txt create mode 100644 acceptance/workspace/jobs/tag-limits/script create mode 100644 acceptance/workspace/jobs/tag-limits/test.toml delete mode 100644 integration/libs/tags/tags_test.go delete mode 100644 integration/libs/telemetry/telemetry_test.go delete mode 100644 internal/testutil/requirement.go diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/out.test.toml b/acceptance/experimental/aitools/tools/query/columns-rows/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/columns-rows/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/output.txt b/acceptance/experimental/aitools/tools/query/columns-rows/output.txt new file mode 100644 index 00000000000..70c47e20bc2 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/columns-rows/output.txt @@ -0,0 +1,6 @@ + +>>> [CLI] experimental aitools tools query --output csv SELECT id, id * 2 AS doubled FROM range(3) ORDER BY id +id,doubled +0,0 +1,2 +2,4 diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/script b/acceptance/experimental/aitools/tools/query/columns-rows/script new file mode 100644 index 00000000000..a7482a2fef4 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/columns-rows/script @@ -0,0 +1 @@ +trace $CLI experimental aitools tools query --output csv "SELECT id, id * 2 AS doubled FROM range(3) ORDER BY id" diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/test.toml b/acceptance/experimental/aitools/tools/query/columns-rows/test.toml new file mode 100644 index 00000000000..26b976ffffa --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/columns-rows/test.toml @@ -0,0 +1,11 @@ + +[[Server]] +Pattern = "POST /api/2.0/sql/statements" +Response.Body = ''' +{ + "statement_id": "s1", + "status": {"state": "SUCCEEDED"}, + "manifest": {"schema": {"columns": [{"name": "id"}, {"name": "doubled"}]}, "total_chunk_count": 1}, + "result": {"data_array": [["0", "0"], ["1", "2"], ["2", "4"]]} +} +''' diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/out.test.toml b/acceptance/experimental/aitools/tools/query/failed-statement/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/failed-statement/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/output.txt b/acceptance/experimental/aitools/tools/query/failed-statement/output.txt new file mode 100644 index 00000000000..1d13fd5c09c --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/failed-statement/output.txt @@ -0,0 +1,2 @@ +query failed: BAD_REQUEST [TABLE_OR_VIEW_NOT_FOUND] The table or view `a_table_that_does_not_exist_zzz` cannot be found +SQLSTATE: 42P01 diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/script b/acceptance/experimental/aitools/tools/query/failed-statement/script new file mode 100644 index 00000000000..911858d18fc --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/failed-statement/script @@ -0,0 +1,6 @@ +# The real message goes on with advice and the workspace's search path; keep the +# stable parts: error code, error class, the relation and the SQLSTATE. +musterr $CLI experimental aitools tools query --output csv "SELECT * FROM a_table_that_does_not_exist_zzz" 2> err.txt +grep -o 'query failed: BAD_REQUEST \[TABLE_OR_VIEW_NOT_FOUND\] The table or view `a_table_that_does_not_exist_zzz` cannot be found' err.txt +grep -o 'SQLSTATE: [0-9A-Z]*' err.txt +rm err.txt diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/test.toml b/acceptance/experimental/aitools/tools/query/failed-statement/test.toml new file mode 100644 index 00000000000..470fd44526d --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/failed-statement/test.toml @@ -0,0 +1,16 @@ + +[[Server]] +Pattern = "POST /api/2.0/sql/statements" +Response.Body = ''' +{ + "statement_id": "s1", + "status": { + "state": "FAILED", + "sql_state": "42P01", + "error": { + "error_code": "BAD_REQUEST", + "message": "[TABLE_OR_VIEW_NOT_FOUND] The table or view `a_table_that_does_not_exist_zzz` cannot be found. Verify the spelling and correctness of the schema and catalog.\nSearch path: [`system`.`session`, `system`.`builtin`].\nSQLSTATE: 42P01; line 1 pos 14" + } + } +} +''' diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/out.test.toml b/acceptance/experimental/aitools/tools/query/null-parameter/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/null-parameter/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/output.txt b/acceptance/experimental/aitools/tools/query/null-parameter/output.txt new file mode 100644 index 00000000000..a72c563ceef --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/null-parameter/output.txt @@ -0,0 +1,9 @@ + +>>> [CLI] experimental aitools tools query --output csv --param maybe= SELECT :maybe IS NULL AS is_null +is_null +true + +=== parameters on the wire + +>>> print_requests.py //api/2.0/sql/statements +[{"name":"maybe"}] diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/script b/acceptance/experimental/aitools/tools/query/null-parameter/script new file mode 100644 index 00000000000..183fab11695 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/null-parameter/script @@ -0,0 +1,5 @@ +# An empty value is sent without a value, which the API binds as SQL NULL. +trace $CLI experimental aitools tools query --output csv --param maybe= "SELECT :maybe IS NULL AS is_null" + +title "parameters on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -c .body.parameters diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/test.toml b/acceptance/experimental/aitools/tools/query/null-parameter/test.toml new file mode 100644 index 00000000000..72bb66d8101 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/null-parameter/test.toml @@ -0,0 +1,12 @@ +RecordRequests = true + +[[Server]] +Pattern = "POST /api/2.0/sql/statements" +Response.Body = ''' +{ + "statement_id": "s1", + "status": {"state": "SUCCEEDED"}, + "manifest": {"schema": {"columns": [{"name": "is_null"}]}, "total_chunk_count": 1}, + "result": {"data_array": [["true"]]} +} +''' diff --git a/acceptance/experimental/aitools/tools/query/parameters/out.test.toml b/acceptance/experimental/aitools/tools/query/parameters/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/parameters/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/query/parameters/output.txt b/acceptance/experimental/aitools/tools/query/parameters/output.txt new file mode 100644 index 00000000000..996b5d29ed4 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/parameters/output.txt @@ -0,0 +1,9 @@ + +>>> [CLI] experimental aitools tools query --output csv --param n:INT=42 --param s=hello SELECT :n AS n, :s AS s +n,s +42,hello + +=== parameters on the wire + +>>> print_requests.py //api/2.0/sql/statements +[{"name":"n","type":"INT","value":"42"},{"name":"s","value":"hello"}] diff --git a/acceptance/experimental/aitools/tools/query/parameters/script b/acceptance/experimental/aitools/tools/query/parameters/script new file mode 100644 index 00000000000..ea573e3809c --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/parameters/script @@ -0,0 +1,4 @@ +trace $CLI experimental aitools tools query --output csv --param n:INT=42 --param s=hello "SELECT :n AS n, :s AS s" + +title "parameters on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -c .body.parameters diff --git a/acceptance/experimental/aitools/tools/query/parameters/test.toml b/acceptance/experimental/aitools/tools/query/parameters/test.toml new file mode 100644 index 00000000000..c38b5abaff1 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/parameters/test.toml @@ -0,0 +1,12 @@ +RecordRequests = true + +[[Server]] +Pattern = "POST /api/2.0/sql/statements" +Response.Body = ''' +{ + "statement_id": "s1", + "status": {"state": "SUCCEEDED"}, + "manifest": {"schema": {"columns": [{"name": "n"}, {"name": "s"}]}, "total_chunk_count": 1}, + "result": {"data_array": [["42", "hello"]]} +} +''' diff --git a/acceptance/experimental/aitools/tools/query/scalar/out.test.toml b/acceptance/experimental/aitools/tools/query/scalar/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/scalar/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/query/scalar/output.txt b/acceptance/experimental/aitools/tools/query/scalar/output.txt new file mode 100644 index 00000000000..b09b4aa11c3 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/scalar/output.txt @@ -0,0 +1,4 @@ + +>>> [CLI] experimental aitools tools query --output csv SELECT 1 +1 +1 diff --git a/acceptance/experimental/aitools/tools/query/scalar/script b/acceptance/experimental/aitools/tools/query/scalar/script new file mode 100644 index 00000000000..f8315d943da --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/scalar/script @@ -0,0 +1 @@ +trace $CLI experimental aitools tools query --output csv "SELECT 1" diff --git a/acceptance/experimental/aitools/tools/query/scalar/test.toml b/acceptance/experimental/aitools/tools/query/scalar/test.toml new file mode 100644 index 00000000000..7de6ec22772 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/scalar/test.toml @@ -0,0 +1,11 @@ + +[[Server]] +Pattern = "POST /api/2.0/sql/statements" +Response.Body = ''' +{ + "statement_id": "s1", + "status": {"state": "SUCCEEDED"}, + "manifest": {"schema": {"columns": [{"name": "1"}]}, "total_chunk_count": 1}, + "result": {"data_array": [["1"]]} +} +''' diff --git a/acceptance/experimental/aitools/tools/query/script.prepare b/acceptance/experimental/aitools/tools/query/script.prepare new file mode 100644 index 00000000000..919c3f8a1c3 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/script.prepare @@ -0,0 +1,8 @@ +# Like the integration tests these replace, run on cloud only on Unity Catalog +# workspaces: the shared classic warehouses of the non-UC ones are unreliable to +# start, and CloudEnvs cannot tell azure-prod-ucws from azure-prod. +if [ -n "${CLOUD_ENV:-}" ] && { [ -z "${TEST_METASTORE_ID:-}" ] || [ -z "${TEST_DEFAULT_WAREHOUSE_ID:-}" ]; }; then + echo "SKIP_TEST: needs a Unity Catalog workspace with a warehouse (TEST_METASTORE_ID, TEST_DEFAULT_WAREHOUSE_ID)" + exit 0 +fi +export DATABRICKS_WAREHOUSE_ID=$TEST_DEFAULT_WAREHOUSE_ID diff --git a/acceptance/experimental/aitools/tools/query/test.toml b/acceptance/experimental/aitools/tools/query/test.toml new file mode 100644 index 00000000000..856b5ed4668 --- /dev/null +++ b/acceptance/experimental/aitools/tools/query/test.toml @@ -0,0 +1,3 @@ +# SQL result types, parameter binding and failures are backend facts: run on every +# cloud. Locally each case stubs the response the real warehouse returns. +Cloud = true diff --git a/acceptance/experimental/aitools/tools/statement/script.prepare b/acceptance/experimental/aitools/tools/statement/script.prepare new file mode 100644 index 00000000000..919c3f8a1c3 --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/script.prepare @@ -0,0 +1,8 @@ +# Like the integration tests these replace, run on cloud only on Unity Catalog +# workspaces: the shared classic warehouses of the non-UC ones are unreliable to +# start, and CloudEnvs cannot tell azure-prod-ucws from azure-prod. +if [ -n "${CLOUD_ENV:-}" ] && { [ -z "${TEST_METASTORE_ID:-}" ] || [ -z "${TEST_DEFAULT_WAREHOUSE_ID:-}" ]; }; then + echo "SKIP_TEST: needs a Unity Catalog workspace with a warehouse (TEST_METASTORE_ID, TEST_DEFAULT_WAREHOUSE_ID)" + exit 0 +fi +export DATABRICKS_WAREHOUSE_ID=$TEST_DEFAULT_WAREHOUSE_ID diff --git a/acceptance/experimental/aitools/tools/statement/submit-cancel/out.test.toml b/acceptance/experimental/aitools/tools/statement/submit-cancel/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/submit-cancel/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/experimental/aitools/tools/statement/submit-cancel/output.txt b/acceptance/experimental/aitools/tools/statement/submit-cancel/output.txt new file mode 100644 index 00000000000..0e73340ab7e --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/submit-cancel/output.txt @@ -0,0 +1,25 @@ + +>>> [CLI] experimental aitools tools statement submit SELECT count(*) FROM range(100000000000) +{ + "statement_id": "[STATEMENT_ID]", + "state": "PENDING", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" +} + +>>> [CLI] experimental aitools tools statement cancel [STATEMENT_ID] +{ + "statement_id": "[STATEMENT_ID]", + "state": "CANCELED" +} + +>>> [CLI] experimental aitools tools statement get [STATEMENT_ID] +{ + "statement_id": "[STATEMENT_ID]", + "state": "CANCELED", + "error": { + "message": "statement reached terminal state CANCELED" + } +} + +=== cancel request +POST /api/2.0/sql/statements/[STATEMENT_ID]/cancel diff --git a/acceptance/experimental/aitools/tools/statement/submit-cancel/script b/acceptance/experimental/aitools/tools/statement/submit-cancel/script new file mode 100644 index 00000000000..e12eceb9889 --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/submit-cancel/script @@ -0,0 +1,14 @@ +# Submit returns at once with a PENDING statement; a statement this long is still +# running when the cancel lands, so it ends CANCELED. Locally the testserver's SQL +# fake tracks the statement and its cancellation. +trace $CLI experimental aitools tools statement submit "SELECT count(*) FROM range(100000000000)" > out.submit.json +cat out.submit.json +STATEMENT_ID=$(jq -r .statement_id out.submit.json) +add_repl "$STATEMENT_ID" STATEMENT_ID +rm out.submit.json + +trace $CLI experimental aitools tools statement cancel "$STATEMENT_ID" +musterr trace $CLI experimental aitools tools statement get "$STATEMENT_ID" + +title "cancel request" +print_requests.py //api/2.0/sql/statements | jq -r 'select(.path | endswith("/cancel")) | .method + " " + .path' diff --git a/acceptance/experimental/aitools/tools/statement/submit-cancel/test.toml b/acceptance/experimental/aitools/tools/statement/submit-cancel/test.toml new file mode 100644 index 00000000000..159efe02696 --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/submit-cancel/test.toml @@ -0,0 +1 @@ +RecordRequests = true diff --git a/acceptance/experimental/aitools/tools/statement/test.toml b/acceptance/experimental/aitools/tools/statement/test.toml new file mode 100644 index 00000000000..856b5ed4668 --- /dev/null +++ b/acceptance/experimental/aitools/tools/statement/test.toml @@ -0,0 +1,3 @@ +# SQL result types, parameter binding and failures are backend facts: run on every +# cloud. Locally each case stubs the response the real warehouse returns. +Cloud = true diff --git a/acceptance/pipelines/show/failed-statement/out.test.toml b/acceptance/pipelines/show/failed-statement/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/pipelines/show/failed-statement/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/pipelines/show/failed-statement/output.txt b/acceptance/pipelines/show/failed-statement/output.txt new file mode 100644 index 00000000000..c67cfd675bf --- /dev/null +++ b/acceptance/pipelines/show/failed-statement/output.txt @@ -0,0 +1,3 @@ + +>>> [CLI] pipelines show main.default.missing_table +Error: statement failed: BAD_REQUEST: unsupported statement: SELECT * FROM `main`.`default`.`missing_table` LIMIT 11 diff --git a/acceptance/pipelines/show/failed-statement/script b/acceptance/pipelines/show/failed-statement/script new file mode 100644 index 00000000000..3100d83f5b8 --- /dev/null +++ b/acceptance/pipelines/show/failed-statement/script @@ -0,0 +1,4 @@ +# The testserver fails statements it has no handler for; this pins how the command +# reports a statement that ends FAILED (the real API's response for that case is +# pinned on cloud by experimental/aitools/tools/query/failed-statement). +musterr trace $CLI pipelines show main.default.missing_table diff --git a/acceptance/pipelines/show/failed-statement/test.toml b/acceptance/pipelines/show/failed-statement/test.toml new file mode 100644 index 00000000000..db7fe7db3a4 --- /dev/null +++ b/acceptance/pipelines/show/failed-statement/test.toml @@ -0,0 +1 @@ +Env.DATABRICKS_WAREHOUSE_ID = "wh-test" diff --git a/acceptance/telemetry/upload-cloud/out.test.toml b/acceptance/telemetry/upload-cloud/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/telemetry/upload-cloud/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/telemetry/upload-cloud/output.txt b/acceptance/telemetry/upload-cloud/output.txt new file mode 100644 index 00000000000..4aed70881eb --- /dev/null +++ b/acceptance/telemetry/upload-cloud/output.txt @@ -0,0 +1,11 @@ + +=== raw response to two test events + +>>> [CLI] api post /telemetry-ext --json @body.json +{ + "errors": [], + "numProtoSuccess": 2 +} + +=== the CLI's own upload +All 2 logs uploaded successfully diff --git a/acceptance/telemetry/upload-cloud/script b/acceptance/telemetry/upload-cloud/script new file mode 100644 index 00000000000..6427db0a0fe --- /dev/null +++ b/acceptance/telemetry/upload-cloud/script @@ -0,0 +1,22 @@ +# The real /telemetry-ext endpoint accepts the CLI's frontend logs. Locally the +# parent test.toml stubs the endpoint with the same response. +# A host that disables telemetry would upload nothing. +unset DATABRICKS_CLI_DISABLE_TELEMETRY + +title "raw response to two test events" +# The response body as the API returns it: every log a success, an empty error list. +event() { + jq -cn --arg id "$(uuid)" --arg name "$1" '{frontend_log_event_id: $id, entry: {databricks_cli_log: {cli_test_event: {name: $name}}}}' +} +jq -n --arg a "$(event VALUE1)" --arg b "$(event VALUE2)" --argjson t "$(date +%s)000" \ + '{uploadTime: $t, items: [], protoLogs: [$a, $b]}' > body.json +trace $CLI api post /telemetry-ext --json @body.json | jq '{errors, numProtoSuccess}' +rm body.json + +title "the CLI's own upload" +# Only the final result: the upload retries 5xx responses on its own, and the real +# response has more fields than the stub. A generous timeout avoids a timeout retry. +export DATABRICKS_CLI_TELEMETRY_TIMEOUT=30 +$CLI selftest send-telemetry --debug 2> debug.txt +grep -o 'All 2 logs uploaded successfully' debug.txt +rm debug.txt diff --git a/acceptance/telemetry/upload-cloud/test.toml b/acceptance/telemetry/upload-cloud/test.toml new file mode 100644 index 00000000000..188fbde9c25 --- /dev/null +++ b/acceptance/telemetry/upload-cloud/test.toml @@ -0,0 +1,4 @@ +# Whether the real endpoint accepts the logs is a backend fact: run on every cloud. +Cloud = true +# Git Bash would rewrite the /telemetry-ext argument as a Windows path. +Env.MSYS_NO_PATHCONV = "1" diff --git a/acceptance/workspace/jobs/tag-limits/out.test.toml b/acceptance/workspace/jobs/tag-limits/out.test.toml new file mode 100644 index 00000000000..c7c6f58ed6e --- /dev/null +++ b/acceptance/workspace/jobs/tag-limits/out.test.toml @@ -0,0 +1 @@ +Cloud = true diff --git a/acceptance/workspace/jobs/tag-limits/output.txt b/acceptance/workspace/jobs/tag-limits/output.txt new file mode 100644 index 00000000000..448e8dd69d3 --- /dev/null +++ b/acceptance/workspace/jobs/tag-limits/output.txt @@ -0,0 +1,7 @@ +key with characters outside the pattern: rejected +key with non-latin1 characters: rejected +empty key: rejected +valid key: accepted, stored tags: {"cafe":"value"} +value café: rejected on aws and gcp, accepted on azure +value with non-latin1 characters: rejected +valid value: accepted, stored tags: {"key":"cafe"} diff --git a/acceptance/workspace/jobs/tag-limits/script b/acceptance/workspace/jobs/tag-limits/script new file mode 100644 index 00000000000..bc8a5997ec3 --- /dev/null +++ b/acceptance/workspace/jobs/tag-limits/script @@ -0,0 +1,114 @@ +# The jobs API rejects tags the cloud provider would reject. The rules differ per +# cloud, and libs/tags (aws.go, azure.go, gcp.go) normalizes bundle tags to the same +# patterns and lengths, so these are the facts that keep normalized tags deployable. +# The expected messages are checked on cloud only: the testserver does not validate +# tags, so the local run injects each rejection with fault.py instead. +case "$CLOUD_ENV_BASE" in +aws) + INVALID_KEY='café' + KEY_ERROR='The key must match the regular expression ^[\d \w\+\-=\.:\/@]*$.' + KEY_MAX=127 + VALUE_ERROR='The value must match the regular expression ^[\d \w\+\-=\.:/@]*$.' + ;; +azure) + INVALID_KEY='café?' + KEY_ERROR='The key must match the regular expression ^[^<>\*&%;\\\/\+\?]*$.' + KEY_MAX=512 + # Azure accepts any latin1 tag value: "café" is a valid value there. + VALUE_ERROR='' + ;; +gcp) + INVALID_KEY='café?' + KEY_ERROR='The key must match the regular expression ^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$.' + KEY_MAX=63 + VALUE_ERROR='The value must match the regular expression ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$.' + ;; +esac + +# Same job shape as the integration tests this replaces: a Python task on a new +# cluster (never run), so tags are validated for a job that would start a cluster. +job_json() { + jq -cn --arg n "$UNIQUE_NAME" --arg k "$1" --arg v "$2" --arg node "$NODE_TYPE_ID" '{ + name: $n, + tags: {($k): $v}, + tasks: [{ + task_key: "test", + new_cluster: {spark_version: "13.3.x-scala2.12", num_workers: 1, node_type_id: $node}, + spark_python_task: {python_file: "/doesnt_exist.py"} + }] + }' +} + +# Delete every job this script created, also when it stops early. +touch created_jobs.txt +cleanup() { + while read -r id; do + $CLI jobs delete "$id" || true + done < created_jobs.txt + rm -f created_jobs.txt job.json create.json err.txt +} +trap cleanup EXIT + +# create_job KEY VALUE: create the job and record its id; the exit status is the CLI's. +create_job() { + job_json "$1" "$2" > job.json + if $CLI jobs create --json @job.json > create.json 2> err.txt; then + jq -er '.job_id | numbers' create.json >> created_jobs.txt || exit 1 + return 0 + fi + return 1 +} + +# expect_rejected LABEL KEY VALUE MESSAGE +expect_rejected() { + if [ -z "$CLOUD_ENV" ]; then + fault.py --body-contains "$(job_json "$2" "$3" | jq -c .tags)" "POST /api/2.2/jobs/create" 400 0 1 INVALID_PARAMETER_VALUE + expected="Fault injected by test." + else + expected="$4" + fi + if create_job "$2" "$3"; then + echo "$1: accepted, expected a rejection" >&2 + exit 1 + fi + # The CLI wraps long error messages; join the lines before matching. + msg=$(tr '\n' ' ' < err.txt) + if [[ "$msg" != *"$expected"* ]]; then + echo "$1: rejected with an unexpected message: $msg" >&2 + exit 1 + fi + echo "$1: rejected" +} + +# expect_accepted LABEL KEY VALUE: the job is created and keeps the tag as sent. +expect_accepted() { + if ! create_job "$2" "$3"; then + echo "$1: rejected, expected it to be accepted: $(cat err.txt)" >&2 + exit 1 + fi + echo "$1: accepted, stored tags: $($CLI jobs get "$(jq -r .job_id create.json)" | jq -c .settings.tags)" +} + +expect_rejected "key with characters outside the pattern" "$INVALID_KEY" value "$KEY_ERROR" +expect_rejected "key with non-latin1 characters" "🍎" value " contains non-latin1 characters." +expect_rejected "empty key" "" value " the minimal length is 1, and the maximum length is $KEY_MAX." +expect_accepted "valid key" cafe value + +# One line on every cloud: Azure accepts the value the other clouds reject. +label="value café: rejected on aws and gcp, accepted on azure" +if [ -n "$VALUE_ERROR" ]; then + expect_rejected "$label" key "café" "$VALUE_ERROR" > /dev/null +else + if ! create_job key "café"; then + echo "$label: rejected on azure: $(cat err.txt)" >&2 + exit 1 + fi + stored=$($CLI jobs get "$(jq -r .job_id create.json)" | jq -c .settings.tags) + if [ "$stored" != '{"key":"café"}' ]; then + echo "$label: azure stored $stored" >&2 + exit 1 + fi +fi +echo "$label" +expect_rejected "value with non-latin1 characters" key "🍎" " contains non-latin1 characters." +expect_accepted "valid value" key cafe diff --git a/acceptance/workspace/jobs/tag-limits/test.toml b/acceptance/workspace/jobs/tag-limits/test.toml new file mode 100644 index 00000000000..1af1350e429 --- /dev/null +++ b/acceptance/workspace/jobs/tag-limits/test.toml @@ -0,0 +1,2 @@ +# Tag limits are a backend fact that differs per cloud: run on every cloud. +Cloud = true diff --git a/integration/libs/sqlexec/sqlexec_test.go b/integration/libs/sqlexec/sqlexec_test.go index e721ec77b43..01ea98cc5ef 100644 --- a/integration/libs/sqlexec/sqlexec_test.go +++ b/integration/libs/sqlexec/sqlexec_test.go @@ -27,24 +27,6 @@ func newClient(t *testing.T) (*acc.WorkspaceT, *sqlexec.Client) { return wt, sqlexec.New(wt.W.StatementExecution, warehouseID) } -func TestSQLExecColumnsAndRows(t *testing.T) { - wt, c := newClient(t) - r, err := c.Execute(wt.Context(), "SELECT id, id * 2 AS doubled FROM range(3) ORDER BY id") - require.NoError(t, err) - assert.Equal(t, []string{"id", "doubled"}, r.Columns) - assert.Equal(t, [][]string{{"0", "0"}, {"1", "2"}, {"2", "4"}}, r.Rows) -} - -func TestSQLExecParameters(t *testing.T) { - wt, c := newClient(t) - r, err := c.Execute(wt.Context(), "SELECT :n AS n, :s AS s", sqlexec.WithParameters([]sql.StatementParameterListItem{ - {Name: "n", Type: "INT", Value: "42"}, - {Name: "s", Value: "hello"}, - })) - require.NoError(t, err) - assert.Equal(t, [][]string{{"42", "hello"}}, r.Rows) -} - func TestSQLExecNullParameter(t *testing.T) { wt, c := newClient(t) // An empty value is sent as SQL NULL (StatementParameterListItem.Value is omitempty). @@ -64,27 +46,3 @@ func TestSQLExecFailedStatement(t *testing.T) { assert.NotEmpty(t, se.Code) assert.NotEmpty(t, se.Message) } - -func TestSQLExecSubmitAndCancel(t *testing.T) { - wt, c := newClient(t) - ctx := wt.Context() - // Submit returns immediately with the statement ID so we can cancel it. - stmt, err := c.Submit(ctx, "SELECT count(*) FROM range(100000000000)") - require.NoError(t, err) - require.NotEmpty(t, stmt.ID) - - require.NoError(t, c.Cancel(ctx, stmt.ID)) - - // The cancel is best-effort; poll to a terminal state and accept either a - // CANCELED statement or one that finished before the cancel landed. - stmt, err = c.Poll(ctx, stmt) - require.NoError(t, err) - if stmt.State == sql.StatementStateCanceled { - require.Error(t, stmt.Err()) - var se *sqlexec.StatementError - require.ErrorAs(t, stmt.Err(), &se) - assert.Equal(t, sql.StatementStateCanceled, se.State) - } else { - assert.Equal(t, sql.StatementStateSucceeded, stmt.State) - } -} diff --git a/integration/libs/tags/tags_test.go b/integration/libs/tags/tags_test.go deleted file mode 100644 index f5b353fc5fa..00000000000 --- a/integration/libs/tags/tags_test.go +++ /dev/null @@ -1,250 +0,0 @@ -package tags_test - -import ( - "context" - "strings" - "testing" - - "github.com/databricks/cli/integration/internal/acc" - "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/stretchr/testify/require" -) - -func testTags(t *testing.T, tags map[string]string) error { - ctx, wt := acc.WorkspaceTest(t) - resp, err := wt.W.Jobs.Create(ctx, jobs.CreateJob{ - Name: testutil.RandomName("test-tags-"), - Tasks: []jobs.Task{ - { - TaskKey: "test", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NumWorkers: 1, - NodeTypeId: testutil.GetCloud(t).NodeTypeID(), - }, - SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "/doesnt_exist.py", - }, - }, - }, - Tags: tags, - }) - - if resp != nil { - t.Cleanup(func() { - _ = wt.W.Jobs.DeleteByJobId(context.WithoutCancel(ctx), resp.JobId) - // Cannot enable errchecking there, tests fail with: - // Error: Received unexpected error: - // Job 0 does not exist. - // require.NoError(t, err) - }) - } - - return err -} - -func testTagKey(t *testing.T, key string) error { - return testTags(t, map[string]string{ - key: "value", - }) -} - -func testTagValue(t *testing.T, value string) error { - return testTags(t, map[string]string{ - "key": value, - }) -} - -type tagTestCase struct { - name string - value string - fn func(t *testing.T, value string) error - err string -} - -func runTagTestCases(t *testing.T, cases []tagTestCase) { - for i := range cases { - tc := cases[i] - t.Run(tc.name, func(t *testing.T) { - t.Parallel() - err := tc.fn(t, tc.value) - if tc.err == "" { - require.NoError(t, err) - } else { - require.Error(t, err) - msg := strings.ReplaceAll(err.Error(), "\n", " ") - require.Contains(t, msg, tc.err) - } - }) - } -} - -func TestTagKeyAWS(t *testing.T) { - testutil.Require(t, testutil.AWS) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "invalid", - value: "café", - fn: testTagKey, - err: ` The key must match the regular expression ^[\d \w\+\-=\.:\/@]*$.`, - }, - { - name: "unicode", - value: "🍎", - fn: testTagKey, - err: ` contains non-latin1 characters.`, - }, - { - name: "empty", - value: "", - fn: testTagKey, - err: ` the minimal length is 1, and the maximum length is 127.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagKey, - err: ``, - }, - }) -} - -func TestTagValueAWS(t *testing.T) { - testutil.Require(t, testutil.AWS) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "invalid", - value: "café", - fn: testTagValue, - err: ` The value must match the regular expression ^[\d \w\+\-=\.:/@]*$.`, - }, - { - name: "unicode", - value: "🍎", - fn: testTagValue, - err: ` contains non-latin1 characters.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagValue, - err: ``, - }, - }) -} - -func TestTagKeyAzure(t *testing.T) { - testutil.Require(t, testutil.Azure) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "invalid", - value: "café?", - fn: testTagKey, - err: ` The key must match the regular expression ^[^<>\*&%;\\\/\+\?]*$.`, - }, - { - name: "unicode", - value: "🍎", - fn: testTagKey, - err: ` contains non-latin1 characters.`, - }, - { - name: "empty", - value: "", - fn: testTagKey, - err: ` the minimal length is 1, and the maximum length is 512.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagKey, - err: ``, - }, - }) -} - -func TestTagValueAzure(t *testing.T) { - testutil.Require(t, testutil.Azure) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "unicode", - value: "🍎", - fn: testTagValue, - err: ` contains non-latin1 characters.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagValue, - err: ``, - }, - }) -} - -func TestTagKeyGCP(t *testing.T) { - testutil.Require(t, testutil.GCP) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "invalid", - value: "café?", - fn: testTagKey, - err: ` The key must match the regular expression ^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$.`, - }, - { - name: "unicode", - value: "🍎", - fn: testTagKey, - err: ` contains non-latin1 characters.`, - }, - { - name: "empty", - value: "", - fn: testTagKey, - err: ` the minimal length is 1, and the maximum length is 63.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagKey, - err: ``, - }, - }) -} - -func TestTagValueGCP(t *testing.T) { - testutil.Require(t, testutil.GCP) - t.Parallel() - - runTagTestCases(t, []tagTestCase{ - { - name: "invalid", - value: "café", - fn: testTagValue, - err: ` The value must match the regular expression ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$.`, - }, - { - name: "unicode", - value: "🍎", - fn: testTagValue, - err: ` contains non-latin1 characters.`, - }, - { - name: "valid", - value: "cafe", - fn: testTagValue, - err: ``, - }, - }) -} diff --git a/integration/libs/telemetry/telemetry_test.go b/integration/libs/telemetry/telemetry_test.go deleted file mode 100644 index 186278dc993..00000000000 --- a/integration/libs/telemetry/telemetry_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package telemetry - -import ( - "encoding/json" - "errors" - "net/http" - "testing" - "time" - "uuid" - - "github.com/databricks/cli/integration/internal/acc" - "github.com/databricks/cli/libs/telemetry" - "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestTelemetryEndpoint(t *testing.T) { - ctx, wt := acc.WorkspaceTest(t) - w := wt.W - - apiClient, err := client.New(w.Config) - require.NoError(t, err) - - logs := []protos.FrontendLog{ - { - FrontendLogEventID: uuid.New().String(), - Entry: protos.FrontendLogEntry{ - DatabricksCliLog: protos.DatabricksCliLog{ - CliTestEvent: &protos.CliTestEvent{Name: protos.DummyCliEnumValue1}, - }, - }, - }, - { - FrontendLogEventID: uuid.New().String(), - Entry: protos.FrontendLogEntry{ - DatabricksCliLog: protos.DatabricksCliLog{ - CliTestEvent: &protos.CliTestEvent{Name: protos.DummyCliEnumValue2}, - }, - }, - }, - } - - protoLogs := make([]string, len(logs)) - for i, log := range logs { - b, err := json.Marshal(log) - require.NoError(t, err) - protoLogs[i] = string(b) - } - - reqB := telemetry.RequestBody{ - UploadTime: time.Now().UnixMilli(), - Items: []string{}, - ProtoLogs: protoLogs, - } - - respB := telemetry.ResponseBody{} - - err = apiClient.Do(ctx, "POST", "/telemetry-ext", nil, nil, reqB, &respB) - // The SDK retries 429 responses for its full retry timeout (5 minutes). - // A 429 that outlasts it means the shared test workspace is throttling - // /telemetry-ext because of traffic from other concurrent CI runs; it - // says nothing about whether the endpoint accepts these logs. - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.StatusCode == http.StatusTooManyRequests { - t.Skipf("/telemetry-ext is rate limited on this workspace: %s", aerr.Message) - } - require.NoError(t, err) - - assert.Equal(t, telemetry.ResponseBody{ - Errors: []telemetry.LogError{}, - NumProtoSuccess: int64(2), - }, respB) -} diff --git a/internal/testutil/cloud.go b/internal/testutil/cloud.go index 535c67e1be0..5f2f9e91f8c 100644 --- a/internal/testutil/cloud.go +++ b/internal/testutil/cloud.go @@ -8,13 +8,6 @@ const ( GCP ) -// Implement [Requirement]. -func (c Cloud) Verify(t TestingT) { - if c != GetCloud(t) { - t.Skipf("Skipping %s-specific test", c) - } -} - func (c Cloud) String() string { switch c { case AWS: diff --git a/internal/testutil/requirement.go b/internal/testutil/requirement.go deleted file mode 100644 index e182b751805..00000000000 --- a/internal/testutil/requirement.go +++ /dev/null @@ -1,15 +0,0 @@ -package testutil - -// Requirement is the interface for test requirements. -type Requirement interface { - Verify(t TestingT) -} - -// Require should be called at the beginning of a test to ensure that all -// requirements are met before running the test. -// If any requirement is not met, the test will be skipped. -func Require(t TestingT, requirements ...Requirement) { - for _, r := range requirements { - r.Verify(t) - } -} From 8a1c5cf41cd3deb4c8cad78f2ed10e2eeead2448 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Thu, 26 Nov 2026 17:48:59 +0000 Subject: [PATCH 2/5] Remove Cloud.String, now unused Its only caller was Cloud.Verify, removed with the tags integration tests. cloud: TestAccept/workspace/jobs/tag-limits TestAccept/telemetry/upload-cloud cloud: TestAccept/experimental/aitools/tools/query TestAccept/experimental/aitools/tools/statement Co-authored-by: Isaac --- internal/testutil/cloud.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/internal/testutil/cloud.go b/internal/testutil/cloud.go index 5f2f9e91f8c..942b0a663ae 100644 --- a/internal/testutil/cloud.go +++ b/internal/testutil/cloud.go @@ -8,19 +8,6 @@ const ( GCP ) -func (c Cloud) String() string { - switch c { - case AWS: - return "AWS" - case Azure: - return "Azure" - case GCP: - return "GCP" - default: - return "unknown" - } -} - func (c Cloud) NodeTypeID() string { switch c { case AWS: From 04f19d49ca90acdb13ce019bb593904d3d6f07de Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Thu, 26 Nov 2026 19:57:43 +0000 Subject: [PATCH 3/5] acc: address review of the backend-libs ports Skip the telemetry test when /telemetry-ext stays throttled, skip submit-cancel when the statement finished before the cancel, pin the SQL statement sent by each query test, keep diagnostics in LOG files, report failed cleanup deletes, and share the warehouse gate of the SQL tests. cloud: TestAccept/workspace/jobs/tag-limits TestAccept/telemetry/upload-cloud cloud: TestAccept/experimental/aitools/tools/query TestAccept/experimental/aitools/tools/statement Co-authored-by: Isaac --- .../tools/query/columns-rows/output.txt | 5 +++ .../aitools/tools/query/columns-rows/script | 3 ++ .../tools/query/columns-rows/test.toml | 1 + .../tools/query/failed-statement/output.txt | 8 +++-- .../tools/query/failed-statement/script | 10 +++--- .../tools/query/failed-statement/test.toml | 1 + .../tools/query/null-parameter/output.txt | 4 +-- .../aitools/tools/query/null-parameter/script | 4 +-- .../aitools/tools/query/parameters/output.txt | 4 +-- .../aitools/tools/query/parameters/script | 4 +-- .../aitools/tools/query/scalar/output.txt | 5 +++ .../aitools/tools/query/scalar/script | 3 ++ .../aitools/tools/query/scalar/test.toml | 1 + .../aitools/tools/query/script.prepare | 9 +---- .../experimental/aitools/tools/script.prepare | 11 +++++++ .../aitools/tools/statement/script.prepare | 9 +---- .../tools/statement/submit-cancel/script | 14 +++++--- .../aitools/tools/statement/test.toml | 4 +-- acceptance/telemetry/upload-cloud/script | 33 +++++++++++++++---- acceptance/telemetry/upload-cloud/test.toml | 2 -- acceptance/workspace/jobs/tag-limits/script | 22 ++++++++----- 21 files changed, 104 insertions(+), 53 deletions(-) create mode 100644 acceptance/experimental/aitools/tools/script.prepare diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/output.txt b/acceptance/experimental/aitools/tools/query/columns-rows/output.txt index 70c47e20bc2..9ee8efb9abc 100644 --- a/acceptance/experimental/aitools/tools/query/columns-rows/output.txt +++ b/acceptance/experimental/aitools/tools/query/columns-rows/output.txt @@ -4,3 +4,8 @@ id,doubled 0,0 1,2 2,4 + +=== statement on the wire + +>>> print_requests.py //api/2.0/sql/statements +SELECT id, id * 2 AS doubled FROM range(3) ORDER BY id diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/script b/acceptance/experimental/aitools/tools/query/columns-rows/script index a7482a2fef4..57d78cb9917 100644 --- a/acceptance/experimental/aitools/tools/query/columns-rows/script +++ b/acceptance/experimental/aitools/tools/query/columns-rows/script @@ -1 +1,4 @@ trace $CLI experimental aitools tools query --output csv "SELECT id, id * 2 AS doubled FROM range(3) ORDER BY id" + +title "statement on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -r .body.statement diff --git a/acceptance/experimental/aitools/tools/query/columns-rows/test.toml b/acceptance/experimental/aitools/tools/query/columns-rows/test.toml index 26b976ffffa..14eef338833 100644 --- a/acceptance/experimental/aitools/tools/query/columns-rows/test.toml +++ b/acceptance/experimental/aitools/tools/query/columns-rows/test.toml @@ -1,3 +1,4 @@ +RecordRequests = true [[Server]] Pattern = "POST /api/2.0/sql/statements" diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/output.txt b/acceptance/experimental/aitools/tools/query/failed-statement/output.txt index 1d13fd5c09c..30214bc42d9 100644 --- a/acceptance/experimental/aitools/tools/query/failed-statement/output.txt +++ b/acceptance/experimental/aitools/tools/query/failed-statement/output.txt @@ -1,2 +1,6 @@ -query failed: BAD_REQUEST [TABLE_OR_VIEW_NOT_FOUND] The table or view `a_table_that_does_not_exist_zzz` cannot be found -SQLSTATE: 42P01 +query failed: BAD_REQUEST [TABLE_OR_VIEW_NOT_FOUND], SQLSTATE: 42P01 + +=== statement on the wire + +>>> print_requests.py //api/2.0/sql/statements +SELECT * FROM a_table_that_does_not_exist_zzz diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/script b/acceptance/experimental/aitools/tools/query/failed-statement/script index 911858d18fc..ffb0cc61d33 100644 --- a/acceptance/experimental/aitools/tools/query/failed-statement/script +++ b/acceptance/experimental/aitools/tools/query/failed-statement/script @@ -1,6 +1,8 @@ # The real message goes on with advice and the workspace's search path; keep the # stable parts: error code, error class, the relation and the SQLSTATE. -musterr $CLI experimental aitools tools query --output csv "SELECT * FROM a_table_that_does_not_exist_zzz" 2> err.txt -grep -o 'query failed: BAD_REQUEST \[TABLE_OR_VIEW_NOT_FOUND\] The table or view `a_table_that_does_not_exist_zzz` cannot be found' err.txt -grep -o 'SQLSTATE: [0-9A-Z]*' err.txt -rm err.txt +musterr $CLI experimental aitools tools query --output csv "SELECT * FROM a_table_that_does_not_exist_zzz" 2> LOG.query +contains.py 'query failed: BAD_REQUEST [TABLE_OR_VIEW_NOT_FOUND] The table or view `a_table_that_does_not_exist_zzz` cannot be found' 'SQLSTATE: 42P01' < LOG.query > /dev/null +echo "query failed: BAD_REQUEST [TABLE_OR_VIEW_NOT_FOUND], SQLSTATE: 42P01" + +title "statement on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -r .body.statement diff --git a/acceptance/experimental/aitools/tools/query/failed-statement/test.toml b/acceptance/experimental/aitools/tools/query/failed-statement/test.toml index 470fd44526d..a8a1982b9c7 100644 --- a/acceptance/experimental/aitools/tools/query/failed-statement/test.toml +++ b/acceptance/experimental/aitools/tools/query/failed-statement/test.toml @@ -1,3 +1,4 @@ +RecordRequests = true [[Server]] Pattern = "POST /api/2.0/sql/statements" diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/output.txt b/acceptance/experimental/aitools/tools/query/null-parameter/output.txt index a72c563ceef..ed793f6ba69 100644 --- a/acceptance/experimental/aitools/tools/query/null-parameter/output.txt +++ b/acceptance/experimental/aitools/tools/query/null-parameter/output.txt @@ -3,7 +3,7 @@ is_null true -=== parameters on the wire +=== statement on the wire >>> print_requests.py //api/2.0/sql/statements -[{"name":"maybe"}] +{"statement":"SELECT :maybe IS NULL AS is_null","parameters":[{"name":"maybe"}]} diff --git a/acceptance/experimental/aitools/tools/query/null-parameter/script b/acceptance/experimental/aitools/tools/query/null-parameter/script index 183fab11695..c30acb90307 100644 --- a/acceptance/experimental/aitools/tools/query/null-parameter/script +++ b/acceptance/experimental/aitools/tools/query/null-parameter/script @@ -1,5 +1,5 @@ # An empty value is sent without a value, which the API binds as SQL NULL. trace $CLI experimental aitools tools query --output csv --param maybe= "SELECT :maybe IS NULL AS is_null" -title "parameters on the wire" -trace print_requests.py //api/2.0/sql/statements | jq -c .body.parameters +title "statement on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -c '.body | {statement, parameters}' diff --git a/acceptance/experimental/aitools/tools/query/parameters/output.txt b/acceptance/experimental/aitools/tools/query/parameters/output.txt index 996b5d29ed4..04080d61a85 100644 --- a/acceptance/experimental/aitools/tools/query/parameters/output.txt +++ b/acceptance/experimental/aitools/tools/query/parameters/output.txt @@ -3,7 +3,7 @@ n,s 42,hello -=== parameters on the wire +=== statement on the wire >>> print_requests.py //api/2.0/sql/statements -[{"name":"n","type":"INT","value":"42"},{"name":"s","value":"hello"}] +{"statement":"SELECT :n AS n, :s AS s","parameters":[{"name":"n","type":"INT","value":"42"},{"name":"s","value":"hello"}]} diff --git a/acceptance/experimental/aitools/tools/query/parameters/script b/acceptance/experimental/aitools/tools/query/parameters/script index ea573e3809c..4307aac3aa2 100644 --- a/acceptance/experimental/aitools/tools/query/parameters/script +++ b/acceptance/experimental/aitools/tools/query/parameters/script @@ -1,4 +1,4 @@ trace $CLI experimental aitools tools query --output csv --param n:INT=42 --param s=hello "SELECT :n AS n, :s AS s" -title "parameters on the wire" -trace print_requests.py //api/2.0/sql/statements | jq -c .body.parameters +title "statement on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -c '.body | {statement, parameters}' diff --git a/acceptance/experimental/aitools/tools/query/scalar/output.txt b/acceptance/experimental/aitools/tools/query/scalar/output.txt index b09b4aa11c3..fb4dc0fe173 100644 --- a/acceptance/experimental/aitools/tools/query/scalar/output.txt +++ b/acceptance/experimental/aitools/tools/query/scalar/output.txt @@ -2,3 +2,8 @@ >>> [CLI] experimental aitools tools query --output csv SELECT 1 1 1 + +=== statement on the wire + +>>> print_requests.py //api/2.0/sql/statements +SELECT 1 diff --git a/acceptance/experimental/aitools/tools/query/scalar/script b/acceptance/experimental/aitools/tools/query/scalar/script index f8315d943da..b2d4f9e5434 100644 --- a/acceptance/experimental/aitools/tools/query/scalar/script +++ b/acceptance/experimental/aitools/tools/query/scalar/script @@ -1 +1,4 @@ trace $CLI experimental aitools tools query --output csv "SELECT 1" + +title "statement on the wire" +trace print_requests.py //api/2.0/sql/statements | jq -r .body.statement diff --git a/acceptance/experimental/aitools/tools/query/scalar/test.toml b/acceptance/experimental/aitools/tools/query/scalar/test.toml index 7de6ec22772..abc4ec07f41 100644 --- a/acceptance/experimental/aitools/tools/query/scalar/test.toml +++ b/acceptance/experimental/aitools/tools/query/scalar/test.toml @@ -1,3 +1,4 @@ +RecordRequests = true [[Server]] Pattern = "POST /api/2.0/sql/statements" diff --git a/acceptance/experimental/aitools/tools/query/script.prepare b/acceptance/experimental/aitools/tools/query/script.prepare index 919c3f8a1c3..afbc9f10b33 100644 --- a/acceptance/experimental/aitools/tools/query/script.prepare +++ b/acceptance/experimental/aitools/tools/query/script.prepare @@ -1,8 +1 @@ -# Like the integration tests these replace, run on cloud only on Unity Catalog -# workspaces: the shared classic warehouses of the non-UC ones are unreliable to -# start, and CloudEnvs cannot tell azure-prod-ucws from azure-prod. -if [ -n "${CLOUD_ENV:-}" ] && { [ -z "${TEST_METASTORE_ID:-}" ] || [ -z "${TEST_DEFAULT_WAREHOUSE_ID:-}" ]; }; then - echo "SKIP_TEST: needs a Unity Catalog workspace with a warehouse (TEST_METASTORE_ID, TEST_DEFAULT_WAREHOUSE_ID)" - exit 0 -fi -export DATABRICKS_WAREHOUSE_ID=$TEST_DEFAULT_WAREHOUSE_ID +require_uc_warehouse diff --git a/acceptance/experimental/aitools/tools/script.prepare b/acceptance/experimental/aitools/tools/script.prepare new file mode 100644 index 00000000000..477d39e5e1a --- /dev/null +++ b/acceptance/experimental/aitools/tools/script.prepare @@ -0,0 +1,11 @@ +# Called by query/ and statement/. Like the integration tests these replace, the +# SQL tests run on cloud only on Unity Catalog workspaces with a warehouse: the +# shared classic warehouses of the non-UC ones are unreliable to start, and +# CloudEnvs cannot tell azure-prod-ucws from azure-prod. +require_uc_warehouse() { + if [ -n "${CLOUD_ENV:-}" ] && { [ -z "${TEST_METASTORE_ID:-}" ] || [ -z "${TEST_DEFAULT_WAREHOUSE_ID:-}" ]; }; then + echo "SKIP_TEST: needs a Unity Catalog workspace with a warehouse (TEST_METASTORE_ID, TEST_DEFAULT_WAREHOUSE_ID)" + exit 0 + fi + export DATABRICKS_WAREHOUSE_ID=$TEST_DEFAULT_WAREHOUSE_ID +} diff --git a/acceptance/experimental/aitools/tools/statement/script.prepare b/acceptance/experimental/aitools/tools/statement/script.prepare index 919c3f8a1c3..afbc9f10b33 100644 --- a/acceptance/experimental/aitools/tools/statement/script.prepare +++ b/acceptance/experimental/aitools/tools/statement/script.prepare @@ -1,8 +1 @@ -# Like the integration tests these replace, run on cloud only on Unity Catalog -# workspaces: the shared classic warehouses of the non-UC ones are unreliable to -# start, and CloudEnvs cannot tell azure-prod-ucws from azure-prod. -if [ -n "${CLOUD_ENV:-}" ] && { [ -z "${TEST_METASTORE_ID:-}" ] || [ -z "${TEST_DEFAULT_WAREHOUSE_ID:-}" ]; }; then - echo "SKIP_TEST: needs a Unity Catalog workspace with a warehouse (TEST_METASTORE_ID, TEST_DEFAULT_WAREHOUSE_ID)" - exit 0 -fi -export DATABRICKS_WAREHOUSE_ID=$TEST_DEFAULT_WAREHOUSE_ID +require_uc_warehouse diff --git a/acceptance/experimental/aitools/tools/statement/submit-cancel/script b/acceptance/experimental/aitools/tools/statement/submit-cancel/script index e12eceb9889..0971f693446 100644 --- a/acceptance/experimental/aitools/tools/statement/submit-cancel/script +++ b/acceptance/experimental/aitools/tools/statement/submit-cancel/script @@ -1,6 +1,5 @@ -# Submit returns at once with a PENDING statement; a statement this long is still -# running when the cancel lands, so it ends CANCELED. Locally the testserver's SQL -# fake tracks the statement and its cancellation. +# Submit returns at once with a PENDING statement, which the cancel then stops. +# Locally the testserver's SQL fake tracks the statement and its cancellation. trace $CLI experimental aitools tools statement submit "SELECT count(*) FROM range(100000000000)" > out.submit.json cat out.submit.json STATEMENT_ID=$(jq -r .statement_id out.submit.json) @@ -8,7 +7,14 @@ add_repl "$STATEMENT_ID" STATEMENT_ID rm out.submit.json trace $CLI experimental aitools tools statement cancel "$STATEMENT_ID" + +# Cancel is best-effort: a statement that finished before the cancel landed leaves +# nothing to check. Otherwise get polls to the terminal state, CANCELED. +if $CLI experimental aitools tools statement get "$STATEMENT_ID" > LOG.get; then + echo "SKIP_TEST: the statement finished before the cancel landed: $(jq -r .state LOG.get)" + exit 0 +fi musterr trace $CLI experimental aitools tools statement get "$STATEMENT_ID" title "cancel request" -print_requests.py //api/2.0/sql/statements | jq -r 'select(.path | endswith("/cancel")) | .method + " " + .path' +print_requests.py --summary //cancel diff --git a/acceptance/experimental/aitools/tools/statement/test.toml b/acceptance/experimental/aitools/tools/statement/test.toml index 856b5ed4668..fd8bc31c187 100644 --- a/acceptance/experimental/aitools/tools/statement/test.toml +++ b/acceptance/experimental/aitools/tools/statement/test.toml @@ -1,3 +1,3 @@ -# SQL result types, parameter binding and failures are backend facts: run on every -# cloud. Locally each case stubs the response the real warehouse returns. +# The statement lifecycle (submit, cancel, terminal state) is a backend fact: run on +# every cloud. Locally the testserver's SQL fake tracks statements and cancellation. Cloud = true diff --git a/acceptance/telemetry/upload-cloud/script b/acceptance/telemetry/upload-cloud/script index 6427db0a0fe..abf52330bc2 100644 --- a/acceptance/telemetry/upload-cloud/script +++ b/acceptance/telemetry/upload-cloud/script @@ -3,6 +3,15 @@ # A host that disables telemetry would upload nothing. unset DATABRICKS_CLI_DISABLE_TELEMETRY +# A shared workspace can throttle /telemetry-ext past every retry because of other +# CI runs. That says nothing about whether the endpoint accepts these logs: skip. +skip_if_throttled() { + if grep -q 'HTTP/1.1 429' "$1"; then + echo "SKIP_TEST: /telemetry-ext is rate limited on this workspace" + exit 0 + fi +} + title "raw response to two test events" # The response body as the API returns it: every log a success, an empty error list. event() { @@ -10,13 +19,23 @@ event() { } jq -n --arg a "$(event VALUE1)" --arg b "$(event VALUE2)" --argjson t "$(date +%s)000" \ '{uploadTime: $t, items: [], protoLogs: [$a, $b]}' > body.json -trace $CLI api post /telemetry-ext --json @body.json | jq '{errors, numProtoSuccess}' -rm body.json +printf "\n>>> [CLI] api post /telemetry-ext --json @body.json\n" +# Git Bash would rewrite the /telemetry-ext argument as a Windows path. +if ! MSYS_NO_PATHCONV=1 $CLI api post /telemetry-ext --json @body.json --debug > response.json 2> LOG.api; then + skip_if_throttled LOG.api + cat LOG.api >&2 + exit 1 +fi +jq '{errors, numProtoSuccess}' response.json +rm body.json response.json title "the CLI's own upload" -# Only the final result: the upload retries 5xx responses on its own, and the real -# response has more fields than the stub. A generous timeout avoids a timeout retry. +# The upload makes one attempt per retry, so a throttled endpoint shows up as a 429 +# in the debug log. A generous timeout avoids a timeout retry. export DATABRICKS_CLI_TELEMETRY_TIMEOUT=30 -$CLI selftest send-telemetry --debug 2> debug.txt -grep -o 'All 2 logs uploaded successfully' debug.txt -rm debug.txt +$CLI selftest send-telemetry --debug 2> LOG.upload +if ! grep -q 'uploaded successfully' LOG.upload; then + skip_if_throttled LOG.upload +fi +contains.py 'All 2 logs uploaded successfully' < LOG.upload > /dev/null +echo "All 2 logs uploaded successfully" diff --git a/acceptance/telemetry/upload-cloud/test.toml b/acceptance/telemetry/upload-cloud/test.toml index 188fbde9c25..ccdbf246c05 100644 --- a/acceptance/telemetry/upload-cloud/test.toml +++ b/acceptance/telemetry/upload-cloud/test.toml @@ -1,4 +1,2 @@ # Whether the real endpoint accepts the logs is a backend fact: run on every cloud. Cloud = true -# Git Bash would rewrite the /telemetry-ext argument as a Windows path. -Env.MSYS_NO_PATHCONV = "1" diff --git a/acceptance/workspace/jobs/tag-limits/script b/acceptance/workspace/jobs/tag-limits/script index bc8a5997ec3..17079813361 100644 --- a/acceptance/workspace/jobs/tag-limits/script +++ b/acceptance/workspace/jobs/tag-limits/script @@ -23,6 +23,10 @@ gcp) KEY_MAX=63 VALUE_ERROR='The value must match the regular expression ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$.' ;; +*) + echo "no tag rules for CLOUD_ENV_BASE=$CLOUD_ENV_BASE" >&2 + exit 1 + ;; esac # Same job shape as the integration tests this replaces: a Python task on a new @@ -43,16 +47,16 @@ job_json() { touch created_jobs.txt cleanup() { while read -r id; do - $CLI jobs delete "$id" || true + errcode $CLI jobs delete "$id" done < created_jobs.txt - rm -f created_jobs.txt job.json create.json err.txt + rm -f created_jobs.txt job.json create.json } trap cleanup EXIT # create_job KEY VALUE: create the job and record its id; the exit status is the CLI's. create_job() { job_json "$1" "$2" > job.json - if $CLI jobs create --json @job.json > create.json 2> err.txt; then + if $CLI jobs create --json @job.json > create.json 2> LOG.create; then jq -er '.job_id | numbers' create.json >> created_jobs.txt || exit 1 return 0 fi @@ -71,8 +75,9 @@ expect_rejected() { echo "$1: accepted, expected a rejection" >&2 exit 1 fi - # The CLI wraps long error messages; join the lines before matching. - msg=$(tr '\n' ' ' < err.txt) + # The CLI wraps long error messages, so contains.py (one line at a time) cannot + # match them: join the lines first. + msg=$(tr '\n' ' ' < LOG.create) if [[ "$msg" != *"$expected"* ]]; then echo "$1: rejected with an unexpected message: $msg" >&2 exit 1 @@ -83,10 +88,11 @@ expect_rejected() { # expect_accepted LABEL KEY VALUE: the job is created and keeps the tag as sent. expect_accepted() { if ! create_job "$2" "$3"; then - echo "$1: rejected, expected it to be accepted: $(cat err.txt)" >&2 + echo "$1: rejected, expected it to be accepted: $(cat LOG.create)" >&2 exit 1 fi - echo "$1: accepted, stored tags: $($CLI jobs get "$(jq -r .job_id create.json)" | jq -c .settings.tags)" + stored=$($CLI jobs get "$(jq -r .job_id create.json)" | jq -c .settings.tags) + echo "$1: accepted, stored tags: $stored" } expect_rejected "key with characters outside the pattern" "$INVALID_KEY" value "$KEY_ERROR" @@ -100,7 +106,7 @@ if [ -n "$VALUE_ERROR" ]; then expect_rejected "$label" key "café" "$VALUE_ERROR" > /dev/null else if ! create_job key "café"; then - echo "$label: rejected on azure: $(cat err.txt)" >&2 + echo "$label: rejected on azure: $(cat LOG.create)" >&2 exit 1 fi stored=$($CLI jobs get "$(jq -r .job_id create.json)" | jq -c .settings.tags) From e9b0bd82439fde93df2999115c15f9123be47660 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 30 Nov 2026 11:01:07 +0000 Subject: [PATCH 4/5] acc: use || true for the tag-limits cleanup delete errcode was removed on main (#7975); best-effort deletes in cleanup traps use || true. cloud: TestAccept/experimental/aitools/tools/query/columns-rows TestAccept/experimental/aitools/tools/query/failed-statement TestAccept/experimental/aitools/tools/query/null-parameter TestAccept/experimental/aitools/tools/query/parameters TestAccept/experimental/aitools/tools/query/scalar TestAccept/experimental/aitools/tools/statement/submit-cancel TestAccept/pipelines/show/failed-statement TestAccept/telemetry/upload-cloud TestAccept/workspace/jobs/tag-limits Co-authored-by: Isaac --- acceptance/workspace/jobs/tag-limits/script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/workspace/jobs/tag-limits/script b/acceptance/workspace/jobs/tag-limits/script index 17079813361..92b0069b4ab 100644 --- a/acceptance/workspace/jobs/tag-limits/script +++ b/acceptance/workspace/jobs/tag-limits/script @@ -47,7 +47,7 @@ job_json() { touch created_jobs.txt cleanup() { while read -r id; do - errcode $CLI jobs delete "$id" + $CLI jobs delete "$id" || true done < created_jobs.txt rm -f created_jobs.txt job.json create.json } From 97d721b7716d0e62f586006d121de70844a173f6 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 30 Nov 2026 11:14:02 +0000 Subject: [PATCH 5/5] Remove Cloud.NodeTypeID, now unused Its last callers were the integration tests deleted here and in #8074. cloud: TestAccept/experimental/aitools/tools/query/columns-rows TestAccept/experimental/aitools/tools/query/failed-statement TestAccept/experimental/aitools/tools/query/null-parameter TestAccept/experimental/aitools/tools/query/parameters TestAccept/experimental/aitools/tools/query/scalar TestAccept/experimental/aitools/tools/statement/submit-cancel TestAccept/pipelines/show/failed-statement TestAccept/telemetry/upload-cloud TestAccept/workspace/jobs/tag-limits Co-authored-by: Isaac --- internal/testutil/cloud.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/internal/testutil/cloud.go b/internal/testutil/cloud.go index 942b0a663ae..605607544f8 100644 --- a/internal/testutil/cloud.go +++ b/internal/testutil/cloud.go @@ -8,19 +8,6 @@ const ( GCP ) -func (c Cloud) NodeTypeID() string { - switch c { - case AWS: - return "i3.xlarge" - case Azure: - return "Standard_E4ds_v5" - case GCP: - return "n1-standard-4" - default: - return "unknown" - } -} - func GetCloud(t TestingT) Cloud { env := GetEnvOrSkipTest(t, "CLOUD_ENV") switch env {