Skip to content
Merged
22 changes: 22 additions & 0 deletions acceptance/bundle/config-remote-sync/job_fields/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ Resource: resources.jobs.my_job

targets:

=== Telemetry

>>> cat out.requests.txt
{
"save": true,
"changes_total": 12,
"add_count": 6,
"replace_count": 4,
"remove_count": 2,
"resource_changes": [
{
"resource_type": "jobs",
"changes_count": 12,
"add_count": 6,
"replace_count": 4,
"remove_count": 2
}
],
"files_changed_count": 1,
"files_written_count": 1
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.my_job
Expand Down
9 changes: 9 additions & 0 deletions acceptance/bundle/config-remote-sync/job_fields/script
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ add_repl.py "$NODE_TYPE_ID" "[NODE_TYPE_ID]"

cleanup() {
trace $CLI bundle destroy --auto-approve
# destroy records requests too; drop the recorded file so it is not compared.
rm -f out.requests.txt
}
trap cleanup EXIT

Expand Down Expand Up @@ -63,3 +65,10 @@ title "Configuration changes"
echo
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup

title "Telemetry"
echo
# The engine name is dropped because both EnvMatrix variants share this output;
# every other counter is engine-agnostic. This run exercises add_count and
# remove_count (the remote edits add and remove keyed fields).
trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null) | del(.engine)'
5 changes: 4 additions & 1 deletion acceptance/bundle/config-remote-sync/job_fields/test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Cloud = true
RequiresUnityCatalog = true

RecordRequests = false
# RecordRequests captures the config-remote-sync telemetry event so the script
# can assert the per-operation change counts (add_count/remove_count/...).
# out.requests.txt is removed in the script's cleanup so it is not compared.
RecordRequests = true
Ignore = [".databricks", "dummy.whl", "databricks.yml", "databricks.yml.backup"]

[Env]
Expand Down
29 changes: 29 additions & 0 deletions acceptance/bundle/config-remote-sync/resolve_variables/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,35 @@ Resource: resources.pipelines.my_pipeline

targets:

=== Telemetry

>>> cat out.requests.txt
{
"save": true,
"changes_total": 17,
"add_count": 10,
"replace_count": 6,
"remove_count": 1,
"resource_changes": [
{
"resource_type": "jobs",
"changes_count": 16,
"add_count": 10,
"replace_count": 5,
"remove_count": 1
},
{
"resource_type": "pipelines",
"changes_count": 1,
"replace_count": 1
}
],
"files_changed_count": 1,
"files_written_count": 1,
"refs_retargeted": 1,
"refs_from_siblings": 7
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.my_job
Expand Down
10 changes: 10 additions & 0 deletions acceptance/bundle/config-remote-sync/resolve_variables/script
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
# destroy records requests too; drop the recorded file so it is not compared.
rm -f out.requests.txt
}
trap cleanup EXIT

Expand Down Expand Up @@ -127,3 +129,11 @@ title "Configuration changes"
echo
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup

title "Telemetry"
echo
# The engine name is dropped because both EnvMatrix variants share this output;
# every other counter is engine-agnostic. This run exercises refs_retargeted
# (the env param re-targeted to a different variable) and refs_from_siblings
# (added params/tasks restored from sibling references).
trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null) | del(.engine)'
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Cloud = true
RequiresUnityCatalog = true

RecordRequests = false
# RecordRequests captures the config-remote-sync telemetry event so the script
# can assert the variable-reference restoration counts (refs_retargeted /
# refs_from_siblings). out.requests.txt is removed in the script's cleanup so it
# is not compared.
RecordRequests = true
Ignore = [".databricks", "databricks.yml", "databricks.yml.backup"]

[Env]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle:
name: config-remote-sync-telemetry-error

resources:
jobs:
foo:
name: test job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/Users/tester@databricks.com/notebook

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-error/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

>>> errcode [CLI] bundle config-remote-sync
Error: failed to detect changes: state snapshot not available: resources state snapshot not found remotely at resources-config-sync-snapshot.json: state snapshot not found

Exit code: 1

>>> cat out.requests.txt
{
"engine": "terraform",
"error_message": "failed to detect changes: state snapshot not available: resources state snapshot not found remotely at resources-config-sync-snapshot.json: state snapshot not found",
"error_category": "STATE_NOT_FOUND"
}
7 changes: 7 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-error/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Running config-remote-sync without a prior deploy: the state snapshot does
# not exist, so the command fails and telemetry reports STATE_NOT_FOUND.
trace errcode $CLI bundle config-remote-sync

trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null)'

rm out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# config-remote-sync is not supported on Windows.
[GOOS]
windows = false

# STATE_NOT_FOUND is a terraform-only path: the terraform engine pulls a config
# snapshot that doesn't exist without a prior deploy, while the direct engine
# does not. Pin the engine so the test exercises that specific failure.
[EnvMatrix]
DATABRICKS_BUNDLE_ENGINE = ["terraform"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bundle:
name: config-remote-sync-recreate

resources:
pipelines:
foo:
name: test pipeline
# ingestion_definition.connection_name is immutable (recreate_on_changes):
# a remote change to it means the next deploy would delete + recreate the
# pipeline. (storage, the other immutable pipeline field, is skipped by
# configsync because the backend auto-generates it, so it can't be used
# here.)
ingestion_definition:
connection_name: my_connection
objects:
- {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-recreate/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-remote-sync-recreate/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle config-remote-sync
Detected changes in 1 resource(s):

Resource: resources.pipelines.foo
ingestion_definition.connection_name: replace



>>> cat out.requests.txt
{
"engine": "direct",
"changes_total": 1,
"replace_count": 1,
"recreate_forcing_changes": 1,
"resource_changes": [
{
"resource_type": "pipelines",
"changes_count": 1,
"replace_count": 1
}
],
"files_changed_count": 1
}
15 changes: 15 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-recreate/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trace $CLI bundle deploy

pipeline_id="$(read_id.py foo)"

# Change the immutable ingestion_definition.connection_name remotely.
# config-remote-sync would sync this into config, so recreate_forcing_changes is 1.
edit_resource.py pipelines $pipeline_id <<EOF
r["ingestion_definition"]["connection_name"] = "my_new_connection"
EOF

trace $CLI bundle config-remote-sync

trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null)'

rm out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# config-remote-sync is not supported on Windows.
[GOOS]
windows = false

# Pinned to the direct engine (see config-remote-sync/test.toml): telemetry is
# engine-agnostic above the state layer, and recreate_forcing_changes is derived
# from the resource lifecycle metadata, not from which engine read the state.
[EnvMatrix]
DATABRICKS_BUNDLE_ENGINE = ["direct"]
11 changes: 11 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-save/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle:
name: config-remote-sync-save

resources:
jobs:
foo:
name: test job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/Users/tester@databricks.com/notebook

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-save/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-remote-sync-save/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle config-remote-sync --save
Detected changes in 1 resource(s):

Resource: resources.jobs.foo
name: replace



>>> cat out.requests.txt
{
"save": true,
"engine": "direct",
"changes_total": 1,
"replace_count": 1,
"overwritten_local_edits": 1,
"resource_changes": [
{
"resource_type": "jobs",
"changes_count": 1,
"replace_count": 1
}
],
"files_changed_count": 1,
"files_written_count": 1
}
12 changes: 12 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-save/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trace $CLI bundle deploy

# Edit the job name locally (not deployed) so the local config diverges from the
# deployed state. config-remote-sync --save then overwrites that pending edit,
# exercising save, files_written_count, and overwritten_local_edits.
update_file.py databricks.yml "test job" "locally edited job name"

trace $CLI bundle config-remote-sync --save

trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null)'

rm out.requests.txt
11 changes: 11 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync-save/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --save rewrites databricks.yml; it's a mutated input, not asserted output.
Ignore = ["databricks.yml", "databricks.yml.backup"]

# config-remote-sync is not supported on Windows.
[GOOS]
windows = false

# overwritten_local_edits is computed from the per-field deployed base, which
# only the direct engine materializes (the terraform sync snapshot is empty).
[EnvMatrix]
DATABRICKS_BUNDLE_ENGINE = ["direct"]
11 changes: 11 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle:
name: config-remote-sync-telemetry

resources:
jobs:
foo:
name: test job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/Users/tester@databricks.com/notebook
4 changes: 4 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-remote-sync-telemetry/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle config-remote-sync
Detected changes in 1 resource(s):

Resource: resources.jobs.foo
name: replace



>>> cat out.requests.txt
{
"engine": "direct",
"changes_total": 1,
"replace_count": 1,
"resource_changes": [
{
"resource_type": "jobs",
"changes_count": 1,
"replace_count": 1
}
],
"files_changed_count": 1
}
12 changes: 12 additions & 0 deletions acceptance/bundle/telemetry/config-remote-sync/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trace $CLI bundle deploy

job_id="$(read_id.py foo)"
edit_resource.py jobs $job_id <<EOF
r["name"] = "renamed remotely"
EOF

trace $CLI bundle config-remote-sync

trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null)'

rm out.requests.txt
Loading
Loading