From 4a706f722522f286edf607da1564dfd98d399977 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 26 Dec 2018 15:44:30 -0800 Subject: [PATCH] upgrade monitoring tests to 0.12 syntax (#2754) /cc @chrisst --- .../resource_monitoring_alert_policy_test.go | 127 ++++++++---------- ...ring_uptime_check_config_generated_test.go | 6 +- ...rce_monitoring_uptime_check_config_test.go | 6 +- ...nitoring_uptime_check_config.html.markdown | 6 +- 4 files changed, 68 insertions(+), 77 deletions(-) diff --git a/google/resource_monitoring_alert_policy_test.go b/google/resource_monitoring_alert_policy_test.go index 66ab1dfe..bcfec956 100644 --- a/google/resource_monitoring_alert_policy_test.go +++ b/google/resource_monitoring_alert_policy_test.go @@ -120,24 +120,20 @@ resource "google_monitoring_alert_policy" "basic" { enabled = true combiner = "OR" - conditions = [ - { - display_name = "%s" + conditions { + display_name = "%s" - condition_threshold = { - aggregations = [ - { - alignment_period = "60s" - per_series_aligner = "%s" - }, - ] - - duration = "60s" - comparison = "COMPARISON_GT" - filter = "%s" + condition_threshold { + aggregations { + alignment_period = "60s" + per_series_aligner = "%s" } - }, - ] + + duration = "60s" + comparison = "COMPARISON_GT" + filter = "%s" + } + } } `, alertName, conditionName, aligner, filter) } @@ -149,66 +145,61 @@ resource "google_monitoring_alert_policy" "full" { combiner = "OR" enabled = true - conditions = [ - { - display_name = "%s" + conditions { + display_name = "%s" - condition_threshold = { - threshold_value = 50 + condition_threshold { + threshold_value = 50 + filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"" + duration = "60s" + comparison = "COMPARISON_GT" - aggregations = [ - { - alignment_period = "60s" - per_series_aligner = "ALIGN_RATE" - cross_series_reducer = "REDUCE_MEAN" + aggregations { + alignment_period = "60s" + per_series_aligner = "ALIGN_RATE" + cross_series_reducer = "REDUCE_MEAN" - group_by_fields = [ - "metric.label.device_name", - "project", - "resource.label.instance_id", - "resource.label.zone", - ] - }, + group_by_fields = [ + "metric.label.device_name", + "project", + "resource.label.instance_id", + "resource.label.zone", ] - - duration = "60s" - comparison = "COMPARISON_GT" - - trigger = { - percent = 10 - } - - filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"" - } - }, - { - condition_absent { - duration = "3600s" - filter = "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" AND resource.type=\"gce_instance\"" - - aggregations { - alignment_period = "60s" - cross_series_reducer = "REDUCE_MEAN" - per_series_aligner = "ALIGN_MEAN" - - group_by_fields = [ - "project", - "resource.label.instance_id", - "resource.label.zone", - ] - } - - trigger { - count = 1 - } } - display_name = "%s" - }, - ] + trigger { + percent = 10 + } + } + } + + conditions { + display_name = "%s" + + condition_absent { + duration = "3600s" + filter = "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" AND resource.type=\"gce_instance\"" + + aggregations { + alignment_period = "60s" + cross_series_reducer = "REDUCE_MEAN" + per_series_aligner = "ALIGN_MEAN" + + group_by_fields = [ + "project", + "resource.label.instance_id", + "resource.label.zone", + ] + } + + trigger { + count = 1 + } + } + } documentation { - content = "test content" + content = "test content" mime_type = "text/markdown" } } diff --git a/google/resource_monitoring_uptime_check_config_generated_test.go b/google/resource_monitoring_uptime_check_config_generated_test.go index 1a991b9a..a5ae987b 100644 --- a/google/resource_monitoring_uptime_check_config_generated_test.go +++ b/google/resource_monitoring_uptime_check_config_generated_test.go @@ -49,7 +49,7 @@ resource "google_monitoring_uptime_check_config" "http" { display_name = "http-uptime-check-%s" timeout = "60s" - http_check = { + http_check { path = "/some-path" port = "8010" } @@ -62,7 +62,7 @@ resource "google_monitoring_uptime_check_config" "http" { } } - content_matchers = { + content_matchers { content = "example" } } @@ -96,7 +96,7 @@ resource "google_monitoring_uptime_check_config" "tcp_group" { display_name = "tcp-uptime-check-%s" timeout = "60s" - tcp_check = { + tcp_check { port = 888 } diff --git a/google/resource_monitoring_uptime_check_config_test.go b/google/resource_monitoring_uptime_check_config_test.go index c58171c5..9521a4cb 100644 --- a/google/resource_monitoring_uptime_check_config_test.go +++ b/google/resource_monitoring_uptime_check_config_test.go @@ -45,10 +45,10 @@ resource "google_monitoring_uptime_check_config" "http" { display_name = "http-uptime-check-%s" timeout = "60s" - http_check = { + http_check { path = "/%s" port = "8010" - auth_info = { + auth_info { username = "name" password = "%s" } @@ -62,7 +62,7 @@ resource "google_monitoring_uptime_check_config" "http" { } } - content_matchers = { + content_matchers { content = "example" } } diff --git a/website/docs/r/monitoring_uptime_check_config.html.markdown b/website/docs/r/monitoring_uptime_check_config.html.markdown index a5353dca..94f4eacd 100644 --- a/website/docs/r/monitoring_uptime_check_config.html.markdown +++ b/website/docs/r/monitoring_uptime_check_config.html.markdown @@ -43,7 +43,7 @@ resource "google_monitoring_uptime_check_config" "http" { display_name = "http-uptime-check" timeout = "60s" - http_check = { + http_check { path = "/some-path" port = "8010" } @@ -56,7 +56,7 @@ resource "google_monitoring_uptime_check_config" "http" { } } - content_matchers = { + content_matchers { content = "example" } } @@ -74,7 +74,7 @@ resource "google_monitoring_uptime_check_config" "tcp_group" { display_name = "tcp-uptime-check" timeout = "60s" - tcp_check = { + tcp_check { port = 888 }