Skip to content

Commit 071b584

Browse files
authored
acc: Add a test to deploy a job with missing git_provider field (#3937)
## Changes Add a test to deploy a job with missing git_provider field ## Why While `git_provider` field is required and we emit the warning that it's missing, the behaviour on TF and direct is different in this case: TF successfully deploys such a bundle because it infers provider from URL (https://github.com/databricks/terraform-provider-databricks/blob/main/jobs/resource_job.go#L805) while direct fails the deployment <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent f5cd1b7 commit 071b584

File tree

9 files changed

+89
-0
lines changed

9 files changed

+89
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
bundle:
2+
name: no-git-provider-$UNIQUE_NAME
3+
4+
workspace:
5+
root_path: ~/.bundle/$UNIQUE_NAME
6+
7+
resources:
8+
jobs:
9+
foo:
10+
name: foo-$UNIQUE_NAME
11+
git_source:
12+
git_url: https://github.com/databricks/cli.git
13+
git_branch: main
14+
15+
tasks:
16+
- task_key: test_task
17+
notebook_task:
18+
notebook_path: some/test/notebook.py
19+
new_cluster:
20+
num_workers: 1
21+
spark_version: $DEFAULT_SPARK_VERSION
22+
node_type_id: $NODE_TYPE_ID
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
>>> errcode [CLI] bundle deploy --force-lock
3+
Warning: required field "git_provider" is not set
4+
at resources.jobs.foo.git_source
5+
in databricks.yml:12:9
6+
7+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
8+
Deploying resources...
9+
Error: cannot create resources.jobs.foo: git_source.git_provider must be one of: github,gitlab,bitbucketcloud,gitlabenterpriseedition,bitbucketserver,azuredevopsservices,githubenterprise,awscodecommit (400 INVALID_PARAMETER_VALUE)
10+
11+
Endpoint: POST [DATABRICKS_URL]/api/2.2/jobs/create
12+
HTTP Status: 400 Bad Request
13+
API error_code: INVALID_PARAMETER_VALUE
14+
API message: git_source.git_provider must be one of: github,gitlab,bitbucketcloud,gitlabenterpriseedition,bitbucketserver,azuredevopsservices,githubenterprise,awscodecommit
15+
16+
Updating deployment state...
17+
18+
Exit code: 1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
>>> errcode [CLI] bundle deploy --force-lock
3+
Warning: required field "git_provider" is not set
4+
at resources.jobs.foo.git_source
5+
in databricks.yml:12:9
6+
7+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
8+
Deploying resources...
9+
Updating deployment state...
10+
Deployment complete!
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
>>> errcode [CLI] bundle destroy --auto-approve
3+
Warning: required field "git_provider" is not set
4+
at resources.jobs.foo.git_source
5+
in databricks.yml:12:9
6+
7+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]
8+
9+
Deleting files...
10+
Destroy complete!
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
>>> errcode [CLI] bundle destroy --auto-approve
3+
Warning: required field "git_provider" is not set
4+
at resources.jobs.foo.git_source
5+
in databricks.yml:12:9
6+
7+
The following resources will be deleted:
8+
delete job foo
9+
10+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]
11+
12+
Deleting files...
13+
Destroy complete!

acceptance/bundle/resources/jobs/no-git-provider/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/resources/jobs/no-git-provider/output.txt

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
3+
cleanup() {
4+
trace errcode $CLI bundle destroy --auto-approve > out.destroy.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1
5+
}
6+
trap cleanup EXIT
7+
trace errcode $CLI bundle deploy --force-lock > out.deploy.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Local = false
2+
Cloud = true
3+
4+
RecordRequests = false

0 commit comments

Comments
 (0)