|
| 1 | +package tencentcloud |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" |
| 7 | +) |
| 8 | + |
| 9 | +func TestAccTencentCloudMonitorAlarmPolicyResource(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + resource.Test(t, resource.TestCase{ |
| 12 | + PreCheck: func() { testAccPreCheck(t) }, |
| 13 | + Providers: testAccProviders, |
| 14 | + Steps: []resource.TestStep{ |
| 15 | + { |
| 16 | + Config: testAccMonitorAlarmPolicy, |
| 17 | + Check: resource.ComposeTestCheckFunc( |
| 18 | + //resource.TestCheckResourceAttrSet("tencentcloud_monitor_alarm_policy.policy", "create_time"), |
| 19 | + resource.TestCheckResourceAttr("tencentcloud_monitor_alarm_policy.policy", "policy_name", "terraform"), |
| 20 | + ), |
| 21 | + }, |
| 22 | + }, |
| 23 | + }) |
| 24 | +} |
| 25 | + |
| 26 | +const testAccMonitorAlarmPolicy string = ` |
| 27 | +resource "tencentcloud_monitor_alarm_policy" "policy" { |
| 28 | + enable = 1 |
| 29 | + monitor_type = "MT_QCE" |
| 30 | + namespace = "cvm_device" |
| 31 | + notice_ids = [ |
| 32 | + "notice-f2svbu3w", |
| 33 | + ] |
| 34 | + policy_name = "terraform" |
| 35 | + project_id = 0 |
| 36 | +
|
| 37 | + conditions { |
| 38 | + is_union_rule = 0 |
| 39 | +
|
| 40 | + rules { |
| 41 | + continue_period = 5 |
| 42 | + description = "CPUUtilization" |
| 43 | + is_power_notice = 0 |
| 44 | + metric_name = "CpuUsage" |
| 45 | + notice_frequency = 7200 |
| 46 | + operator = "gt" |
| 47 | + period = 60 |
| 48 | + rule_type = "STATIC" |
| 49 | + unit = "%" |
| 50 | + value = "95" |
| 51 | + } |
| 52 | + rules { |
| 53 | + continue_period = 5 |
| 54 | + description = "PublicBandwidthUtilization" |
| 55 | + is_power_notice = 0 |
| 56 | + metric_name = "Outratio" |
| 57 | + notice_frequency = 7200 |
| 58 | + operator = "gt" |
| 59 | + period = 60 |
| 60 | + rule_type = "STATIC" |
| 61 | + unit = "%" |
| 62 | + value = "95" |
| 63 | + } |
| 64 | + rules { |
| 65 | + continue_period = 5 |
| 66 | + description = "MemoryUtilization" |
| 67 | + is_power_notice = 0 |
| 68 | + metric_name = "MemUsage" |
| 69 | + notice_frequency = 7200 |
| 70 | + operator = "gt" |
| 71 | + period = 60 |
| 72 | + rule_type = "STATIC" |
| 73 | + unit = "%" |
| 74 | + value = "95" |
| 75 | + } |
| 76 | + rules { |
| 77 | + continue_period = 5 |
| 78 | + description = "DiskUtilization" |
| 79 | + is_power_notice = 0 |
| 80 | + metric_name = "CvmDiskUsage" |
| 81 | + notice_frequency = 7200 |
| 82 | + operator = "gt" |
| 83 | + period = 60 |
| 84 | + rule_type = "STATIC" |
| 85 | + unit = "%" |
| 86 | + value = "95" |
| 87 | + } |
| 88 | + } |
| 89 | +
|
| 90 | + event_conditions { |
| 91 | + continue_period = 0 |
| 92 | + description = "DiskReadonly" |
| 93 | + is_power_notice = 0 |
| 94 | + metric_name = "disk_readonly" |
| 95 | + notice_frequency = 0 |
| 96 | + period = 0 |
| 97 | + } |
| 98 | +
|
| 99 | + policy_tag { |
| 100 | + key = "test-tag" |
| 101 | + value = "unit-test" |
| 102 | + } |
| 103 | +} |
| 104 | +` |
0 commit comments