@@ -22,7 +22,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
22
22
Steps : []resource.TestStep {
23
23
{
24
24
// create instance with replica count 1
25
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
25
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
26
26
},
27
27
{
28
28
ResourceName : "google_memorystore_instance.test" ,
@@ -31,7 +31,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
31
31
},
32
32
{
33
33
// update replica count to 2
34
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 2 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
34
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 2 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
35
35
},
36
36
{
37
37
ResourceName : "google_memorystore_instance.test" ,
@@ -40,7 +40,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
40
40
},
41
41
{
42
42
// clean up the resource
43
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 2 , shardCount : 3 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
43
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 2 , shardCount : 3 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
44
44
},
45
45
},
46
46
})
@@ -59,7 +59,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
59
59
Steps : []resource.TestStep {
60
60
{
61
61
// create cluster with shard count 3
62
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
62
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
63
63
},
64
64
{
65
65
ResourceName : "google_memorystore_instance.test" ,
@@ -68,7 +68,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
68
68
},
69
69
{
70
70
// update shard count to 5
71
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 5 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
71
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 5 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
72
72
},
73
73
{
74
74
ResourceName : "google_memorystore_instance.test" ,
@@ -77,7 +77,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
77
77
},
78
78
{
79
79
// clean up the resource
80
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 5 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false }),
80
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 1 , shardCount : 5 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
81
81
},
82
82
},
83
83
})
@@ -103,7 +103,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
103
103
engineConfigs : map [string ]string {
104
104
"maxmemory-policy" : "volatile-ttl" ,
105
105
},
106
- deletionProtectionEnabled : false }),
106
+ deletionProtectionEnabled : false ,
107
+ maintenanceDay : "MONDAY" ,
108
+ maintenanceHours : 1 ,
109
+ maintenanceMinutes : 0 ,
110
+ maintenanceSeconds : 0 ,
111
+ maintenanceNanos : 0 }),
107
112
},
108
113
{
109
114
ResourceName : "google_memorystore_instance.test" ,
@@ -120,7 +125,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
120
125
"maxmemory-policy" : "allkeys-lru" ,
121
126
"maxmemory-clients" : "90%" ,
122
127
},
123
- deletionProtectionEnabled : false }),
128
+ deletionProtectionEnabled : false ,
129
+ maintenanceDay : "MONDAY" ,
130
+ maintenanceHours : 1 ,
131
+ maintenanceMinutes : 0 ,
132
+ maintenanceSeconds : 0 ,
133
+ maintenanceNanos : 0 }),
124
134
},
125
135
{
126
136
ResourceName : "google_memorystore_instance.test" ,
@@ -137,7 +147,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
137
147
"maxmemory-policy" : "allkeys-lru" ,
138
148
"maxmemory-clients" : "90%" ,
139
149
},
140
- deletionProtectionEnabled : false }),
150
+ deletionProtectionEnabled : false ,
151
+ maintenanceDay : "MONDAY" ,
152
+ maintenanceHours : 1 ,
153
+ maintenanceMinutes : 0 ,
154
+ maintenanceSeconds : 0 ,
155
+ maintenanceNanos : 0 }),
141
156
},
142
157
},
143
158
})
@@ -161,7 +176,11 @@ func TestAccMemorystoreInstance_updateDeletionProtection(t *testing.T) {
161
176
shardCount : 3 ,
162
177
zoneDistributionMode : "MULTI_ZONE" ,
163
178
deletionProtectionEnabled : true ,
164
- }),
179
+ maintenanceDay : "MONDAY" ,
180
+ maintenanceHours : 1 ,
181
+ maintenanceMinutes : 0 ,
182
+ maintenanceSeconds : 0 ,
183
+ maintenanceNanos : 0 }),
165
184
},
166
185
{
167
186
ResourceName : "google_memorystore_instance.test" ,
@@ -175,7 +194,11 @@ func TestAccMemorystoreInstance_updateDeletionProtection(t *testing.T) {
175
194
shardCount : 3 ,
176
195
zoneDistributionMode : "MULTI_ZONE" ,
177
196
deletionProtectionEnabled : false ,
178
- }),
197
+ maintenanceDay : "MONDAY" ,
198
+ maintenanceHours : 1 ,
199
+ maintenanceMinutes : 0 ,
200
+ maintenanceSeconds : 0 ,
201
+ maintenanceNanos : 0 }),
179
202
},
180
203
{
181
204
ResourceName : "google_memorystore_instance.test" ,
@@ -285,7 +308,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
285
308
Steps : []resource.TestStep {
286
309
{
287
310
// create instance with AOF enabled
288
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "AOF" , deletionProtectionEnabled : false }),
311
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "AOF" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
289
312
},
290
313
{
291
314
ResourceName : "google_memorystore_instance.test" ,
@@ -294,7 +317,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
294
317
},
295
318
{
296
319
// update persitence to RDB
297
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "RDB" , deletionProtectionEnabled : false }),
320
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : true , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "RDB" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
298
321
},
299
322
{
300
323
ResourceName : "google_memorystore_instance.test" ,
@@ -303,7 +326,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
303
326
},
304
327
{
305
328
// clean up the resource
306
- Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "RDB" , deletionProtectionEnabled : false }),
329
+ Config : createOrUpdateMemorystoreInstance (& InstanceParams {name : name , replicaCount : 0 , shardCount : 3 , preventDestroy : false , zoneDistributionMode : "MULTI_ZONE" , persistenceMode : "RDB" , deletionProtectionEnabled : false , maintenanceDay : "MONDAY" , maintenanceHours : 1 , maintenanceMinutes : 0 , maintenanceSeconds : 0 , maintenanceNanos : 0 }),
307
330
},
308
331
},
309
332
})
@@ -320,6 +343,11 @@ type InstanceParams struct {
320
343
zone string
321
344
deletionProtectionEnabled bool
322
345
persistenceMode string
346
+ maintenanceDay string
347
+ maintenanceHours int
348
+ maintenanceMinutes int
349
+ maintenanceSeconds int
350
+ maintenanceNanos int
323
351
engineVersion string
324
352
}
325
353
@@ -345,6 +373,22 @@ func createOrUpdateMemorystoreInstance(params *InstanceParams) string {
345
373
}
346
374
` , params .zoneDistributionMode , params .zone )
347
375
}
376
+ maintenancePolicyBlock := ``
377
+ if params .maintenanceDay != "" {
378
+ maintenancePolicyBlock = fmt .Sprintf (`
379
+ maintenance_policy {
380
+ weekly_maintenance_window {
381
+ day = "%s"
382
+ start_time {
383
+ hours = %d
384
+ minutes = %d
385
+ seconds = %d
386
+ nanos = %d
387
+ }
388
+ }
389
+ }
390
+ ` , params .maintenanceDay , params .maintenanceHours , params .maintenanceMinutes , params .maintenanceSeconds , params .maintenanceNanos )
391
+ }
348
392
persistenceBlock := ``
349
393
if params .persistenceMode != "" {
350
394
persistenceBlock = fmt .Sprintf (`
@@ -370,6 +414,7 @@ resource "google_memorystore_instance" "test" {
370
414
%s
371
415
}
372
416
%s
417
+ %s
373
418
%s
374
419
depends_on = [
375
420
google_network_connectivity_service_connection_policy.default
@@ -402,5 +447,5 @@ resource "google_compute_network" "producer_net" {
402
447
403
448
data "google_project" "project" {
404
449
}
405
- ` , params .name , params .replicaCount , params .shardCount , params .nodeType , params .deletionProtectionEnabled , params .engineVersion , strBuilder .String (), zoneDistributionConfigBlock , persistenceBlock , lifecycleBlock , params .name , params .name , params .name )
450
+ ` , params .name , params .replicaCount , params .shardCount , params .nodeType , params .deletionProtectionEnabled , params .engineVersion , strBuilder .String (), zoneDistributionConfigBlock , maintenancePolicyBlock , persistenceBlock , lifecycleBlock , params .name , params .name , params .name )
406
451
}
0 commit comments