Skip to content

Commit 1dc39ff

Browse files
authored
acc: extract common repls; support order for repls (#2972)
## Changes - New timestamp and number related replacements in root test.toml - New attribute on `[[Repls]]` object: Order. This defines order in which replacements are applied. - Remove `[TEST_JOB_ID+0]` replacement, little value and does not work when making test support both local and cloud. ## Why Different tests are re-doing the same work with different approaches, this adds standard way to do this.
1 parent 6d5f2a8 commit 1dc39ff

File tree

47 files changed

+180
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+180
-169
lines changed

acceptance/acceptance_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/databricks/cli/internal/testutil"
3232
"github.com/databricks/cli/libs/auth"
3333
"github.com/databricks/cli/libs/testdiff"
34-
"github.com/databricks/cli/libs/testserver"
3534
"github.com/databricks/cli/libs/utils"
3635
"github.com/stretchr/testify/require"
3736
)
@@ -472,12 +471,6 @@ func runTest(t *testing.T,
472471
// User replacements:
473472
repls.Repls = append(repls.Repls, config.Repls...)
474473

475-
// Apply these after user replacements in case user replacement capture something like "Job \d+"
476-
for offset := range 5 {
477-
repls.Set(strconv.Itoa(testserver.TestJobID+offset), fmt.Sprintf("[TEST_JOB_ID+%d]", offset))
478-
repls.Set(strconv.Itoa(testserver.TestRunID+offset), fmt.Sprintf("[TEST_RUN_ID+%d]", offset))
479-
}
480-
481474
// Save replacements to temp test directory so that it can be read by diff.py
482475
replsJson, err := json.MarshalIndent(repls.Repls, "", " ")
483476
require.NoError(t, err)

acceptance/bundle/artifacts/whl_dynamic/output.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@
2121

2222
>>> [CLI] bundle deploy
2323
Building my_test_code...
24-
Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
25-
Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
24+
Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
25+
Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
2626
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
2727
Deploying resources...
2828
Updating deployment state...
2929
Deployment complete!
3030

3131
=== There are 2 original wheels and 2 patched ones
3232
>>> find.py --expect 4 whl
33-
.databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl
34-
.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl
33+
.databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl
34+
.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl
3535
my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl
3636
prebuilt/other_test_code-0.0.1-py3-none-any.whl
3737

3838
=== Verify contents of the zip file
3939
>>> find.py --expect 1 .databricks/.*my_test_code.*whl
4040
src/__init__.py
4141
src/__main__.py
42-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/METADATA
43-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/WHEEL
44-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/entry_points.txt
45-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/top_level.txt
46-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
42+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/METADATA
43+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/WHEEL
44+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/entry_points.txt
45+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/top_level.txt
46+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/RECORD
4747

4848
=== Expecting 2 patched wheels in libraries section in /jobs/create
4949
>>> jq -s .[] | select(.path=="/api/2.2/jobs/create") | .body.tasks out.requests.txt
@@ -64,7 +64,7 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
6464
"existing_cluster_id": "0717-132531-5opeqon1",
6565
"libraries": [
6666
{
67-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
67+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
6868
}
6969
],
7070
"python_wheel_task": {
@@ -76,10 +76,10 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
7676
},
7777
"libraries": [
7878
{
79-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
79+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
8080
},
8181
{
82-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
82+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
8383
}
8484
],
8585
"python_wheel_task": {
@@ -92,16 +92,16 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
9292

9393
=== Expecting 2 patched wheels to be uploaded
9494
>>> jq .path
95-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
96-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
95+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
96+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
9797
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl"
9898
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/prebuilt/other_test_code-0.0.1-py3-none-any.whl"
9999

100100
=== Updating the local wheel and deploying again
101101
>>> [CLI] bundle deploy
102102
Building my_test_code...
103-
Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
104-
Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
103+
Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
104+
Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
105105
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
106106
Deploying resources...
107107
Updating deployment state...
@@ -112,11 +112,11 @@ Deployment complete!
112112
src/__init__.py
113113
src/__main__.py
114114
src/new_module.py
115-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/METADATA
116-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/WHEEL
117-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/entry_points.txt
118-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/top_level.txt
119-
my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
115+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/METADATA
116+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/WHEEL
117+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/entry_points.txt
118+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/top_level.txt
119+
my_test_code-0.0.1+[UNIX_TIME_NANOS].dist-info/RECORD
120120

121121
=== Expecting 2 patched wheels in libraries section in /jobs/reset
122122
>>> jq -s .[] | select(.path=="/api/2.2/jobs/reset") | .body.new_settings.tasks out.requests.txt
@@ -137,7 +137,7 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
137137
"existing_cluster_id": "0717-132531-5opeqon1",
138138
"libraries": [
139139
{
140-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
140+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
141141
}
142142
],
143143
"python_wheel_task": {
@@ -149,10 +149,10 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
149149
},
150150
"libraries": [
151151
{
152-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
152+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
153153
},
154154
{
155-
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
155+
"whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
156156
}
157157
],
158158
"python_wheel_task": {
@@ -165,6 +165,6 @@ my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD
165165

166166
=== Expecting 2 pached wheels to be uploaded (Bad: it is currently uploaded twice)
167167
>>> jq .path
168-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
169-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
168+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
169+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
170170
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl"

acceptance/bundle/artifacts/whl_prebuilt_outside_dynamic/output.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22
>>> errcode [CLI] bundle deploy
3-
Uploading this_dab/.databricks/bundle/default/patched_wheels/art1_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
4-
Uploading this_dab/.databricks/bundle/default/patched_wheels/art2_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl...
3+
Uploading this_dab/.databricks/bundle/default/patched_wheels/art1_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
4+
Uploading this_dab/.databricks/bundle/default/patched_wheels/art2_other_test_code/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl...
55
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files...
66
Deploying resources...
77
Updating deployment state...
88
Deployment complete!
99

1010
=== Expecting to find two patched wheels in current directory
1111
>>> find.py --expect 2 whl
12-
.databricks/bundle/default/patched_wheels/art1_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl
13-
.databricks/bundle/default/patched_wheels/art2_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl
12+
.databricks/bundle/default/patched_wheels/art1_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl
13+
.databricks/bundle/default/patched_wheels/art2_other_test_code/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl
1414

1515
=== Expecting 2 wheels in libraries section in /jobs/create
1616
>>> jq -s .[] | select(.path=="/api/2.2/jobs/create") | .body.tasks out.requests.txt
@@ -27,10 +27,10 @@ Deployment complete!
2727
"existing_cluster_id": "0717-132531-5opeqon1",
2828
"libraries": [
2929
{
30-
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
30+
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
3131
},
3232
{
33-
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
33+
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
3434
}
3535
],
3636
"python_wheel_task": {
@@ -48,14 +48,14 @@ Deployment complete!
4848
"spec": {
4949
"client": "1",
5050
"dependencies": [
51-
"/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl",
52-
"/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
51+
"/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl",
52+
"/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
5353
]
5454
}
5555
}
5656
]
5757

5858
=== Expecting 2 wheels to be uploaded
5959
>>> jq .path
60-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
61-
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl"
60+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"
61+
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS]-py3-none-any.whl"

acceptance/bundle/deploy/experimental-python/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Deployment complete!
88
>>> [CLI] jobs list --output json
99
[
1010
{
11-
"job_id": [TEST_JOB_ID+0],
11+
"job_id": [NUMID],
1212
"settings": {
1313
"deployment": {
1414
"kind": "BUNDLE",

acceptance/bundle/deploy/fail-on-active-runs/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updating deployment state...
66
Deployment complete!
77

88
>>> errcode [CLI] bundle deploy --fail-on-active-runs
9-
Error: job [TEST_JOB_ID+0] is running
9+
Error: job [NUMID] is running
1010

1111

1212
Exit code: 1

acceptance/bundle/deploy/jobs/check-metadata/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,3 @@ Ignore = [
1212
# C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI
1313
# Setting this environment variable prevents that conversion on windows.
1414
MSYS_NO_PATHCONV = "1"
15-
16-
[[Repls]]
17-
Old = "[0-9]{12,}"
18-
New = "[NUMID]"

acceptance/bundle/deploy/mlops-stacks/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ Ignore = [
77
"config.json"
88
]
99

10-
[[Repls]]
11-
Old = "[0-9]{12,}"
12-
New = "[NUMID]"
13-
1410
[[Repls]]
1511
Old = '\\'
1612
New = '/'

acceptance/bundle/deploy/pipeline/auto-approve/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ Cloud = true
44
Ignore = [
55
"databricks.yml"
66
]
7-
8-
[[Repls]]
9-
Old = "[0-9]{3,}"
10-
New = "[NUMID]"

acceptance/bundle/deploy/python-notebook/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Deployment complete!
88
>>> [CLI] jobs list --output json
99
[
1010
{
11-
"job_id": [TEST_JOB_ID+0],
11+
"job_id": [NUMID],
1212
"settings": {
1313
"deployment": {
1414
"kind": "BUNDLE",

acceptance/bundle/deployment/bind/experiment/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ Local = true
22
Cloud = true
33
BundleConfigTarget = "databricks.yml"
44

5-
[[Repls]]
6-
Old = "[0-9]{3,}"
7-
New = "[NUMID]"
8-
95
[[Server]]
106
Pattern = "POST /api/2.0/mlflow/experiments/create"
117
Response.Body = '''

0 commit comments

Comments
 (0)