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..c46bbfb2f89 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/output.txt @@ -0,0 +1,47 @@ + +>>> [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 job's python_file and the deployment state exist +>>> [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" +} + +>>> [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/state/deployment.json +{ + "object_type": "FILE", + "path": "/Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/state/deployment.json" +} + +=== 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 without changing any local file, so the stale sync snapshot is reused +>>> [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 redeploy: the files dir and state are recreated, but the python_file is NOT re-uploaded +>>> errcode [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files/hello_world.py +Error: Workspace path not found + +Exit code: 1 + +>>> [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files +{ + "object_type": "DIRECTORY", + "path": "/Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/files" +} + +>>> [CLI] workspace get-status /Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/state/deployment.json +{ + "object_type": "FILE", + "path": "/Workspace/Users/[USERNAME]/.bundle/out-of-band-delete/default/state/deployment.json" +} 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..46b95a26528 --- /dev/null +++ b/acceptance/bundle/deploy/files/out-of-band-delete/script @@ -0,0 +1,31 @@ +# Redeploy after the remote bundle directory is deleted out-of-band (e.g. a user +# deletes it in the workspace UI). +# +# After such a deletion the next "bundle deploy" does not re-upload the bundle files: +# the local sync snapshot still records them as present remotely, and the remote +# deployment state that would otherwise reset the snapshot was deleted too, so the +# file sync computes an empty diff and uploads nothing. +# +# This test pins down the current behaviour: hello_world.py is missing from the +# workspace after the redeploy even though the deploy reports success. If the file +# sync is changed to re-upload in this case, the final get-status will succeed and +# this output is expected to change. + +BUNDLE_PATH="/Workspace/Users/${CURRENT_USER_NAME}/.bundle/out-of-band-delete/default" + +trace $CLI bundle deploy + +title "After the initial deploy the job's python_file and the deployment state exist" +trace $CLI workspace get-status "$BUNDLE_PATH/files/hello_world.py" | jq '{object_type,path}' +trace $CLI workspace get-status "$BUNDLE_PATH/state/deployment.json" | 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 without changing any local file, so the stale sync snapshot is reused" +trace $CLI bundle deploy + +title "After redeploy: the files dir and state are recreated, but the python_file is NOT re-uploaded" +trace errcode $CLI workspace get-status "$BUNDLE_PATH/files/hello_world.py" +trace $CLI workspace get-status "$BUNDLE_PATH/files" | jq '{object_type,path}' +trace $CLI workspace get-status "$BUNDLE_PATH/state/deployment.json" | jq '{object_type,path}'