diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/databricks.yml b/acceptance/bundle/deploy/files/out-of-band-delete/databricks.yml new file mode 100644 index 00000000000..a4c66846c58 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/databricks.yml @@ -0,0 +1,15 @@ +bundle: + name: out-of-band-delete + +resources: + jobs: + foo: + name: test-job + tasks: + - task_key: my_task + spark_python_task: + python_file: ./hello_world.py + new_cluster: + num_workers: 1 + spark_version: 13.3.x-snapshot-scala2.12 + node_type_id: i3.xlarge diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/hello_world.py b/acceptance/bundle/deploy/files/out-of-band-delete/hello_world.py new file mode 100644 index 00000000000..f301245e242 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/hello_world.py @@ -0,0 +1 @@ +print("Hello World!") diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/out.test.toml b/acceptance/bundle/deploy/files/out-of-band-delete/out.test.toml new file mode 100644 index 00000000000..f784a183258 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/out.test.toml @@ -0,0 +1,3 @@ +Local = true +Cloud = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/output.txt b/acceptance/bundle/deploy/files/out-of-band-delete/output.txt new file mode 100644 index 00000000000..8ac61e622b7 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/output.txt @@ -0,0 +1,41 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +=== After the initial deploy the python_file exists +>>> [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py +{ + "object_type": "FILE", + "path": "/Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py" +} + +=== Delete the remote bundle directory out-of-band (simulates deleting it in the UI) +>>> [CLI] workspace delete --recursive /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete + +=== Redeploy reuses the stale snapshot, so the python_file is NOT re-uploaded +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +>>> musterr [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py +Error: Workspace path not found + +=== Removing the sync snapshot forces a full re-upload, restoring the python_file +>>> rm -rf .databricks/bundle/default/sync-snapshots + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +>>> [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py +{ + "object_type": "FILE", + "path": "/Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py" +} diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/script b/acceptance/bundle/deploy/files/out-of-band-delete/script new file mode 100644 index 00000000000..183e58d04a2 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/script @@ -0,0 +1,21 @@ +# Reproduces https://github.com/databricks/cli/issues/1976: after the remote bundle +# files are deleted out-of-band, a plain redeploy does not re-upload them. + +BUNDLE_PATH="/Workspace/Users/${CURRENT_USER_NAME}/.bundle/out-of-band-delete/default" + +trace $CLI bundle deploy + +title "After the initial deploy the python_file exists" +trace $CLI workspace get-status "$BUNDLE_PATH/files/hello_world.py" | jq '{object_type,path}' + +title "Delete the remote bundle directory out-of-band (simulates deleting it in the UI)" +trace $CLI workspace delete --recursive "/Workspace/Users/${CURRENT_USER_NAME}/.bundle/out-of-band-delete" + +title "Redeploy reuses the stale snapshot, so the python_file is NOT re-uploaded" +trace $CLI bundle deploy +trace musterr $CLI workspace get-status "$BUNDLE_PATH/files/hello_world.py" + +title "Removing the sync snapshot forces a full re-upload, restoring the python_file" +trace rm -rf .databricks/bundle/default/sync-snapshots +trace $CLI bundle deploy +trace $CLI workspace get-status "$BUNDLE_PATH/files/hello_world.py" | jq '{object_type,path}' diff --git a/acceptance/bundle/deploy/files/out-of-band-delete/test.toml b/acceptance/bundle/deploy/files/out-of-band-delete/test.toml new file mode 100644 index 00000000000..6a62c44e94d --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/test.toml @@ -0,0 +1,9 @@ +Badness = "After the remote bundle files are deleted out-of-band, the next deploy does not re-upload them until the local sync snapshot is removed." + +[Env] +# This test passes absolute workspace paths like /Workspace/Users/.../hello_world.py +# as CLI arguments. On Windows the script runs under MSYS2, which rewrites such +# leading-slash arguments to Windows paths (e.g. C:/Program Files/Git/Workspace/...) +# before the CLI sees them, so workspace get-status would query the wrong path. +# Setting this environment variable disables that conversion. +MSYS_NO_PATHCONV = "1"