Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move testing to externally configured test envs #1739

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions clusters/acceptance/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccClusterResource_CreateClusterWithLibraries(t *testing.T) {
resource "databricks_cluster" "this" {
cluster_name = "libs-{var.RANDOM}"
spark_version = data.databricks_spark_version.latest.id
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
autotermination_minutes = 10
num_workers = 1
spark_conf = {
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestAccClusterResource_CreateSingleNodeCluster(t *testing.T) {
resource "databricks_cluster" "this" {
cluster_name = "singlenode-{var.RANDOM}"
spark_version = data.databricks_spark_version.latest.id
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
num_workers = 0
autotermination_minutes = 10
spark_conf = {
Expand Down
7 changes: 2 additions & 5 deletions clusters/acceptance/clusters_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/databricks/terraform-provider-databricks/clusters"
"github.com/databricks/terraform-provider-databricks/common"
"github.com/databricks/terraform-provider-databricks/internal/compute"
"github.com/databricks/terraform-provider-databricks/qa"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -27,9 +26,8 @@ func TestAccListClustersIntegration(t *testing.T) {
SparkVersion: clustersAPI.LatestSparkVersionOrDefault(
clusters.SparkVersionRequest{
Latest: true,
LongTermSupport: true,
}),
InstancePoolID: compute.CommonInstancePoolID(),
InstancePoolID: qa.GetEnvOrSkipTest(t, "TEST_INSTANCE_POOL_ID"),
IdempotencyToken: "acc-list-" + randomName,
AutoterminationMinutes: 15,
}
Expand Down Expand Up @@ -79,9 +77,8 @@ func TestAccListClustersResizeIntegrationTest(t *testing.T) {
SparkVersion: clustersAPI.LatestSparkVersionOrDefault(
clusters.SparkVersionRequest{
Latest: true,
LongTermSupport: true,
}),
InstancePoolID: compute.CommonInstancePoolID(),
InstancePoolID: qa.GetEnvOrSkipTest(t, "TEST_INSTANCE_POOL_ID"),
IdempotencyToken: "acc-list-" + randomName,
AutoterminationMinutes: 15,
}
Expand Down
6 changes: 4 additions & 2 deletions internal/compute/common_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func CommonInstancePoolID() string {
if commonInstancePool != nil {
return commonInstancePool.InstancePoolID
}
configured := os.Getenv("TEST_INSTANCE_POOL_ID")
if configured != "" {
return configured
}
client := common.CommonEnvironmentClient()
oncePool.Do(func() { // atomic
log.Printf("[INFO] Initializing common instance pool")
Expand Down Expand Up @@ -92,7 +96,6 @@ func NewTinyClusterInCommonPool() (c clusters.ClusterInfo, err error) {
ClusterName: "Terraform " + randomName,
SparkVersion: clustersAPI.LatestSparkVersionOrDefault(clusters.SparkVersionRequest{
Latest: true,
LongTermSupport: true,
}),
InstancePoolID: CommonInstancePoolID(),
IdempotencyToken: "tf-" + randomName,
Expand All @@ -112,7 +115,6 @@ func NewTinyClusterInCommonPoolPossiblyReused() (c clusters.ClusterInfo) {
ClusterName: currentCluster,
SparkVersion: clustersAPI.LatestSparkVersionOrDefault(clusters.SparkVersionRequest{
Latest: true,
LongTermSupport: true,
}),
InstancePoolID: CommonInstancePoolID(),
IdempotencyToken: "tf-" + randomName,
Expand Down
12 changes: 6 additions & 6 deletions pipelines/acceptance/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAccPipelineResource_CreatePipeline(t *testing.T) {
}

cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "default"
num_workers = 2
custom_tags = {
Expand All @@ -78,7 +78,7 @@ func TestAccPipelineResource_CreatePipeline(t *testing.T) {
}

cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "maintenance"
num_workers = 1
custom_tags = {
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestAccAwsPipelineResource_CreatePipeline(t *testing.T) {
}

cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "default"
num_workers = 2
custom_tags = {
Expand All @@ -128,7 +128,7 @@ func TestAccAwsPipelineResource_CreatePipeline(t *testing.T) {
}
}
cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "maintenance"
num_workers = 1
custom_tags = {
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestAccAwsPipelineResource_CreatePipeline(t *testing.T) {
}

cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "default"
num_workers = 3
custom_tags = {
Expand All @@ -169,7 +169,7 @@ func TestAccAwsPipelineResource_CreatePipeline(t *testing.T) {
}
}
cluster {
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
label = "maintenance"
num_workers = 1
custom_tags = {
Expand Down
8 changes: 1 addition & 7 deletions sql/acceptance/sql_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestAccDashboard(t *testing.T) {
}

resource "databricks_sql_query" "q1" {
data_source_id = databricks_sql_endpoint.this.data_source_id
data_source_id = "{env.TEST_DEFAULT_WAREHOUSE_DATASOURCE_ID}"
name = "tf-{var.RANDOM}-query"
query = "SELECT 1"
}
Expand All @@ -58,12 +58,6 @@ func TestAccDashboard(t *testing.T) {

options = jsonencode({})
}

resource "databricks_sql_endpoint" "this" {
name = "tf-{var.RANDOM}-endpoint"
cluster_size = "Small"
max_num_clusters = 1
}
`,
},
})
Expand Down
8 changes: 1 addition & 7 deletions sql/acceptance/sql_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestAccQuery(t *testing.T) {
{
Template: `
resource "databricks_sql_query" "q1" {
data_source_id = databricks_sql_endpoint.this.data_source_id
data_source_id = "{env.TEST_DEFAULT_WAREHOUSE_DATASOURCE_ID}"
name = "tf-{var.RANDOM}"
query = "SELECT {{ p1 }} AS p1, 2 as p2"

Expand Down Expand Up @@ -43,12 +43,6 @@ func TestAccQuery(t *testing.T) {
}
})
}

resource "databricks_sql_endpoint" "this" {
name = "tf-{var.RANDOM}"
cluster_size = "Small"
max_num_clusters = 1
}
`,
},
})
Expand Down
2 changes: 1 addition & 1 deletion storage/acceptance/aws_s3_mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestAccAwsS3IamMount_WithCluster(t *testing.T) {
resource "databricks_cluster" "this" {
cluster_name = "ready-{var.RANDOM}"
spark_version = data.databricks_spark_version.latest.id
instance_pool_id = "{var.COMMON_INSTANCE_POOL_ID}"
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
autotermination_minutes = 5
num_workers = 1
aws_attributes {
Expand Down