Skip to content

Commit 3e00170

Browse files
authored
Convert artifact_path_with_volume to acceptance test (#3180)
1 parent 3c17460 commit 3e00170

File tree

12 files changed

+104
-116
lines changed

12 files changed

+104
-116
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export SCHEMA_NAME=schema-$UNIQUE_NAME
2+
trace envsubst < $TESTDIR/../databricks.yml.tmpl > databricks.yml
3+
trap "trace '$CLI' schemas delete main.$SCHEMA_NAME" EXIT
4+
trace $CLI schemas create $SCHEMA_NAME main | jq 'del(.effective_predictive_optimization_flag.inherited_from_name)'
5+
trace musterr $CLI bundle deploy
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bundle:
2+
name: artifact_path_with_volume-$UNIQUE_NAME
3+
4+
workspace:
5+
root_path: "~/.bundle/$UNIQUE_NAME"
6+
artifact_path: /Volumes/main/$SCHEMA_NAME/$VOLUME_NAME
7+
8+
resources:
9+
volumes:
10+
foo:
11+
catalog_name: main
12+
name: my_volume
13+
schema_name: $SCHEMA_NAME
14+
volume_type: MANAGED
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Local = false
2+
Cloud = true
3+
RecordRequests = false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
>>> envsubst
3+
4+
>>> [CLI] schemas create schema-[UNIQUE_NAME] main
5+
{
6+
"browse_only": false,
7+
"catalog_name": "main",
8+
"catalog_type": "MANAGED_CATALOG",
9+
"created_at": [UNIX_TIME_MILLIS],
10+
"created_by": "[USERNAME]",
11+
"effective_predictive_optimization_flag": {
12+
"inherited_from_type": "METASTORE",
13+
"value": "DISABLE"
14+
},
15+
"enable_predictive_optimization": "INHERIT",
16+
"full_name": "main.schema-[UNIQUE_NAME]",
17+
"metastore_id": "[UUID]",
18+
"name": "schema-[UNIQUE_NAME]",
19+
"owner": "[USERNAME]",
20+
"schema_id": "[UUID]",
21+
"updated_at": [UNIX_TIME_MILLIS],
22+
"updated_by": "[USERNAME]"
23+
}
24+
25+
>>> musterr [CLI] bundle deploy
26+
Error: volume main.schema-[UNIQUE_NAME].doesnotexist does not exist
27+
at workspace.artifact_path
28+
in databricks.yml:6:18
29+
30+
31+
Exit code (musterr): 1
32+
33+
>>> [CLI] schemas delete main.schema-[UNIQUE_NAME]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export VOLUME_NAME=doesnotexist
2+
source $TESTDIR/../common_script.sh
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cloud = true
2+
RequiresUnityCatalog = true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
>>> envsubst
3+
4+
>>> [CLI] schemas create schema-[UNIQUE_NAME] main
5+
{
6+
"browse_only": false,
7+
"catalog_name": "main",
8+
"catalog_type": "MANAGED_CATALOG",
9+
"created_at": [UNIX_TIME_MILLIS],
10+
"created_by": "[USERNAME]",
11+
"effective_predictive_optimization_flag": {
12+
"inherited_from_type": "METASTORE",
13+
"value": "DISABLE"
14+
},
15+
"enable_predictive_optimization": "INHERIT",
16+
"full_name": "main.schema-[UNIQUE_NAME]",
17+
"metastore_id": "[UUID]",
18+
"name": "schema-[UNIQUE_NAME]",
19+
"owner": "[USERNAME]",
20+
"schema_id": "[UUID]",
21+
"updated_at": [UNIX_TIME_MILLIS],
22+
"updated_by": "[USERNAME]"
23+
}
24+
25+
>>> musterr [CLI] bundle deploy
26+
Error: volume main.schema-[UNIQUE_NAME].my_volume does not exist
27+
at workspace.artifact_path
28+
resources.volumes.foo
29+
in databricks.yml:6:18
30+
databricks.yml:11:7
31+
32+
You are using a volume in your artifact_path that is managed by
33+
this bundle but which has not been deployed yet. Please first deploy
34+
the volume using 'bundle deploy' and then switch over to using it in
35+
the artifact_path.
36+
37+
38+
Exit code (musterr): 1
39+
40+
>>> [CLI] schemas delete main.schema-[UNIQUE_NAME]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export VOLUME_NAME=my_volume
2+
source $TESTDIR/../common_script.sh
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Badness = "Requires two bundles; one for volumes, another for artifacts. Ideally it would just work but today we first upload then deploy, so it does not fit in that architecture."
2+
Cloud = true
3+
RequiresUnityCatalog = true

integration/bundle/artifacts_test.go

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package bundle_test
22

33
import (
4-
"fmt"
54
"os"
65
"path"
76
"path/filepath"
@@ -13,14 +12,8 @@ import (
1312
"github.com/databricks/cli/bundle/config/resources"
1413
"github.com/databricks/cli/bundle/libraries"
1514
"github.com/databricks/cli/integration/internal/acc"
16-
"github.com/databricks/cli/internal/testcli"
17-
"github.com/databricks/cli/internal/testutil"
18-
"github.com/databricks/cli/libs/env"
19-
"github.com/databricks/databricks-sdk-go/service/catalog"
2015
"github.com/databricks/databricks-sdk-go/service/compute"
2116
"github.com/databricks/databricks-sdk-go/service/jobs"
22-
"github.com/google/uuid"
23-
"github.com/stretchr/testify/assert"
2417
"github.com/stretchr/testify/require"
2518
)
2619

@@ -228,82 +221,3 @@ func TestUploadArtifactFileToCorrectRemotePathForVolumes(t *testing.T) {
228221
b.Config.Resources.Jobs["test"].JobSettings.Tasks[0].Libraries[0].Whl,
229222
)
230223
}
231-
232-
func TestUploadArtifactFileToVolumeThatDoesNotExist(t *testing.T) {
233-
ctx, wt := acc.UcWorkspaceTest(t)
234-
w := wt.W
235-
236-
schemaName := testutil.RandomName("schema-")
237-
238-
_, err := w.Schemas.Create(ctx, catalog.CreateSchema{
239-
CatalogName: "main",
240-
Comment: "test schema",
241-
Name: schemaName,
242-
})
243-
require.NoError(t, err)
244-
245-
t.Cleanup(func() {
246-
err = w.Schemas.DeleteByFullName(ctx, "main."+schemaName)
247-
require.NoError(t, err)
248-
})
249-
250-
bundleRoot := initTestTemplate(t, ctx, "artifact_path_with_volume", map[string]any{
251-
"unique_id": uuid.New().String(),
252-
"schema_name": schemaName,
253-
"volume_name": "doesnotexist",
254-
})
255-
256-
ctx = env.Set(ctx, "BUNDLE_ROOT", bundleRoot)
257-
stdout, stderr, err := testcli.RequireErrorRun(t, ctx, "bundle", "deploy")
258-
259-
assert.Error(t, err)
260-
assert.Equal(t, fmt.Sprintf(`Error: volume main.%s.doesnotexist does not exist
261-
at workspace.artifact_path
262-
in databricks.yml:6:18
263-
264-
`, schemaName), stdout.String())
265-
assert.Equal(t, "", stderr.String())
266-
}
267-
268-
func TestUploadArtifactToVolumeNotYetDeployed(t *testing.T) {
269-
ctx, wt := acc.UcWorkspaceTest(t)
270-
w := wt.W
271-
272-
schemaName := testutil.RandomName("schema-")
273-
274-
_, err := w.Schemas.Create(ctx, catalog.CreateSchema{
275-
CatalogName: "main",
276-
Comment: "test schema",
277-
Name: schemaName,
278-
})
279-
require.NoError(t, err)
280-
281-
t.Cleanup(func() {
282-
err = w.Schemas.DeleteByFullName(ctx, "main."+schemaName)
283-
require.NoError(t, err)
284-
})
285-
286-
bundleRoot := initTestTemplate(t, ctx, "artifact_path_with_volume", map[string]any{
287-
"unique_id": uuid.New().String(),
288-
"schema_name": schemaName,
289-
"volume_name": "my_volume",
290-
})
291-
292-
ctx = env.Set(ctx, "BUNDLE_ROOT", bundleRoot)
293-
stdout, stderr, err := testcli.RequireErrorRun(t, ctx, "bundle", "deploy")
294-
295-
assert.Error(t, err)
296-
assert.Equal(t, fmt.Sprintf(`Error: volume main.%s.my_volume does not exist
297-
at workspace.artifact_path
298-
resources.volumes.foo
299-
in databricks.yml:6:18
300-
databricks.yml:11:7
301-
302-
You are using a volume in your artifact_path that is managed by
303-
this bundle but which has not been deployed yet. Please first deploy
304-
the volume using 'bundle deploy' and then switch over to using it in
305-
the artifact_path.
306-
307-
`, schemaName), stdout.String())
308-
assert.Equal(t, "", stderr.String())
309-
}

0 commit comments

Comments
 (0)