diff --git a/acceptance/bundle/deployment/bind/schema/databricks.yml b/acceptance/bundle/deployment/bind/schema/databricks.yml new file mode 100644 index 000000000..5236f6356 --- /dev/null +++ b/acceptance/bundle/deployment/bind/schema/databricks.yml @@ -0,0 +1,10 @@ +bundle: + name: bind-schema-test-$BUNDLE_UUID + +resources: + schemas: + schema1: + name: $SCHEMA_NAME + catalog_name: main + comment: This schema was created from DABs + diff --git a/acceptance/bundle/deployment/bind/schema/output.txt b/acceptance/bundle/deployment/bind/schema/output.txt new file mode 100644 index 000000000..f00043b2d --- /dev/null +++ b/acceptance/bundle/deployment/bind/schema/output.txt @@ -0,0 +1,38 @@ + +=== Bind schema test: +=== Substitute variables in the template: +=== Create a pre-defined schema: { + "full_name": "main.test-schema-[UUID]", + "catalog_name": "main", + "comment": null +} + +=== Bind schema: Updating deployment state... +Successfully bound databricks_schema with an id 'main.test-schema-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace + +=== Deploy bundle: Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-schema-test-[UUID]/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +=== Read the pre-defined schema: { + "full_name": "main.test-schema-[UUID]", + "catalog_name": "main", + "comment": "This schema was created from DABs" +} + +=== Unbind the schema: Updating deployment state... + +=== Destroy the bundle: All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/bind-schema-test-[UUID]/default + +Deleting files... +Destroy complete! + +=== Read the pre-defined schema again (expecting it still exists): { + "full_name": "main.test-schema-[UUID]", + "catalog_name": "main", + "comment": "This schema was created from DABs" +} + +=== Test cleanup: +=== Delete the pre-defined schema: 0 diff --git a/acceptance/bundle/deployment/bind/schema/script b/acceptance/bundle/deployment/bind/schema/script new file mode 100644 index 000000000..48094ebef --- /dev/null +++ b/acceptance/bundle/deployment/bind/schema/script @@ -0,0 +1,33 @@ +title "Bind schema test: " + +title "Substitute variables in the template: " +export BUNDLE_UUID=$(uuid) +export SCHEMA_NAME="test-schema-$(uuid)" +envsubst < databricks.yml > out.yml && mv out.yml databricks.yml + +title "Create a pre-defined schema: " +CATALOG_NAME=main +$CLI schemas create ${SCHEMA_NAME} ${CATALOG_NAME} | jq '{full_name, catalog_name, comment}' + +title "Bind schema: " +$CLI bundle deployment bind schema1 ${CATALOG_NAME}.${SCHEMA_NAME} --auto-approve + +title "Deploy bundle: " +$CLI bundle deploy --force-lock --auto-approve + +title "Read the pre-defined schema: " +$CLI schemas get ${CATALOG_NAME}.${SCHEMA_NAME} | jq '{full_name, catalog_name, comment}' + +title "Unbind the schema: " +$CLI bundle deployment unbind schema1 + +title "Destroy the bundle: " +$CLI bundle destroy --auto-approve + +title "Read the pre-defined schema again (expecting it still exists): " +$CLI schemas get ${CATALOG_NAME}.${SCHEMA_NAME} | jq '{full_name, catalog_name, comment}' + +title "Test cleanup: " +title "Delete the pre-defined schema: " +$CLI schemas delete ${CATALOG_NAME}.${SCHEMA_NAME} +echo $? \ No newline at end of file diff --git a/acceptance/bundle/deployment/bind/schema/test.toml b/acceptance/bundle/deployment/bind/schema/test.toml new file mode 100644 index 000000000..c67d1feed --- /dev/null +++ b/acceptance/bundle/deployment/bind/schema/test.toml @@ -0,0 +1,2 @@ +Cloud = true +Local = false \ No newline at end of file diff --git a/acceptance/script.prepare b/acceptance/script.prepare index ca47cdbff..4d2afb98c 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -59,3 +59,7 @@ withdir() { cd "$orig_dir" || return $? return $exit_code } + +uuid() { + python3 -c 'import uuid; print(uuid.uuid4())' +} \ No newline at end of file