Skip to content

Commit e7d7525

Browse files
authored
Replace old Spark Jar integration tests with an acceptance test (#5191)
## Changes Replace old Spark Jar integration tests with an acceptance test ## Why We don't need to test the matric of DBR / Java / Spark versions anymore and instead can just rely on an acceptance test for LTS DBR ## Tests Added an acceptance test which pass on both Cloud and Local <!-- 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 42a9c25 commit e7d7525

13 files changed

Lines changed: 74 additions & 324 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
bundle:
2+
name: spark-jar-task-$UNIQUE_NAME
3+
4+
artifacts:
5+
my_java_code:
6+
path: ./myjar
7+
build: "javac PrintArgs.java && jar cvfm PrintArgs.jar META-INF/MANIFEST.MF PrintArgs.class"
8+
files:
9+
- source: ./myjar/PrintArgs.jar
10+
11+
resources:
12+
jobs:
13+
jar_job:
14+
name: "[${bundle.target}] Test Spark Jar Job $UNIQUE_NAME"
15+
tasks:
16+
- task_key: TestSparkJarTask
17+
new_cluster:
18+
num_workers: 1
19+
spark_version: 16.4.x-scala2.12
20+
node_type_id: $NODE_TYPE_ID
21+
instance_pool_id: $TEST_INSTANCE_POOL_ID
22+
data_security_mode: NONE
23+
spark_jar_task:
24+
main_class_name: PrintArgs
25+
libraries:
26+
- jar: ./myjar/PrintArgs.jar

integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF renamed to acceptance/bundle/deploy/spark-jar-task/myjar/META-INF/MANIFEST.MF

File renamed without changes.

integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java renamed to acceptance/bundle/deploy/spark-jar-task/myjar/PrintArgs.java

File renamed without changes.

acceptance/bundle/deploy/spark-jar-task/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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
>>> [CLI] bundle deploy
3+
Building my_java_code...
4+
Uploading myjar/PrintArgs.jar...
5+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/spark-jar-task-[UNIQUE_NAME]/default/files...
6+
Deploying resources...
7+
Updating deployment state...
8+
Deployment complete!
9+
10+
>>> [CLI] bundle run jar_job
11+
Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID]
12+
13+
[TIMESTAMP] "[default] Test Spark Jar Job [UNIQUE_NAME]" RUNNING
14+
[TIMESTAMP] "[default] Test Spark Jar Job [UNIQUE_NAME]" TERMINATED SUCCESS
15+
Hello from Jar!
16+
[]
17+
>>> [CLI] bundle destroy --auto-approve
18+
The following resources will be deleted:
19+
delete resources.jobs.jar_job
20+
21+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/spark-jar-task-[UNIQUE_NAME]/default
22+
23+
Deleting files...
24+
Destroy complete!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT
3+
trace $CLI bundle deploy
4+
trace $CLI bundle run jar_job
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Local = true
2+
Cloud = true
3+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"]
4+
5+
Ignore = [
6+
'myjar/PrintArgs.jar',
7+
'myjar/PrintArgs.class',
8+
]
9+
10+
[[Server]]
11+
Pattern = "GET /api/2.2/jobs/runs/get-output"
12+
Response.Body = '''
13+
{
14+
"run_id": 1234567890,
15+
"logs": "Hello from Jar!\n[]"
16+
}
17+
'''

integration/bundle/bundles/spark_jar_task/databricks_template_schema.json

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

integration/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl

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

integration/bundle/helpers_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ func deployBundle(t testutil.TestingT, ctx context.Context, path string) {
6767
require.NoError(t, err)
6868
}
6969

70-
func runResource(t testutil.TestingT, ctx context.Context, path, key string) (string, error) {
71-
ctx = env.Set(ctx, "BUNDLE_ROOT", path)
72-
c := testcli.NewRunner(t, ctx, "bundle", "run", key)
73-
stdout, _, err := c.Run()
74-
return stdout.String(), err
75-
}
76-
7770
func destroyBundle(t testutil.TestingT, ctx context.Context, path string) {
7871
ctx = env.Set(ctx, "BUNDLE_ROOT", path)
7972
c := testcli.NewRunner(t, ctx, "bundle", "destroy", "--auto-approve")

0 commit comments

Comments
 (0)