diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl new file mode 100644 index 00000000000..38ebb44dd69 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl @@ -0,0 +1,45 @@ +bundle: + name: test-bundle-$UNIQUE_NAME + +# cluster_id makes OverrideCompute clear job_cluster_key, so the merged config +# has no value for it even though the YAML still declares it. + +variables: + cluster_key: + default: shared + cluster: + type: complex + default: + spark_version: 13.3.x-scala2.12 + num_workers: 1 + +resources: + jobs: + my_job: + job_clusters: + - job_cluster_key: shared + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 1 + - job_cluster_key: other + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 2 + tasks: + - task_key: main + job_cluster_key: shared + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + - task_key: by_variable + job_cluster_key: ${var.cluster_key} + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + - task_key: by_complex_variable + new_cluster: ${var.cluster} + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +targets: + dev: + mode: development + cluster_id: 0101-000000-override diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml new file mode 100644 index 00000000000..8c2cb31de53 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt new file mode 100644 index 00000000000..791fb3d8d54 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt @@ -0,0 +1,55 @@ +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files... +Created jobs.my_job +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +=== Move the tasks back to job clusters remotely + +=== Sync replaces the job_cluster_key the YAML already has and keeps the variables + +>>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='by_complex_variable'].existing_cluster_id: remove + tasks[task_key='by_complex_variable'].new_cluster: skip + tasks[task_key='by_variable'].existing_cluster_id: remove + tasks[task_key='by_variable'].job_cluster_key: replace + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -28,5 +28,5 @@ + tasks: + - task_key: main +- job_cluster_key: shared ++ job_cluster_key: other + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +=== The override still clears job_cluster_key, so the next sync detects it again + +>>> [CLI] bundle config-remote-sync -t dev +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='by_complex_variable'].existing_cluster_id: remove + tasks[task_key='by_complex_variable'].new_cluster: skip + tasks[task_key='by_variable'].existing_cluster_id: remove + tasks[task_key='by_variable'].job_cluster_key: replace + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: replace + + + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script new file mode 100644 index 00000000000..ebd93d2dc82 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script @@ -0,0 +1,24 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the tasks back to job clusters remotely" +edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='defines_inside'].existing_cluster_id: remove + tasks[task_key='defines_inside'].job_cluster_key: add + tasks[task_key='from_inside'].existing_cluster_id: remove + tasks[task_key='from_inside'].job_cluster_key: add + tasks[task_key='from_outside'].existing_cluster_id: remove + tasks[task_key='from_outside'].job_cluster_key: add + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -22,17 +22,20 @@ + num_workers: 2 + tasks: +- - <<: *outside ++ - !!merge <<: *outside + task_key: from_outside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb +- - <<: &inside ++ job_cluster_key: other ++ - !!merge <<: &inside + job_cluster_key: shared + task_key: defines_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb +- - <<: *inside ++ job_cluster_key: other ++ - !!merge <<: *inside + task_key: from_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb ++ job_cluster_key: other + + targets: + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script new file mode 100644 index 00000000000..b541a56d6c6 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script @@ -0,0 +1,18 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the tasks back to job clusters remotely" +edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + max_concurrent_runs: replace + + + +>>> diff.py databricks.yml.backup databricks.yml + +>>> [CLI] bundle validate -t dev -o json +{"max_concurrent_runs":2,"timeout_seconds":2} + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/anchored_override_field/script b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script new file mode 100644 index 00000000000..47c15a94531 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script @@ -0,0 +1,17 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Change the field remotely" +edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -33,4 +33,4 @@ + tasks: + - task_key: main +- job_cluster_key: shared ++ job_cluster_key: other + max_retries: 1 + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/cleared_key_override/script b/acceptance/bundle/config-remote-sync/split/cleared_key_override/script new file mode 100644 index 00000000000..4b53bcb8b11 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/cleared_key_override/script @@ -0,0 +1,18 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the task to another job cluster remotely" +edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + max_concurrent_runs: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -19,3 +19,3 @@ + jobs: + my_job: +- max_concurrent_runs: 2 ++ max_concurrent_runs: 10 + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script new file mode 100644 index 00000000000..c7b81294d13 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script @@ -0,0 +1,16 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Change the field remotely" +edit_resource.py jobs $job_id <