Skip to content

Commit a1b09c6

Browse files
committed
Added make test-gcp for verifying GCP functionality on Google Cloud through common integration tests
1 parent 05a9125 commit a1b09c6

File tree

6 files changed

+102
-6
lines changed

6 files changed

+102
-6
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,18 @@ test-mws: install
5858
@echo "✓ Running acceptance Tests for Multiple Workspace APIs on AWS..."
5959
@/bin/bash scripts/run.sh mws '^TestMwsAcc' --debug --tee
6060

61-
test-gcp-accounts: install
62-
@echo "✓ Running acceptance Tests for Multiple Workspace APIs on GCP..."
63-
@/bin/bash scripts/run.sh gcp-accounts '^TestGcpAcc' --debug --tee
64-
6561
test-awsmt: install
6662
@echo "✓ Running Terraform Acceptance Tests for AWS MT..."
6763
@/bin/bash scripts/run.sh awsmt '^(TestAcc|TestAwsAcc)' --debug --tee
6864

65+
test-gcp-accounts: install
66+
@echo "✓ Running acceptance Tests for Multiple Workspace APIs on GCP..."
67+
@/bin/bash scripts/run.sh gcp-accounts '^TestGcpaAcc' --debug --tee
68+
69+
test-gcp: install
70+
@echo "✓ Running acceptance Tests for GCP..."
71+
@/bin/bash scripts/run.sh gcp '^(TestAcc|TestGcpAcc)' --debug --tee
72+
6973
test-preview: install
7074
@echo "✓ Running acceptance Tests for Preview features..."
7175
@/bin/bash scripts/run.sh preview '^TestPreviewAcc' --debug --tee

mws/acceptance/workspace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestMwsAccWorkspaces(t *testing.T) {
6060
})
6161
}
6262

63-
func TestGcpAccWorkspaces(t *testing.T) {
63+
func TestGcpAccaWorkspaces(t *testing.T) {
6464
cloudEnv := os.Getenv("CLOUD_ENV")
6565
if cloudEnv != "gcp-accounts" {
6666
t.Skip("Acceptance tests skipped unless CLOUD_ENV=gcp-accounts is set")

mws/resource_workspace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestMwsAccWorkspace(t *testing.T) {
2727
t.Log(workspaceList)
2828
}
2929

30-
func TestGcpAccWorkspace(t *testing.T) {
30+
func TestGcpaAccWorkspace(t *testing.T) {
3131
acctID := qa.GetEnvOrSkipTest(t, "DATABRICKS_ACCOUNT_ID")
3232
client := common.CommonEnvironmentClient()
3333
workspacesAPI := NewWorkspacesAPI(context.Background(), client)

scripts/gcp-integration/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
make test-gcp
2+
---
3+
4+
Used for running integration tests on GCP.
5+
6+
* `DATABRICKS_GOOGLE_SERVICE_ACCOUNT` is the account created through [this module](../gcp-accounts-integration/service-account/main.tf).

scripts/gcp-integration/main.tf

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
terraform {
2+
required_providers {
3+
databricks = {
4+
source = "databrickslabs/databricks"
5+
}
6+
}
7+
}
8+
9+
locals {
10+
username = replace(split("@", data.google_client_openid_userinfo.me.email)[0], ".", "_")
11+
prefix = "${local.username}-${random_string.naming.result}"
12+
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
13+
}
14+
15+
data "external" "env" {
16+
program = ["python", "-c", "import sys,os,json;json.dump(dict(os.environ), sys.stdout)"]
17+
}
18+
19+
resource "random_string" "naming" {
20+
special = false
21+
upper = false
22+
length = 6
23+
}
24+
25+
// configured via env
26+
provider "google" {}
27+
28+
// account_id & google_service_account configured via env
29+
provider "databricks" {
30+
alias = "accounts"
31+
host = "https://accounts.gcp.databricks.com"
32+
}
33+
34+
data "google_client_config" "current" {}
35+
36+
resource "databricks_mws_workspaces" "this" {
37+
provider = databricks.accounts
38+
account_id = local.account_id
39+
workspace_name = local.prefix
40+
location = data.google_client_config.current.region
41+
cloud_resource_bucket {
42+
gcp {
43+
project_id = data.google_client_config.current.project
44+
}
45+
}
46+
}
47+
48+
// google_service_account configured via env
49+
provider "databricks" {
50+
alias = "workspace"
51+
host = databricks_mws_workspaces.this.workspace_url
52+
}
53+
54+
data "google_client_openid_userinfo" "me" {}
55+
56+
data "databricks_group" "admins" {
57+
depends_on = [databricks_mws_workspaces.this]
58+
provider = databricks.workspace
59+
display_name = "admins"
60+
}
61+
62+
resource "databricks_user" "me" {
63+
depends_on = [databricks_mws_workspaces.this]
64+
provider = databricks.workspace
65+
user_name = data.google_client_openid_userinfo.me.email
66+
}
67+
68+
resource "databricks_group_member" "allow_me_to_admin" {
69+
depends_on = [databricks_mws_workspaces.this]
70+
provider = databricks.workspace
71+
group_id = data.databricks_group.admins.id
72+
member_id = databricks_user.me.id
73+
}
74+
75+
output "databricks_host" {
76+
value = databricks_mws_workspaces.this.workspace_url
77+
}
78+
79+
output "cloud_env" {
80+
value = "gcp"
81+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DATABRICKS_ACCOUNT_ID
2+
DATABRICKS_GOOGLE_SERVICE_ACCOUNT
3+
GOOGLE_PROJECT
4+
GOOGLE_REGION
5+
GOOGLE_ZONE

0 commit comments

Comments
 (0)