Skip to content

Commit c2b7c6e

Browse files
authored
acc: Use large numbers for jobId & testId in testserver (#2922)
1 parent 6ba1837 commit c2b7c6e

File tree

9 files changed

+32
-15
lines changed

9 files changed

+32
-15
lines changed

acceptance/acceptance_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ 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"
3435
"github.com/databricks/cli/libs/utils"
3536
"github.com/stretchr/testify/require"
3637
)
@@ -439,9 +440,15 @@ func runTest(t *testing.T,
439440
// Must be added PrepareReplacementsUser, otherwise conflicts with [USERNAME]
440441
testdiff.PrepareReplacementsUUID(t, &repls)
441442

442-
// User replacements come last:
443+
// User replacements:
443444
repls.Repls = append(repls.Repls, config.Repls...)
444445

446+
// Apply these after user replacements in case user replacement capture something like "Job \d+"
447+
for offset := range 5 {
448+
repls.Set(strconv.Itoa(testserver.TestJobID+offset), fmt.Sprintf("[TEST_JOB_ID+%d]", offset))
449+
repls.Set(strconv.Itoa(testserver.TestRunID+offset), fmt.Sprintf("[TEST_RUN_ID+%d]", offset))
450+
}
451+
445452
// Save replacements to temp test directory so that it can be read by diff.py
446453
replsJson, err := json.MarshalIndent(repls.Repls, "", " ")
447454
require.NoError(t, err)

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": 1,
11+
"job_id": [TEST_JOB_ID+0],
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 1 is running
9+
Error: job [TEST_JOB_ID+0] is running
1010

1111

1212
Exit code: 1

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": 1,
11+
"job_id": [TEST_JOB_ID+0],
1212
"settings": {
1313
"deployment": {
1414
"kind": "BUNDLE",

acceptance/bundle/resources/jobs/output.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Deployment complete!
3939
"method": "POST",
4040
"path": "/api/2.2/jobs/create"
4141
}
42-
jobs foo id='1' name='foo'
42+
jobs foo id='[TEST_JOB_ID+0]' name='foo'
4343

4444
=== Update trigger.periodic.unit and re-deploy
4545
>>> update_file.py databricks.yml DAYS HOURS
@@ -53,7 +53,7 @@ Deployment complete!
5353
>>> print_requests
5454
{
5555
"body": {
56-
"job_id": 1,
56+
"job_id": [TEST_JOB_ID+0],
5757
"new_settings": {
5858
"deployment": {
5959
"kind": "BUNDLE",
@@ -87,4 +87,4 @@ Deployment complete!
8787
"method": "POST",
8888
"path": "/api/2.2/jobs/reset"
8989
}
90-
jobs foo id='1' name='foo'
90+
jobs foo id='[TEST_JOB_ID+0]' name='foo'

acceptance/bundle/run/basic/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Updating deployment state...
1313
Deployment complete!
1414

1515
>>> [CLI] bundle run foo
16-
Run URL: [DATABRICKS_URL]/job/run/1
16+
Run URL: [DATABRICKS_URL]/job/run/[TEST_RUN_ID+0]
1717

1818
[DATE] HH:MM:SS "run-name" TERMINATED
1919

@@ -25,7 +25,7 @@ Exit code: 1
2525

2626
=== resource key with parameters
2727
>>> [CLI] bundle run foo -- arg1 arg2
28-
Run URL: [DATABRICKS_URL]/job/run/2
28+
Run URL: [DATABRICKS_URL]/job/run/[TEST_RUN_ID+1]
2929

3030
[DATE] HH:MM:SS "run-name" TERMINATED
3131

acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"resource_dashboard_count": 0,
2828
"resource_app_count": 0,
2929
"resource_job_ids": [
30-
"1"
30+
"[TEST_JOB_ID+0]"
3131
],
3232
"experimental": {
3333
"configuration_file_count": 1,

acceptance/bundle/telemetry/deploy/out.telemetry.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"resource_dashboard_count": 0,
2828
"resource_app_count": 0,
2929
"resource_job_ids": [
30-
"1",
31-
"2",
32-
"3"
30+
"[TEST_JOB_ID+0]",
31+
"[TEST_JOB_ID+1]",
32+
"[TEST_JOB_ID+2]"
3333
],
3434
"resource_pipeline_ids": [
3535
"[UUID]",

libs/testserver/fake_workspace.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ import (
1717
"github.com/databricks/databricks-sdk-go/service/workspace"
1818
)
1919

20+
// 4611686018427387911 == 2 ** 62 + 7
21+
// 2305843009213693969 == 2 ** 61 + 17
22+
// This values cannot be represented by float64, so they can test incorrect use of json parsing
23+
// (encoding/json without options parses numbers into float64)
24+
// These are also easier to spot / replace in test output compared to numbers with one or few digits.
25+
const (
26+
TestJobID = 4611686018427387911
27+
TestRunID = 2305843009213693969
28+
)
29+
2030
// FakeWorkspace holds a state of a workspace for acceptance tests.
2131
type FakeWorkspace struct {
2232
mu sync.Mutex
@@ -100,8 +110,8 @@ func NewFakeWorkspace(url string) *FakeWorkspace {
100110
files: map[string][]byte{},
101111
Jobs: map[int64]jobs.Job{},
102112
JobRuns: map[int64]jobs.Run{},
103-
nextJobId: 1,
104-
nextJobRunId: 1,
113+
nextJobId: TestJobID,
114+
nextJobRunId: TestRunID,
105115
Pipelines: map[string]pipelines.PipelineSpec{},
106116
Monitors: map[string]catalog.MonitorInfo{},
107117
Apps: map[string]apps.App{},

0 commit comments

Comments
 (0)