Skip to content

Commit bec9838

Browse files
authored
Clean up tests for references pointing to non-existing items (#4200)
## Changes - Update resource_deps/missing_ingestion_definition to fix reference syntax in databricks.yml for terraform - Merge missing_map_key_tffix into missing_map_key test. - Clean up incorrect Badness. ## Why Easier to compara behaviour between terraform in direct.
1 parent 32295be commit bec9838

24 files changed

+117
-127
lines changed

acceptance/bundle/resource_deps/missing_ingestion_definition/databricks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ resources:
66
foo:
77
name: pfoo
88
bar:
9-
name: pbar ${resources.pipelines.foo.ingestion_definition.connection_name}
9+
name: pbar ${resources.pipelines.foo.ingestion_definition.connection_name} # direct engine syntax
10+
#terraform syntax: name: pbar ${resources.pipelines.foo.ingestion_definition[0].connection_name}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Error: exit status 1
22

3-
Error: Invalid operation
3+
Error: Invalid index
44

55
on bundle.tf.json line 22, in resource.databricks_pipeline.bar:
6-
22: "name": "pbar ${databricks_pipeline.foo.ingestion_definition.connection_name}"
6+
22: "name": "pbar ${databricks_pipeline.foo.ingestion_definition[0].connection_name}"
7+
├────────────────
8+
│ databricks_pipeline.foo.ingestion_definition is empty list of object
79

8-
Block type "ingestion_definition" is represented by a list of objects, so it
9-
must be indexed using a numeric key, like .ingestion_definition[0].
10+
The given key does not identify an element in this collection value: the
11+
collection has no elements.
1012

1113

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bar": {
3+
"channel": "CURRENT",
4+
"deployment": {
5+
"kind": "BUNDLE",
6+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
7+
},
8+
"edition": "ADVANCED",
9+
"name": "pbar ${resources.pipelines.foo.ingestion_definition.connection_name}"
10+
},
11+
"foo": {
12+
"channel": "CURRENT",
13+
"deployment": {
14+
"kind": "BUNDLE",
15+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
16+
},
17+
"edition": "ADVANCED",
18+
"name": "pfoo"
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bar": {
3+
"channel": "CURRENT",
4+
"deployment": {
5+
"kind": "BUNDLE",
6+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
7+
},
8+
"edition": "ADVANCED",
9+
"name": "pbar ${resources.pipelines.foo.ingestion_definition[0].connection_name}"
10+
},
11+
"foo": {
12+
"channel": "CURRENT",
13+
"deployment": {
14+
"kind": "BUNDLE",
15+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
16+
},
17+
"edition": "ADVANCED",
18+
"name": "pfoo"
19+
}
20+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
"pbar ${resources.pipelines.foo.ingestion_definition.connection_name}"
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
$CLI bundle validate -o json | jq .resources.pipelines.bar.name
1+
if [ "$DATABRICKS_BUNDLE_ENGINE" = "terraform" ]; then
2+
grep -v "# direct engine syntax" databricks.yml > databricks.yml.tmp
3+
update_file.py databricks.yml.tmp "#terraform syntax: " ""
4+
mv databricks.yml.tmp databricks.yml
5+
fi
6+
7+
$CLI bundle validate -o json | jq .resources.pipelines > out.validate.$DATABRICKS_BUNDLE_ENGINE.json
28
musterr $CLI bundle plan &> out.plan.$DATABRICKS_BUNDLE_ENGINE.txt

acceptance/bundle/resource_deps/missing_map_key/databricks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ resources:
1111
custom_tags:
1212
ResourceClass: SingleNode
1313
bar:
14-
name: "test ${resources.jobs.test.tasks[0].new_cluster.custom_tags.missing_tag}"
14+
name: "test ${resources.jobs.test.tasks[0].new_cluster.custom_tags.missing_tag}" # direct engine syntax
15+
#terraform syntax: name: "test ${resources.jobs.test.task[0].new_cluster[0].custom_tags.missing_tag}"
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/state/default/files...
22
Error: exit status 1
33

4-
Error: Unsupported attribute
4+
Error: Missing map element
55

66
on bundle.tf.json line 23, in resource.databricks_job.bar:
7-
23: "name": "test ${databricks_job.test.tasks[0].new_cluster.custom_tags.missing_tag}",
7+
23: "name": "test ${databricks_job.test.task[0].new_cluster[0].custom_tags.missing_tag}",
8+
├────────────────
9+
│ databricks_job.test.task[0].new_cluster[0].custom_tags is map of string with 1 element
810

9-
This object has no argument, nested block, or exported attribute named
10-
"tasks". Did you mean "tags"?
11+
This map does not have an element with the key "missing_tag".
1112

1213

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Error: exit status 1
22

3-
Error: Unsupported attribute
3+
Error: Missing map element
44

55
on bundle.tf.json line 23, in resource.databricks_job.bar:
6-
23: "name": "test ${databricks_job.test.tasks[0].new_cluster.custom_tags.missing_tag}",
6+
23: "name": "test ${databricks_job.test.task[0].new_cluster[0].custom_tags.missing_tag}",
7+
├────────────────
8+
│ databricks_job.test.task[0].new_cluster[0].custom_tags is map of string with 1 element
79

8-
This object has no argument, nested block, or exported attribute named
9-
"tasks". Did you mean "tags"?
10+
This map does not have an element with the key "missing_tag".
1011

1112

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"jobs": {
3+
"bar": {
4+
"deployment": {
5+
"kind": "BUNDLE",
6+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/state/default/state/metadata.json"
7+
},
8+
"edit_mode": "UI_LOCKED",
9+
"format": "MULTI_TASK",
10+
"max_concurrent_runs": 1,
11+
"name": "test ${resources.jobs.test.tasks[0].new_cluster.custom_tags.missing_tag}",
12+
"queue": {
13+
"enabled": true
14+
}
15+
},
16+
"test": {
17+
"deployment": {
18+
"kind": "BUNDLE",
19+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/state/default/state/metadata.json"
20+
},
21+
"edit_mode": "UI_LOCKED",
22+
"format": "MULTI_TASK",
23+
"max_concurrent_runs": 1,
24+
"name": "test",
25+
"queue": {
26+
"enabled": true
27+
},
28+
"tasks": [
29+
{
30+
"new_cluster": {
31+
"custom_tags": {
32+
"ResourceClass": "SingleNode"
33+
}
34+
},
35+
"task_key": "test-task"
36+
}
37+
]
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)