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

Bigtable: Compare column family #12381

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
3 changes: 3 additions & 0 deletions .changelog/6422.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigtable: fixed comparing column family name when reading a GC policy.
```
3 changes: 2 additions & 1 deletion google/resource_bigtable_gc_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func resourceBigtableGCPolicyRead(d *schema.ResourceData, meta interface{}) erro
defer c.Close()

name := d.Get("table").(string)
columnFamily := d.Get("column_family").(string)
ti, err := c.TableInfo(ctx, name)
if err != nil {
log.Printf("[WARN] Removing %s because it's gone", name)
Expand All @@ -254,7 +255,7 @@ func resourceBigtableGCPolicyRead(d *schema.ResourceData, meta interface{}) erro
}

for _, fi := range ti.FamilyInfos {
if fi.Name == name {
if fi.Name == columnFamily {
d.SetId(fi.GCPolicy)
break
}
Expand Down
19 changes: 13 additions & 6 deletions google/resource_bigtable_gc_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func TestAccBigtableGCPolicy_union(t *testing.T) {
})
}

// Testing multiple GC policies; one per column family.
func TestAccBigtableGCPolicy_multiplePolicies(t *testing.T) {
// bigtable instance does not use the shared HTTP client, this test creates an instance
skipIfVcr(t)
Expand Down Expand Up @@ -406,7 +407,7 @@ func testAccBigtableGCPolicyExists(t *testing.T, n string) resource.TestCheckFun
}

for _, i := range table.FamilyInfos {
if i.Name == rs.Primary.Attributes["column_family"] {
if i.Name == rs.Primary.Attributes["column_family"] && i.GCPolicy == rs.Primary.ID {
return nil
}
}
Expand Down Expand Up @@ -621,14 +622,20 @@ resource "google_bigtable_table" "table" {
instance_name = google_bigtable_instance.instance.id

column_family {
family = "%s"
family = "%sA"
}
column_family {
family = "%sB"
}
column_family {
family = "%sC"
}
}

resource "google_bigtable_gc_policy" "policyA" {
instance_name = google_bigtable_instance.instance.id
table = google_bigtable_table.table.name
column_family = "%s"
column_family = "%sA"

max_age {
days = 30
Expand All @@ -638,7 +645,7 @@ resource "google_bigtable_gc_policy" "policyA" {
resource "google_bigtable_gc_policy" "policyB" {
instance_name = google_bigtable_instance.instance.id
table = google_bigtable_table.table.name
column_family = "%s"
column_family = "%sB"

max_version {
number = 8
Expand All @@ -648,7 +655,7 @@ resource "google_bigtable_gc_policy" "policyB" {
resource "google_bigtable_gc_policy" "policyC" {
instance_name = google_bigtable_instance.instance.id
table = google_bigtable_table.table.name
column_family = "%s"
column_family = "%sC"

max_age {
days = 7
Expand All @@ -660,7 +667,7 @@ resource "google_bigtable_gc_policy" "policyC" {

mode = "UNION"
}
`, instanceName, instanceName, tableName, family, family, family, family)
`, instanceName, instanceName, tableName, family, family, family, family, family, family)
}

func testAccBigtableGCPolicy_gcRulesCreate(instanceName, tableName, family string) string {
Expand Down