@@ -79,6 +79,9 @@ func TestAccCloudflareLoadBalancerMonitor_Basic(t *testing.T) {
79
79
resource .TestCheckResourceAttr (name , "header.%" , "0" ),
80
80
// also expect api to generate some values
81
81
testAccCheckCloudflareLoadBalancerMonitorDates (name , & loadBalancerMonitor , testStartTime ),
82
+ resource .TestCheckResourceAttr (name , "port" , "0" ),
83
+ resource .TestCheckResourceAttr (name , "consecutive_up" , "0" ),
84
+ resource .TestCheckResourceAttr (name , "consecutive_down" , "0" ),
82
85
),
83
86
},
84
87
},
@@ -261,6 +264,71 @@ func TestAccCloudflareLoadBalancerMonitor_Update(t *testing.T) {
261
264
})
262
265
}
263
266
267
+ func TestAccCloudflareLoadBalancerMonitor_ConsecutiveUpDownDrift (t * testing.T ) {
268
+ accountID := os .Getenv ("CLOUDFLARE_ACCOUNT_ID" )
269
+ rnd := utils .GenerateRandomResourceName ()
270
+ name := "cloudflare_load_balancer_monitor." + rnd
271
+ var loadBalancerMonitor cloudflare.LoadBalancerMonitor
272
+
273
+ resource .Test (t , resource.TestCase {
274
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
275
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
276
+ CheckDestroy : testAccCheckCloudflareLoadBalancerMonitorDestroy ,
277
+ Steps : []resource.TestStep {
278
+ {
279
+ Config : testAccCheckCloudflareLoadBalancerMonitorConfigWithConsecutiveValues (rnd , accountID ),
280
+ Check : resource .ComposeTestCheckFunc (
281
+ testAccCheckCloudflareLoadBalancerMonitorExists (name , & loadBalancerMonitor ),
282
+ resource .TestCheckResourceAttr (name , consts .AccountIDSchemaKey , accountID ),
283
+ resource .TestCheckResourceAttr (name , "consecutive_up" , "0" ),
284
+ resource .TestCheckResourceAttr (name , "consecutive_down" , "0" ),
285
+ resource .TestCheckResourceAttr (name , "port" , "0" ),
286
+ ),
287
+ },
288
+ {
289
+ Config : testAccCheckCloudflareLoadBalancerMonitorConfigWithConsecutiveValues (rnd , accountID ),
290
+ ExpectNonEmptyPlan : false ,
291
+ },
292
+ },
293
+ })
294
+ }
295
+
296
+ func TestAccCloudflareLoadBalancerMonitor_NonZeroConsecutiveValuesDrift (t * testing.T ) {
297
+ accountID := os .Getenv ("CLOUDFLARE_ACCOUNT_ID" )
298
+ rnd := utils .GenerateRandomResourceName ()
299
+ name := "cloudflare_load_balancer_monitor." + rnd
300
+ var loadBalancerMonitor cloudflare.LoadBalancerMonitor
301
+
302
+ resource .Test (t , resource.TestCase {
303
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
304
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
305
+ CheckDestroy : testAccCheckCloudflareLoadBalancerMonitorDestroy ,
306
+ Steps : []resource.TestStep {
307
+ {
308
+ Config : testAccCheckCloudflareLoadBalancerMonitorConfigWithNonZeroConsecutiveValues (rnd , accountID , "Initial description" ),
309
+ Check : resource .ComposeTestCheckFunc (
310
+ testAccCheckCloudflareLoadBalancerMonitorExists (name , & loadBalancerMonitor ),
311
+ resource .TestCheckResourceAttr (name , consts .AccountIDSchemaKey , accountID ),
312
+ resource .TestCheckResourceAttr (name , "consecutive_up" , "2" ),
313
+ resource .TestCheckResourceAttr (name , "consecutive_down" , "2" ),
314
+ resource .TestCheckResourceAttr (name , "port" , "8080" ),
315
+ resource .TestCheckResourceAttr (name , "description" , "Initial description" ),
316
+ ),
317
+ },
318
+ {
319
+ Config : testAccCheckCloudflareLoadBalancerMonitorConfigWithNonZeroConsecutiveValues (rnd , accountID , "Updated description" ),
320
+ Check : resource .ComposeTestCheckFunc (
321
+ testAccCheckCloudflareLoadBalancerMonitorExists (name , & loadBalancerMonitor ),
322
+ resource .TestCheckResourceAttr (name , "description" , "Updated description" ),
323
+ resource .TestCheckResourceAttr (name , "consecutive_up" , "2" ),
324
+ resource .TestCheckResourceAttr (name , "consecutive_down" , "2" ),
325
+ resource .TestCheckResourceAttr (name , "port" , "8080" ),
326
+ ),
327
+ },
328
+ },
329
+ })
330
+ }
331
+
264
332
func TestAccCloudflareLoadBalancerMonitor_ChangingHeadersCauseReplacement (t * testing.T ) {
265
333
domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
266
334
accountID := os .Getenv ("CLOUDFLARE_ACCOUNT_ID" )
@@ -395,6 +463,14 @@ func testAccCheckCloudflareLoadBalancerMonitorConfigSMTP(resourceName, accountID
395
463
return acctest .LoadTestCase ("loadbalancermonitorconfigsmtp.tf" , resourceName , accountID )
396
464
}
397
465
466
+ func testAccCheckCloudflareLoadBalancerMonitorConfigWithConsecutiveValues (rnd , accountID string ) string {
467
+ return acctest .LoadTestCase ("loadbalancermonitorconfigwithconsecutivevalues.tf" , rnd , accountID )
468
+ }
469
+
470
+ func testAccCheckCloudflareLoadBalancerMonitorConfigWithNonZeroConsecutiveValues (rnd , accountID , description string ) string {
471
+ return acctest .LoadTestCase ("loadbalancermonitorconfigwithnonzeroconsecutivevalues.tf" , rnd , accountID , description )
472
+ }
473
+
398
474
func testAccCheckCloudflareLoadBalancerMonitorConfigMissingRequired (accountID string ) string {
399
475
return acctest .LoadTestCase ("loadbalancermonitorconfigmissingrequired.tf" , accountID )
400
476
}
0 commit comments