Skip to content

Commit 0aca1bc

Browse files
authored
Convert TestJobsMetadataFile to an acceptance test (#2925)
## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> One change in the series of changes for converting integration tests into acceptance tests. This will allow for easier testing of various backing solutions for bundle deployment
1 parent a9b7c4c commit 0aca1bc

File tree

9 files changed

+113
-120
lines changed

9 files changed

+113
-120
lines changed

integration/bundle/bundles/job_metadata/template/a/b/bar.py renamed to acceptance/bundle/deploy/jobs/check-metadata/a/b/bar.py

File renamed without changes.

integration/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl renamed to acceptance/bundle/deploy/jobs/check-metadata/a/b/resources.yml.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
resources:
22
jobs:
33
bar:
4-
name: test-job-metadata-2-{{.unique_id}}
4+
name: test-job-metadata-2-$UNIQUE_NAME
55
tasks:
66
- task_key: my_notebook_task
77
new_cluster:
88
num_workers: 1
9-
spark_version: "{{.spark_version}}"
10-
node_type_id: "{{.node_type_id}}"
9+
spark_version: $DEFAULT_SPARK_VERSION
10+
node_type_id: $NODE_TYPE_ID
1111
notebook_task:
1212
notebook_path: "./bar.py"

integration/bundle/bundles/job_metadata/template/databricks.yml.tmpl renamed to acceptance/bundle/deploy/jobs/check-metadata/databricks.yml.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
bundle:
2-
name: job-metadata
2+
name: deploy-jobs-check-metadata-$UNIQUE_NAME
33

44
workspace:
5-
root_path: "~/.bundle/{{.unique_id}}"
5+
root_path: ~/.bundle/$UNIQUE_NAME
66

77
include:
88
- "a/b/*.yml"
99

1010
resources:
1111
jobs:
1212
foo:
13-
name: test-job-metadata-1-{{.unique_id}}
13+
name: test-job-metadata-1-$UNIQUE_NAME
1414
tasks:
1515
- task_key: my_notebook_task
1616
new_cluster:
1717
num_workers: 1
18-
spark_version: "{{.spark_version}}"
19-
node_type_id: "{{.node_type_id}}"
18+
spark_version: $DEFAULT_SPARK_VERSION
19+
node_type_id: $NODE_TYPE_ID
2020
notebook_task:
2121
notebook_path: "./foo.py"
File renamed without changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
=== Assert job 1 is created
9+
{
10+
"name": "test-job-metadata-1-[UNIQUE_NAME]"
11+
}
12+
13+
=== Assert job 2 is created
14+
{
15+
"name": "test-job-metadata-2-[UNIQUE_NAME]"
16+
}
17+
18+
=== Read metadata object from the workspace
19+
>>> [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/state/metadata.json
20+
21+
>>> cat metadata.json
22+
{
23+
"version": 1,
24+
"config": {
25+
"bundle": {
26+
"git": {
27+
"bundle_root_path": "."
28+
}
29+
},
30+
"workspace": {
31+
"file_path": "/Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files"
32+
},
33+
"resources": {
34+
"jobs": {
35+
"bar": {
36+
"id": "[NUMID]",
37+
"relative_path": "a/b/resources.yml"
38+
},
39+
"foo": {
40+
"id": "[NUMID]",
41+
"relative_path": "databricks.yml"
42+
}
43+
}
44+
}
45+
}
46+
}
47+
=== Check that metadata contains created job ids
48+
>>> cat metadata.json
49+
"id": "[NUMID]",
50+
51+
>>> cat metadata.json
52+
"id": "[NUMID]",
53+
54+
>>> [CLI] bundle destroy --auto-approve
55+
The following resources will be deleted:
56+
delete job bar
57+
delete job foo
58+
59+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]
60+
61+
Deleting files...
62+
Destroy complete!
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
envsubst < a/b/resources.yml.tmpl > a/b/resources.yml
3+
4+
cleanup() {
5+
trace $CLI bundle destroy --auto-approve
6+
}
7+
trap cleanup EXIT
8+
9+
trace $CLI bundle deploy
10+
11+
title "Assert job 1 is created\n"
12+
JOB_1_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.foo.id')
13+
$CLI jobs get "${JOB_1_ID}" | jq '{name: .settings.name}'
14+
15+
title "Assert job 2 is created\n"
16+
JOB_2_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.bar.id')
17+
$CLI jobs get "${JOB_2_ID}" | jq '{name: .settings.name}'
18+
19+
title "Read metadata object from the workspace"
20+
trace $CLI workspace export "/Workspace/Users/${CURRENT_USER_NAME}/.bundle/${UNIQUE_NAME}/state/metadata.json" > metadata.json
21+
trace cat metadata.json
22+
23+
title "Check that metadata contains created job ids"
24+
trace cat metadata.json | grep "${JOB_1_ID}"
25+
trace cat metadata.json | grep "${JOB_2_ID}"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Local = false
2+
Cloud = true
3+
4+
Ignore = [
5+
"databricks.yml",
6+
"a/b/resources.yml",
7+
"metadata.json",
8+
]
9+
10+
[Env]
11+
# MSYS2 automatically converts absolute paths like /Users/$username/$UNIQUE_NAME to
12+
# C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI
13+
# Setting this environment variable prevents that conversion on windows.
14+
MSYS_NO_PATHCONV = "1"
15+
16+
[[Repls]]
17+
Old = "[0-9]{12,}"
18+
New = "[NUMID]"

integration/bundle/bundles/job_metadata/databricks_template_schema.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

integration/bundle/job_metadata_test.go

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)