Skip to content

Commit 256adaa

Browse files
authored
Add invariant test for "deployment migrate" (#4421)
## Why This detects mutliples resources that cannot be migrated, secret scopes, database instances, database catalogs, synced database tables.
1 parent 994c9d7 commit 256adaa

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

acceptance/bundle/invariant/migrate/out.test.toml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT_CONFIG_OK
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Invariant to test: migrate is successful, no drift after deploy
2+
# Additional checks: no internal errors / panics in any commands
3+
4+
unset DATABRICKS_BUNDLE_ENGINE
5+
6+
# Copy data files to test directory
7+
cp -r "$TESTDIR/../data/." . &> LOG.cp
8+
9+
# Run init script if present
10+
INIT_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-init.sh"
11+
if [ -f "$INIT_SCRIPT" ]; then
12+
source "$INIT_SCRIPT" &> LOG.init
13+
fi
14+
15+
envsubst < $TESTDIR/../configs/$INPUT_CONFIG > databricks.yml
16+
17+
cp databricks.yml LOG.config
18+
19+
cleanup() {
20+
trace $CLI bundle destroy --auto-approve &> LOG.destroy
21+
cat LOG.destroy | contains.py '!panic' '!internal error' > /dev/null
22+
23+
# Run cleanup script if present
24+
CLEANUP_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-cleanup.sh"
25+
if [ -f "$CLEANUP_SCRIPT" ]; then
26+
source "$CLEANUP_SCRIPT" &> LOG.cleanup
27+
fi
28+
}
29+
30+
trap cleanup EXIT
31+
32+
trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle deploy &> LOG.deploy
33+
cat LOG.deploy | contains.py '!panic' '!internal error' > /dev/null
34+
35+
echo INPUT_CONFIG_OK
36+
37+
trace $CLI bundle deployment migrate &> LOG.migrate
38+
39+
cat LOG.migrate | contains.py '!panic' '!internal error' > /dev/null
40+
41+
$CLI bundle plan -o json &> plan.json
42+
cat plan.json | contains.py '!panic' '!internal error' > /dev/null
43+
verify_no_drift.py plan.json
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Unexpected action='create' for resources.secret_scopes.foo.permissions
2+
EnvMatrixExclude.no_secret_scope = ["INPUT_CONFIG=secret_scope.yml.tmpl"]
3+
4+
# Error: cannot plan resources.database_instances.foo: invalid state empty id
5+
EnvMatrixExclude.no_database_instance = ["INPUT_CONFIG=database_instance.yml.tmpl"]
6+
EnvMatrixExclude.no_database_catalog = ["INPUT_CONFIG=database_catalog.yml.tmpl"]
7+
EnvMatrixExclude.no_synced_database_table = ["INPUT_CONFIG=synced_database_table.yml.tmpl"]

0 commit comments

Comments
 (0)