Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions acceptance/bundle/invariant/configs/empty.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundle:
name: test-bundle-$UNIQUE_NAME
1 change: 1 addition & 0 deletions acceptance/bundle/invariant/continue_293/out.test.toml

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

61 changes: 61 additions & 0 deletions acceptance/bundle/invariant/delete/out.test.toml

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

1 change: 1 addition & 0 deletions acceptance/bundle/invariant/delete/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INPUT_CONFIG_OK
66 changes: 66 additions & 0 deletions acceptance/bundle/invariant/delete/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Invariant to test: deleting all resources from a deployed bundle leaves an empty plan and summary
# Additional checks: no internal errors / panics in validate/plan/deploy/destroy

# Copy data files to test directory
cp -r "$TESTDIR/../data/." . &> LOG.cp

# Run init script if present
INIT_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-init.sh"
if [ -f "$INIT_SCRIPT" ]; then
source "$INIT_SCRIPT" &> LOG.init
fi

envsubst < $TESTDIR/../configs/$INPUT_CONFIG > databricks.yml

cp databricks.yml LOG.config

# We redirect output rather than record it because some configs that are being tested may produce warnings
trace $CLI bundle validate &> LOG.validate
cat LOG.validate | contains.py '!panic' '!internal error' > /dev/null

cleanup() {
trace $CLI bundle destroy --auto-approve &> LOG.destroy
cat LOG.destroy | contains.py '!panic' '!internal error' > /dev/null

# Run cleanup script if present
CLEANUP_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-cleanup.sh"
if [ -f "$CLEANUP_SCRIPT" ]; then
source "$CLEANUP_SCRIPT" &> LOG.cleanup
fi
}

trap cleanup EXIT

# Deploy the config with all its resources
trace $CLI bundle deploy &> LOG.deploy
cat LOG.deploy | contains.py '!panic' '!internal error' > /dev/null

# Special message to fuzzer that generated config was fine.
# Any failures after this point will be considered as "bug detected" by fuzzer.
echo INPUT_CONFIG_OK

# Replace the config with an empty bundle, keeping only the bundle name so the
# deployment continues to target the same state root.
envsubst < $TESTDIR/../configs/empty.yml.tmpl > databricks.yml
cp databricks.yml LOG.config.empty

# Save a plan for the emptied config; the second variant deploys with it via --plan
$CLI bundle plan -o json > plan.json 2>LOG.plan_delete.err
cat LOG.plan_delete.err | contains.py '!panic' '!internal error' > /dev/null

# Deploy the emptied config, deleting all resources
trace $CLI bundle deploy --auto-approve $(readplanarg plan.json) &> LOG.deploy_delete
cat LOG.deploy_delete | contains.py '!panic' '!internal error' > /dev/null

# After deleting all resources, the plan must be empty (no drift, no resources)
$CLI bundle plan -o json > LOG.planjson 2>LOG.planjson.err
cat LOG.planjson.err | contains.py '!panic' '!internal error' > /dev/null
verify_no_drift.py LOG.planjson

$CLI bundle plan 2>LOG.plan.err | contains.py '!panic' '!internal error' 'Plan: 0 to add, 0 to change, 0 to delete, 0 unchanged' > LOG.plan
cat LOG.plan.err | contains.py '!panic' '!internal error' > /dev/null

# The summary must also report no resources
$CLI bundle summary -o json > LOG.summary 2>LOG.summary.err
cat LOG.summary.err | contains.py '!panic' '!internal error' > /dev/null
cat LOG.summary | jq -e '(.resources // {}) == {}' > /dev/null
1 change: 1 addition & 0 deletions acceptance/bundle/invariant/delete/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EnvMatrix.READPLAN = ["", "1"]
4 changes: 4 additions & 0 deletions acceptance/bundle/invariant/migrate/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ EnvMatrixExclude.no_grant_ref = ["INPUT_CONFIG=schema_grant_ref.yml.tmpl"]
# SQL warehouses currently failing with migration with permanent drift. TODO: fix this.
EnvMatrixExclude.no_sql_warehouse = ["INPUT_CONFIG=sql_warehouse.yml.tmpl"]

# The empty bundle has no resources, so the terraform deploy writes no state and
# there is nothing for "bundle deployment migrate" to migrate.
EnvMatrixExclude.no_empty = ["INPUT_CONFIG=empty.yml.tmpl"]

# The 1000-task scale case is covered by no_drift. Running it here adds ~1.5 min
# per variant (deploy + migrate + plan at 1000 tasks) without incremental coverage.
EnvMatrixExclude.no_pydabs_1000_tasks = ["INPUT_CONFIG=job_pydabs_1000_tasks.yml.tmpl"]
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/invariant/no_drift/out.test.toml

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

1 change: 1 addition & 0 deletions acceptance/bundle/invariant/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ EnvMatrix.INPUT_CONFIG = [
"database_catalog.yml.tmpl",
"database_instance.yml.tmpl",
"database_instance_with_permissions.yml.tmpl",
"empty.yml.tmpl",
"experiment.yml.tmpl",
"external_location.yml.tmpl",
"genie_space.yml.tmpl",
Expand Down
Loading