Skip to content

Commit dc8ac14

Browse files
committed
Add acceptance test pinning plan suppression of policy-injected cluster fields
1 parent 175ea17 commit dc8ac14

5 files changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
bundle:
2+
name: test-bundle-$UNIQUE_NAME
3+
4+
targets:
5+
default:
6+
mode: development
7+
8+
resources:
9+
jobs:
10+
job1:
11+
max_concurrent_runs: 1
12+
job_clusters:
13+
- job_cluster_key: shared
14+
new_cluster:
15+
spark_version: $DEFAULT_SPARK_VERSION
16+
node_type_id: $NODE_TYPE_ID
17+
num_workers: 1
18+
tasks:
19+
- task_key: shared_cluster_task
20+
job_cluster_key: shared
21+
notebook_task:
22+
notebook_path: /Users/{{workspace_user_name}}/notebook
23+
- task_key: own_cluster_task
24+
notebook_task:
25+
notebook_path: /Users/{{workspace_user_name}}/notebook
26+
new_cluster:
27+
spark_version: $DEFAULT_SPARK_VERSION
28+
node_type_id: $NODE_TYPE_ID
29+
num_workers: 1

acceptance/bundle/resources/jobs/policy_injected_cluster_fields/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files...
2+
Deploying resources...
3+
Updating deployment state...
4+
Deployment complete!
5+
6+
=== Simulate a cluster policy injecting custom_tags and cluster_log_conf
7+
These fields exist only remotely (the user never set them in config).
8+
9+
=== Plan after injection: policy-injected fields alone must not produce an update
10+
>>> [CLI] bundle plan
11+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
12+
13+
=== A real remote edit must still be detected
14+
>>> [CLI] bundle plan
15+
update jobs.job1
16+
17+
Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
18+
19+
>>> [CLI] bundle destroy --auto-approve
20+
The following resources will be deleted:
21+
delete resources.jobs.job1
22+
23+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default
24+
25+
Deleting files...
26+
Destroy complete!
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
envsubst < databricks.yml.tmpl > databricks.yml
4+
5+
cleanup() {
6+
trace $CLI bundle destroy --auto-approve
7+
}
8+
trap cleanup EXIT
9+
10+
$CLI bundle deploy
11+
job_id="$(read_id.py job1)"
12+
13+
title "Simulate a cluster policy injecting custom_tags and cluster_log_conf"
14+
echo
15+
echo "These fields exist only remotely (the user never set them in config)."
16+
edit_resource.py jobs $job_id <<'PYEOF'
17+
# A DBFS destination is used instead of S3: the real backend rejects an S3
18+
# cluster log destination without a per-cluster instance-profile ARN.
19+
policy_tags = {"CostCenter": "dev-1234", "Team": "finops"}
20+
policy_log_conf = {"dbfs": {"destination": "dbfs:/cluster-logs/dev"}}
21+
22+
for task in r.get("tasks", []):
23+
if "new_cluster" in task:
24+
task["new_cluster"]["custom_tags"] = dict(policy_tags)
25+
task["new_cluster"]["cluster_log_conf"] = dict(policy_log_conf)
26+
27+
for jc in r.get("job_clusters", []):
28+
jc["new_cluster"]["custom_tags"] = dict(policy_tags)
29+
jc["new_cluster"]["cluster_log_conf"] = dict(policy_log_conf)
30+
PYEOF
31+
32+
title "Plan after injection: policy-injected fields alone must not produce an update"
33+
trace $CLI bundle plan
34+
35+
title "A real remote edit must still be detected"
36+
edit_resource.py jobs $job_id <<'PYEOF'
37+
r["max_concurrent_runs"] = 5
38+
PYEOF
39+
40+
trace $CLI bundle plan
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Cloud = true
2+
3+
RecordRequests = false
4+
Ignore = [".databricks", "databricks.yml"]
5+
6+
# The suppression under test is the direct engine's backend_defaults
7+
# classification of policy-injected fields; the terraform engine delegates
8+
# these diffs to the terraform provider.
9+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]

0 commit comments

Comments
 (0)