mirror of https://github.com/databricks/cli.git
Enable acceptance tests for manually running against the cloud (#2120)
## Changes - If CLOUD_ENV variable is set, acceptance will no longer set up server & override DATABRICKS_HOST/DATABRICKS_TOKEN/HOME env vars. - I've updated replacements logic in testdiff to use tester / tester@databricks.com convention. ## Tests Manually running current acceptance tests against dogfood on my laptop I get all test pass except for 2 failures. ``` --- FAIL: TestAccept/bundle/variables/env_overrides (0.09s) --- FAIL: TestAccept/bundle/variables/resolve-builtin (1.30s) ```
This commit is contained in:
parent
fe31e4d02e
commit
2ae2b7e8c8
|
@ -1,6 +1,7 @@
|
||||||
package acceptance_test
|
package acceptance_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -17,6 +18,7 @@ import (
|
||||||
"github.com/databricks/cli/internal/testutil"
|
"github.com/databricks/cli/internal/testutil"
|
||||||
"github.com/databricks/cli/libs/env"
|
"github.com/databricks/cli/libs/env"
|
||||||
"github.com/databricks/cli/libs/testdiff"
|
"github.com/databricks/cli/libs/testdiff"
|
||||||
|
"github.com/databricks/databricks-sdk-go"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,19 +47,33 @@ func TestAccept(t *testing.T) {
|
||||||
// Make helper scripts available
|
// Make helper scripts available
|
||||||
t.Setenv("PATH", fmt.Sprintf("%s%c%s", filepath.Join(cwd, "bin"), os.PathListSeparator, os.Getenv("PATH")))
|
t.Setenv("PATH", fmt.Sprintf("%s%c%s", filepath.Join(cwd, "bin"), os.PathListSeparator, os.Getenv("PATH")))
|
||||||
|
|
||||||
server := StartServer(t)
|
|
||||||
AddHandlers(server)
|
|
||||||
// Redirect API access to local server:
|
|
||||||
t.Setenv("DATABRICKS_HOST", fmt.Sprintf("http://127.0.0.1:%d", server.Port))
|
|
||||||
t.Setenv("DATABRICKS_TOKEN", "dapi1234")
|
|
||||||
|
|
||||||
homeDir := t.TempDir()
|
|
||||||
// Do not read user's ~/.databrickscfg
|
|
||||||
t.Setenv(env.HomeEnvVar(), homeDir)
|
|
||||||
|
|
||||||
repls := testdiff.ReplacementsContext{}
|
repls := testdiff.ReplacementsContext{}
|
||||||
repls.Set(execPath, "$CLI")
|
repls.Set(execPath, "$CLI")
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
cloudEnv := os.Getenv("CLOUD_ENV")
|
||||||
|
|
||||||
|
if cloudEnv == "" {
|
||||||
|
server := StartServer(t)
|
||||||
|
AddHandlers(server)
|
||||||
|
// Redirect API access to local server:
|
||||||
|
t.Setenv("DATABRICKS_HOST", fmt.Sprintf("http://127.0.0.1:%d", server.Port))
|
||||||
|
t.Setenv("DATABRICKS_TOKEN", "dapi1234")
|
||||||
|
|
||||||
|
homeDir := t.TempDir()
|
||||||
|
// Do not read user's ~/.databrickscfg
|
||||||
|
t.Setenv(env.HomeEnvVar(), homeDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceClient, err := databricks.NewWorkspaceClient()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
user, err := workspaceClient.CurrentUser.Me(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, user)
|
||||||
|
testdiff.PrepareReplacementsUser(t, &repls, *user)
|
||||||
|
testdiff.PrepareReplacements(t, &repls, workspaceClient)
|
||||||
|
|
||||||
testDirs := getTests(t)
|
testDirs := getTests(t)
|
||||||
require.NotEmpty(t, testDirs)
|
require.NotEmpty(t, testDirs)
|
||||||
for _, dir := range testDirs {
|
for _, dir := range testDirs {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"foo": {
|
"foo": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_job_cluster/development/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
"foo": {
|
"foo": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_job_cluster/staging/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"foo": {
|
"foo": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_job_cluster/development/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
Name: override_job_cluster
|
Name: override_job_cluster
|
||||||
Target: development
|
Target: development
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development
|
Path: /Workspace/Users/$USERNAME/.bundle/override_job_cluster/development
|
||||||
|
|
||||||
Validation OK!
|
Validation OK!
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ Validation OK!
|
||||||
"foo": {
|
"foo": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_job_cluster/staging/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
@ -68,7 +68,7 @@ Validation OK!
|
||||||
Name: override_job_cluster
|
Name: override_job_cluster
|
||||||
Target: staging
|
Target: staging
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging
|
Path: /Workspace/Users/$USERNAME/.bundle/override_job_cluster/staging
|
||||||
|
|
||||||
Validation OK!
|
Validation OK!
|
||||||
|
|
|
@ -69,8 +69,8 @@ Error: file ./test1.py not found
|
||||||
Name: override_job_tasks
|
Name: override_job_tasks
|
||||||
Target: staging
|
Target: staging
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_tasks/staging
|
Path: /Workspace/Users/$USERNAME/.bundle/override_job_tasks/staging
|
||||||
|
|
||||||
Found 1 error
|
Found 1 error
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ Warning: expected map, found string
|
||||||
Name: merge-string-map
|
Name: merge-string-map
|
||||||
Target: dev
|
Target: dev
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/merge-string-map/dev
|
Path: /Workspace/Users/$USERNAME/.bundle/merge-string-map/dev
|
||||||
|
|
||||||
Found 1 warning
|
Found 1 warning
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
],
|
],
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_pipeline_cluster/development/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_pipeline_cluster/development/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "job",
|
"name": "job",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
],
|
],
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_pipeline_cluster/staging/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/override_pipeline_cluster/staging/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "job",
|
"name": "job",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"my_job": {
|
"my_job": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/complex-variables/default/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/complex-variables/default/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"my_job": {
|
"my_job": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/complex-variables/dev/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/complex-variables/dev/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"my_job": {
|
"my_job": {
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/complex-variables-multiple-files/dev/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/complex-variables-multiple-files/dev/state/metadata.json"
|
||||||
},
|
},
|
||||||
"edit_mode": "UI_LOCKED",
|
"edit_mode": "UI_LOCKED",
|
||||||
"format": "MULTI_TASK",
|
"format": "MULTI_TASK",
|
||||||
|
|
|
@ -3,8 +3,8 @@ Error: no value assigned to required variable a. Assignment can be done through
|
||||||
Name: empty${var.a}
|
Name: empty${var.a}
|
||||||
Target: default
|
Target: default
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/empty${var.a}/default
|
Path: /Workspace/Users/$USERNAME/.bundle/empty${var.a}/default
|
||||||
|
|
||||||
Found 1 error
|
Found 1 error
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ Error: no value assigned to required variable b. Assignment can be done through
|
||||||
Name: test bundle
|
Name: test bundle
|
||||||
Target: env-missing-a-required-variable-assignment
|
Target: env-missing-a-required-variable-assignment
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/test bundle/env-missing-a-required-variable-assignment
|
Path: /Workspace/Users/$USERNAME/.bundle/test bundle/env-missing-a-required-variable-assignment
|
||||||
|
|
||||||
Found 1 error
|
Found 1 error
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"artifact_path": "TestResolveVariableReferences/bar/artifacts",
|
"artifact_path": "TestResolveVariableReferences/bar/artifacts",
|
||||||
"current_user": {
|
"current_user": {
|
||||||
"short_name": "tester",
|
"short_name": "$USERNAME",
|
||||||
"userName": "tester@databricks.com"
|
"userName": "$USERNAME"
|
||||||
},
|
},
|
||||||
"file_path": "TestResolveVariableReferences/bar/baz",
|
"file_path": "TestResolveVariableReferences/bar/baz",
|
||||||
"resource_path": "TestResolveVariableReferences/bar/resources",
|
"resource_path": "TestResolveVariableReferences/bar/resources",
|
||||||
|
|
|
@ -8,8 +8,8 @@ Error: no value assigned to required variable b. Assignment can be done through
|
||||||
Name: ${var.a} ${var.b}
|
Name: ${var.a} ${var.b}
|
||||||
Target: default
|
Target: default
|
||||||
Workspace:
|
Workspace:
|
||||||
User: tester@databricks.com
|
User: $USERNAME
|
||||||
Path: /Workspace/Users/tester@databricks.com/.bundle/${var.a} ${var.b}/default
|
Path: /Workspace/Users/$USERNAME/.bundle/${var.a} ${var.b}/default
|
||||||
|
|
||||||
Found 1 error
|
Found 1 error
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"continuous": true,
|
"continuous": true,
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/foobar/use-default-variable-values/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/foobar/use-default-variable-values/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "a_string",
|
"name": "a_string",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"continuous": true,
|
"continuous": true,
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/foobar/override-string-variable/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/foobar/override-string-variable/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "overridden_string",
|
"name": "overridden_string",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
"continuous": true,
|
"continuous": true,
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/foobar/override-int-variable/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/foobar/override-int-variable/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "a_string",
|
"name": "a_string",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
"continuous": false,
|
"continuous": false,
|
||||||
"deployment": {
|
"deployment": {
|
||||||
"kind": "BUNDLE",
|
"kind": "BUNDLE",
|
||||||
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/foobar/override-both-bool-and-string-variables/state/metadata.json"
|
"metadata_file_path": "/Workspace/Users/$USERNAME/.bundle/foobar/override-both-bool-and-string-variables/state/metadata.json"
|
||||||
},
|
},
|
||||||
"name": "overridden_string",
|
"name": "overridden_string",
|
||||||
"permissions": []
|
"permissions": []
|
||||||
|
|
Loading…
Reference in New Issue