Skip to content

Commit 164b6d4

Browse files
authored
acc: Add test for stale wheel problem (#2477)
This tests record current situation with wheel refresh on databricks clusters. See #2427 for background on "stale wheel" problem.
1 parent afa253c commit 164b6d4

File tree

8 files changed

+154
-1
lines changed

8 files changed

+154
-1
lines changed

acceptance/bin/update_file.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Usage: update_file.py FILENAME OLD NEW
4+
5+
Replace all strings OLD with NEW in FILENAME.
6+
7+
If OLD is not found in FILENAME, the script reports error.
8+
"""
9+
10+
import sys
11+
12+
filename, old, new = sys.argv[1:]
13+
data = open(filename).read()
14+
newdata = data.replace(old, new)
15+
if newdata == data:
16+
sys.exit(f"{old=} not found in {filename=}\n{data}")
17+
with open(filename, "w") as fobj:
18+
fobj.write(newdata)

acceptance/bundle/integration_whl/base/output.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ Hello from my func
4747
Got arguments:
4848
['my_test_code', 'one', 'two']
4949

50+
=== Make a change to code without version change and run the job again
51+
>>> [CLI] bundle deploy
52+
Building python_artifact...
53+
Uploading my_test_code-0.0.1-py3-none-any.whl...
54+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
55+
Deploying resources...
56+
Updating deployment state...
57+
Deployment complete!
58+
59+
>>> [CLI] bundle run some_other_job
60+
Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID]
61+
62+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING
63+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS
64+
UPDATED MY FUNC
65+
Got arguments:
66+
['my_test_code', 'one', 'two']
67+
5068
>>> [CLI] bundle destroy --auto-approve
5169
The following resources will be deleted:
5270
delete job some_other_job

acceptance/bundle/integration_whl/base/script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ trace cat databricks.yml
44
trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT
55
trace $CLI bundle deploy
66
trace $CLI bundle run some_other_job
7+
8+
title "Make a change to code without version change and run the job again"
9+
update_file.py my_test_code/__main__.py 'Hello from my func' 'UPDATED MY FUNC'
10+
trace $CLI bundle deploy
11+
trace $CLI bundle run some_other_job

acceptance/bundle/integration_whl/interactive_cluster/databricks.yml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resources:
1111
spark_version: "$DEFAULT_SPARK_VERSION"
1212
node_type_id: "$NODE_TYPE_ID"
1313
num_workers: 1
14-
data_security_mode: USER_ISOLATION
14+
data_security_mode: $DATA_SECURITY_MODE
1515

1616
jobs:
1717
some_other_job:

acceptance/bundle/integration_whl/interactive_cluster/output.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ Hello from my func
4747
Got arguments:
4848
['my_test_code', 'one', 'two']
4949

50+
=== Make a change to code without version change and run the job again
51+
>>> [CLI] bundle deploy
52+
Building python_artifact...
53+
Uploading my_test_code-0.0.1-py3-none-any.whl...
54+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
55+
Deploying resources...
56+
Updating deployment state...
57+
Deployment complete!
58+
59+
>>> [CLI] bundle run some_other_job
60+
Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID]
61+
62+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING
63+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS
64+
Hello from my func
65+
Got arguments:
66+
['my_test_code', 'one', 'two']
67+
5068
>>> [CLI] bundle destroy --auto-approve
5169
The following resources will be deleted:
5270
delete cluster test_cluster
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
export DATA_SECURITY_MODE=USER_ISOLATION
12
envsubst < databricks.yml.tmpl > databricks.yml
23
trace cat databricks.yml
34
trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT
45
trace $CLI bundle deploy
56
trace $CLI bundle run some_other_job
7+
8+
title "Make a change to code without version change and run the job again"
9+
update_file.py my_test_code/__main__.py 'Hello from my func' 'UPDATED MY FUNC'
10+
trace $CLI bundle deploy
11+
trace $CLI bundle run some_other_job
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
>>> cat databricks.yml
3+
bundle:
4+
name: wheel-task
5+
6+
workspace:
7+
root_path: "~/.bundle/[UNIQUE_NAME]"
8+
9+
resources:
10+
clusters:
11+
test_cluster:
12+
cluster_name: "test-cluster-[UNIQUE_NAME]"
13+
spark_version: "13.3.x-snapshot-scala2.12"
14+
node_type_id: "[NODE_TYPE_ID]"
15+
num_workers: 1
16+
data_security_mode: SINGLE_USER
17+
18+
jobs:
19+
some_other_job:
20+
name: "[${bundle.target}] Test Wheel Job [UNIQUE_NAME]"
21+
tasks:
22+
- task_key: TestTask
23+
existing_cluster_id: "${resources.clusters.test_cluster.cluster_id}"
24+
python_wheel_task:
25+
package_name: my_test_code
26+
entry_point: run
27+
parameters:
28+
- "one"
29+
- "two"
30+
libraries:
31+
- whl: ./dist/*.whl
32+
33+
>>> [CLI] bundle deploy
34+
Building python_artifact...
35+
Uploading my_test_code-0.0.1-py3-none-any.whl...
36+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
37+
Deploying resources...
38+
Updating deployment state...
39+
Deployment complete!
40+
41+
>>> [CLI] bundle run some_other_job
42+
Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID]
43+
44+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING
45+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS
46+
Hello from my func
47+
Got arguments:
48+
['my_test_code', 'one', 'two']
49+
50+
=== Make a change to code without version change and run the job again
51+
>>> [CLI] bundle deploy
52+
Building python_artifact...
53+
Uploading my_test_code-0.0.1-py3-none-any.whl...
54+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
55+
Deploying resources...
56+
Updating deployment state...
57+
Deployment complete!
58+
59+
>>> [CLI] bundle run some_other_job
60+
Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID]
61+
62+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING
63+
[TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS
64+
UPDATED MY FUNC
65+
Got arguments:
66+
['my_test_code', 'one', 'two']
67+
68+
>>> [CLI] bundle destroy --auto-approve
69+
The following resources will be deleted:
70+
delete cluster test_cluster
71+
delete job some_other_job
72+
73+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]
74+
75+
Deleting files...
76+
Destroy complete!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export DATA_SECURITY_MODE=SINGLE_USER
2+
envsubst < $TESTDIR/../interactive_cluster/databricks.yml.tmpl > databricks.yml
3+
trace cat databricks.yml
4+
cp -r $TESTDIR/../interactive_cluster/{setup.py,my_test_code} .
5+
trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT
6+
trace $CLI bundle deploy
7+
trace $CLI bundle run some_other_job
8+
9+
title "Make a change to code without version change and run the job again"
10+
update_file.py my_test_code/__main__.py 'Hello from my func' 'UPDATED MY FUNC'
11+
trace $CLI bundle deploy
12+
trace $CLI bundle run some_other_job

0 commit comments

Comments
 (0)