Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ func TestInprocessMode(t *testing.T) {
require.Equal(t, 1, testAccept(t, true, "selftest/server"))
}

// Configure replacements for environment variables we read from test environments.
func setReplsForTestEnvVars(t *testing.T, repls *testdiff.ReplacementsContext) {
envVars := []string{
"TEST_USER_EMAIL",
"TEST_GROUP_NAME",
"TEST_SP_APPLICATION_ID",
"TEST_DEFAULT_WAREHOUSE_ID",
"TEST_INSTANCE_POOL_ID",
}
for _, envVar := range envVars {
if value := os.Getenv(envVar); value != "" {
repls.Set(value, "["+envVar+"]")
}
}
}

func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
repls := testdiff.ReplacementsContext{}
cwd, err := os.Getwd()
Expand Down Expand Up @@ -232,17 +248,14 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
}
}

setReplsForTestEnvVars(t, &repls)

if cloudEnv != "" && UseVersion == "" {
// Create linux release artifacts, to be used by the cloud-only ssh tunnel tests
releasesDir := CreateReleaseArtifacts(t, cwd, coverDir, "linux")
t.Setenv("CLI_RELEASES_DIR", releasesDir)
}

testDefaultWarehouseId := os.Getenv("TEST_DEFAULT_WAREHOUSE_ID")
if testDefaultWarehouseId != "" {
repls.Set(testDefaultWarehouseId, "[TEST_DEFAULT_WAREHOUSE_ID]")
}

terraformrcPath := filepath.Join(terraformDir, ".terraformrc")
t.Setenv("TF_CLI_CONFIG_FILE", terraformrcPath)
t.Setenv("DATABRICKS_TF_CLI_CONFIG_FILE", terraformrcPath)
Expand All @@ -256,8 +269,6 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
// do it last so that full paths match first:
repls.SetPath(buildDir, "[BUILD_DIR]")

repls.Set(os.Getenv("TEST_INSTANCE_POOL_ID"), "[TEST_INSTANCE_POOL_ID]")

testdiff.PrepareReplacementsDevVersion(t, &repls)
testdiff.PrepareReplacementSdkVersion(t, &repls)
testdiff.PrepareReplacementsGoVersion(t, &repls)
Expand Down
7 changes: 7 additions & 0 deletions acceptance/bundle/refschema/out.fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ resources.dashboards.*.serialized_dashboard string ALL
resources.dashboards.*.update_time string ALL
resources.dashboards.*.url string INPUT
resources.dashboards.*.warehouse_id string ALL
resources.dashboards.*.permissions.object_id string ALL
resources.dashboards.*.permissions.permissions []iam.AccessControlRequest ALL
resources.dashboards.*.permissions.permissions[*] iam.AccessControlRequest ALL
resources.dashboards.*.permissions.permissions[*].group_name string ALL
resources.dashboards.*.permissions.permissions[*].permission_level iam.PermissionLevel ALL
resources.dashboards.*.permissions.permissions[*].service_principal_name string ALL
resources.dashboards.*.permissions.permissions[*].user_name string ALL
resources.database_catalogs.*.create_database_if_not_exists bool ALL
resources.database_catalogs.*.database_instance_name string ALL
resources.database_catalogs.*.database_name string ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": [
"APPLY_TAG"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": [
"APPLY_TAG"
],
"principal": "deco-test-user@databricks.com"
"principal": "[TEST_USER_EMAIL]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"body": {
"changes": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"APPLY_TAG"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"full_name": "",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"APPLY_TAG"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Deployment complete!
{
"privilege_assignments": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"APPLY_TAG"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"CREATE_TABLE",
"USE_SCHEMA"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"CREATE_TABLE",
"USE_SCHEMA"
],
"principal": "deco-test-user@databricks.com"
"principal": "[TEST_USER_EMAIL]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"APPLY_TAG",
"CREATE_TABLE"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": [
"APPLY_TAG"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"USE_SCHEMA"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"body": {
"changes": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"CREATE_TABLE",
"APPLY_TAG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"full_name": "",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"CREATE_TABLE",
"USE_SCHEMA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"full_name": "main.schema_grants_[UNIQUE_NAME]",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"APPLY_TAG",
"CREATE_TABLE"
Expand All @@ -41,7 +41,7 @@
"full_name": "main.schema_grants_[UNIQUE_NAME]",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"CREATE_TABLE",
"USE_SCHEMA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Deployment complete!
{
"privilege_assignments": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"CREATE_TABLE",
"USE_SCHEMA"
Expand Down Expand Up @@ -48,7 +48,7 @@ Deployment complete!
{
"privilege_assignments": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"APPLY_TAG",
"CREATE_TABLE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Error: Missing required argument
on bundle.tf.json line 17, in resource.databricks_grants.schema_grants_schema:
17: "grant": [
18: {
19: "principal": "deco-test-user@databricks.com",
19: "principal": "[TEST_USER_EMAIL]",
20: "privileges": null
21: }
22: ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"body": {
"changes": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"full_name": "",
"grants": [
{
"principal": "deco-test-user@databricks.com"
"principal": "[TEST_USER_EMAIL]"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Error: Missing required argument
on bundle.tf.json line 17, in resource.databricks_grants.schema_grants_schema:
17: "grant": [
18: {
19: "principal": "deco-test-user@databricks.com",
19: "principal": "[TEST_USER_EMAIL]",
20: "privileges": null
21: }
22: ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"READ_VOLUME",
"WRITE_VOLUME"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"READ_VOLUME",
"WRITE_VOLUME"
],
"principal": "deco-test-user@databricks.com"
"principal": "[TEST_USER_EMAIL]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"MANAGE",
"READ_VOLUME"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"ALL_PRIVILEGES"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": [
"MANAGE"
],
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"WRITE_VOLUME"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"body": {
"changes": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"remove": [
"READ_VOLUME",
"MANAGE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"full_name": "",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"READ_VOLUME",
"WRITE_VOLUME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"full_name": "main.schema_grants_[UNIQUE_NAME].volume_name",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"MANAGE",
"READ_VOLUME"
Expand All @@ -69,7 +69,7 @@
"full_name": "main.schema_grants_[UNIQUE_NAME].volume_name",
"grants": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"READ_VOLUME",
"WRITE_VOLUME"
Expand Down
4 changes: 2 additions & 2 deletions acceptance/bundle/resources/grants/volumes/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Deployment complete!
{
"privilege_assignments": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"READ_VOLUME",
"WRITE_VOLUME"
Expand All @@ -36,7 +36,7 @@ Deployment complete!
{
"privilege_assignments": [
{
"principal": "deco-test-user@databricks.com",
"principal": "[TEST_USER_EMAIL]",
"privileges": [
"MANAGE",
"READ_VOLUME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"permissions": [
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
},
{
"permission_level": "CAN_MANAGE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"access_control_list": [
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
},
{
"permission_level": "CAN_MANAGE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"permissions": [
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
},
{
"permission_level": "CAN_MANAGE",
Expand All @@ -46,7 +46,7 @@
"permissions": [
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
},
{
"permission_level": "CAN_MANAGE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"access_control_list": [
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
},
{
"permission_level": "CAN_MANAGE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"permission_level": "CAN_VIEW",
"user_name": "deco-test-user@databricks.com"
"user_name": "[TEST_USER_EMAIL]"
}
]
}
Expand Down
Loading
Loading