Skip to content

Commit

Permalink
bigtable: fix wrong diffs when adding two or more clusters (#6144) (#…
Browse files Browse the repository at this point in the history
…12109)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jul 15, 2022
1 parent 14c9d11 commit 167756e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6144.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigtable: fixed an incorrect diff when adding two or more clusters
```
1 change: 1 addition & 0 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ func resourceBigtableInstanceClusterReorderTypeList(_ context.Context, diff *sch
for i, e := range orderedClusters {
if e == nil {
orderedClusters[i] = elem
break
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions google/resource_bigtable_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ func TestAccBigtableInstance_cluster(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection", "instance_type"}, // we don't read instance type back
},
{
Config: testAccBigtableInstance_clusterModifiedAgain(instanceName, 5),
},
{
ResourceName: "google_bigtable_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection", "instance_type"}, // we don't read instance type back
},
},
})
}
Expand Down Expand Up @@ -478,6 +487,51 @@ resource "google_bigtable_instance" "instance" {
`, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
}

// Add two clusters after testAccBigtableInstance_clusterModified.
func testAccBigtableInstance_clusterModifiedAgain(instanceName string, numNodes int) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
name = "%s"
cluster {
cluster_id = "%s-c"
zone = "us-central1-c"
num_nodes = %d
storage_type = "HDD"
}
cluster {
cluster_id = "%s-a"
zone = "us-central1-a"
num_nodes = %d
storage_type = "HDD"
}
cluster {
cluster_id = "%s-b"
zone = "us-central1-b"
num_nodes = %d
storage_type = "HDD"
}
cluster {
cluster_id = "%s-asia-a"
zone = "asia-northeast1-a"
num_nodes = %d
storage_type = "HDD"
}
cluster {
cluster_id = "%s-asia-b"
zone = "asia-northeast1-b"
num_nodes = %d
storage_type = "HDD"
}
deletion_protection = false
labels = {
env = "default"
}
}
`, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
}

func testAccBigtableInstance_development(instanceName string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
Expand Down

0 comments on commit 167756e

Please sign in to comment.