@@ -23,7 +23,7 @@ import (
23
23
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
24
24
)
25
25
26
- func TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (t * testing.T ) {
26
+ func TestAccBigtableAppProfile_bigtableAppProfileAnyclusterExample (t * testing.T ) {
27
27
t .Parallel ()
28
28
29
29
context := map [string ]interface {}{
@@ -37,7 +37,7 @@ func TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample(t *testing.
37
37
CheckDestroy : testAccCheckBigtableAppProfileDestroyProducer (t ),
38
38
Steps : []resource.TestStep {
39
39
{
40
- Config : testAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (context ),
40
+ Config : testAccBigtableAppProfile_bigtableAppProfileAnyclusterExample (context ),
41
41
},
42
42
{
43
43
ResourceName : "google_bigtable_app_profile.ap" ,
@@ -49,16 +49,28 @@ func TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample(t *testing.
49
49
})
50
50
}
51
51
52
- func testAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (context map [string ]interface {}) string {
52
+ func testAccBigtableAppProfile_bigtableAppProfileAnyclusterExample (context map [string ]interface {}) string {
53
53
return Nprintf (`
54
54
resource "google_bigtable_instance" "instance" {
55
55
name = "tf-test-bt-instance%{random_suffix}"
56
56
cluster {
57
- cluster_id = "tf-test-bt-instance%{random_suffix}"
57
+ cluster_id = "cluster-1"
58
+ zone = "us-central1-a"
59
+ num_nodes = 3
60
+ storage_type = "HDD"
61
+ }
62
+ cluster {
63
+ cluster_id = "cluster-2"
58
64
zone = "us-central1-b"
59
65
num_nodes = 3
60
66
storage_type = "HDD"
61
67
}
68
+ cluster {
69
+ cluster_id = "cluster-3"
70
+ zone = "us-central1-c"
71
+ num_nodes = 3
72
+ storage_type = "HDD"
73
+ }
62
74
63
75
deletion_protection = "%{deletion_protection}"
64
76
}
@@ -67,7 +79,9 @@ resource "google_bigtable_app_profile" "ap" {
67
79
instance = google_bigtable_instance.instance.name
68
80
app_profile_id = "tf-test-bt-profile%{random_suffix}"
69
81
82
+ // Requests will be routed to any of the 3 clusters.
70
83
multi_cluster_routing_use_any = true
84
+
71
85
ignore_warnings = true
72
86
}
73
87
` , context )
@@ -104,7 +118,7 @@ func testAccBigtableAppProfile_bigtableAppProfileSingleclusterExample(context ma
104
118
resource "google_bigtable_instance" "instance" {
105
119
name = "tf-test-bt-instance%{random_suffix}"
106
120
cluster {
107
- cluster_id = "tf-test-bt-instance%{random_suffix} "
121
+ cluster_id = "cluster-1 "
108
122
zone = "us-central1-b"
109
123
num_nodes = 3
110
124
storage_type = "HDD"
@@ -117,8 +131,9 @@ resource "google_bigtable_app_profile" "ap" {
117
131
instance = google_bigtable_instance.instance.name
118
132
app_profile_id = "tf-test-bt-profile%{random_suffix}"
119
133
134
+ // Requests will be routed to the following cluster.
120
135
single_cluster_routing {
121
- cluster_id = "tf-test-bt-instance%{random_suffix} "
136
+ cluster_id = "cluster-1 "
122
137
allow_transactional_writes = true
123
138
}
124
139
@@ -127,6 +142,71 @@ resource "google_bigtable_app_profile" "ap" {
127
142
` , context )
128
143
}
129
144
145
+ func TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (t * testing.T ) {
146
+ t .Parallel ()
147
+
148
+ context := map [string ]interface {}{
149
+ "deletion_protection" : false ,
150
+ "random_suffix" : randString (t , 10 ),
151
+ }
152
+
153
+ vcrTest (t , resource.TestCase {
154
+ PreCheck : func () { testAccPreCheck (t ) },
155
+ Providers : testAccProviders ,
156
+ CheckDestroy : testAccCheckBigtableAppProfileDestroyProducer (t ),
157
+ Steps : []resource.TestStep {
158
+ {
159
+ Config : testAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (context ),
160
+ },
161
+ {
162
+ ResourceName : "google_bigtable_app_profile.ap" ,
163
+ ImportState : true ,
164
+ ImportStateVerify : true ,
165
+ ImportStateVerifyIgnore : []string {"app_profile_id" , "instance" , "ignore_warnings" , "ignore_warnings" },
166
+ },
167
+ },
168
+ })
169
+ }
170
+
171
+ func testAccBigtableAppProfile_bigtableAppProfileMulticlusterExample (context map [string ]interface {}) string {
172
+ return Nprintf (`
173
+ resource "google_bigtable_instance" "instance" {
174
+ name = "tf-test-bt-instance%{random_suffix}"
175
+ cluster {
176
+ cluster_id = "cluster-1"
177
+ zone = "us-central1-a"
178
+ num_nodes = 3
179
+ storage_type = "HDD"
180
+ }
181
+ cluster {
182
+ cluster_id = "cluster-2"
183
+ zone = "us-central1-b"
184
+ num_nodes = 3
185
+ storage_type = "HDD"
186
+ }
187
+ cluster {
188
+ cluster_id = "cluster-3"
189
+ zone = "us-central1-c"
190
+ num_nodes = 3
191
+ storage_type = "HDD"
192
+ }
193
+
194
+ deletion_protection = "%{deletion_protection}"
195
+ }
196
+
197
+ resource "google_bigtable_app_profile" "ap" {
198
+ instance = google_bigtable_instance.instance.name
199
+ app_profile_id = "tf-test-bt-profile%{random_suffix}"
200
+
201
+ // Requests will be routed to the following 2 clusters.
202
+ multi_cluster_routing_use_any = true
203
+ multi_cluster_routing_cluster_ids = ["cluster-1", "cluster-2"]
204
+
205
+ ignore_warnings = true
206
+ }
207
+ ` , context )
208
+ }
209
+
130
210
func testAccCheckBigtableAppProfileDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
131
211
return func (s * terraform.State ) error {
132
212
for name , rs := range s .RootModule ().Resources {
0 commit comments