Skip to content

Commit

Permalink
add cluster pinning acctest
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrams committed Nov 11, 2024
1 parent e5dba26 commit 1011fee
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions internal/acceptance/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccClusterResource_CreateClusterWithLibraries(t *testing.T) {
})
}

func singleNodeClusterTemplate(autoTerminationMinutes string) string {
func singleNodeClusterTemplate(autoTerminationMinutes string, isPinned bool) string {
return fmt.Sprintf(`
data "databricks_spark_version" "latest" {
}
Expand All @@ -61,6 +61,7 @@ func singleNodeClusterTemplate(autoTerminationMinutes string) string {
instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}"
num_workers = 0
autotermination_minutes = %s
is_pinned = %t
spark_conf = {
"spark.databricks.cluster.profile" = "singleNode"
"spark.master" = "local[*]"
Expand All @@ -69,14 +70,14 @@ func singleNodeClusterTemplate(autoTerminationMinutes string) string {
"ResourceClass" = "SingleNode"
}
}
`, autoTerminationMinutes)
`, autoTerminationMinutes, isPinned)
}

func TestAccClusterResource_CreateSingleNodeCluster(t *testing.T) {
WorkspaceLevel(t, Step{
Template: singleNodeClusterTemplate("10"),
Template: singleNodeClusterTemplate("10", false),
}, Step{
Template: singleNodeClusterTemplate("20"),
Template: singleNodeClusterTemplate("20", false),
})
}

Expand Down Expand Up @@ -176,6 +177,19 @@ func TestAccClusterResource_WorkloadType(t *testing.T) {
})
}

func TestAccClusterResource_PinAndUnpin(t *testing.T) {
WorkspaceLevel(t, Step{
Template: singleNodeClusterTemplate("10", false),
Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "false"),
}, Step{
Template: singleNodeClusterTemplate("10", true),
Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "true"),
}, Step{
Template: singleNodeClusterTemplate("10", false),
Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "false"),
})
}

func testAccClusterResourceWorkloadTypeTemplate(workloadType string) string {
return fmt.Sprintf(`
data "databricks_spark_version" "latest" {}
Expand Down

0 comments on commit 1011fee

Please sign in to comment.