Skip to content

Commit f822fa9

Browse files
committed
fix(notification channels): avoid drift on send_test_notification = true
1 parent 2082fa9 commit f822fa9

File tree

26 files changed

+217
-164
lines changed

26 files changed

+217
-164
lines changed

sysdig/resource_sysdig_monitor_alert_metric_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ func TestAccAlertMetric(t *testing.T) {
4242
},
4343
},
4444
{
45-
ResourceName: "sysdig_secure_notification_channel_pagerduty.sample-pagerduty",
46-
ImportState: true,
47-
ImportStateVerify: true,
45+
ResourceName: "sysdig_secure_notification_channel_pagerduty.sample-pagerduty",
46+
ImportState: true,
47+
ImportStateVerify: true,
48+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4849
SkipFunc: func() (bool, error) {
4950
return buildinfo.IBMMonitor, nil
5051
},
@@ -62,7 +63,7 @@ resource "sysdig_monitor_alert_metric" "sample" {
6263
6364
metric = "avg(avg(cpu.used.percent)) > 50"
6465
scope = "agent.id in (\"foo\")"
65-
66+
6667
trigger_after_minutes = 10
6768
6869
enabled = false
@@ -86,7 +87,7 @@ resource "sysdig_monitor_alert_metric" "sample" {
8687
8788
metric = "avg(avg(cpu.used.percent)) > 50"
8889
scope = "agent.id in (\"foo\")"
89-
90+
9091
trigger_after_minutes = 10
9192
group_name = "sample_group_name"
9293
enabled = false
@@ -109,7 +110,7 @@ resource "sysdig_monitor_alert_metric" "sample2" {
109110
severity = 3
110111
111112
metric = "avg(avg(cpu.used.percent)) > 50"
112-
113+
113114
trigger_after_minutes = 10
114115
115116
enabled = false

sysdig/resource_sysdig_monitor_notification_channel_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func monitorNotificationChannelToResourceData(nc *v2.NotificationChannel, data *
8484
}
8585
_ = data.Set("notify_when_ok", nc.Options.NotifyOnOk)
8686
_ = data.Set("notify_when_resolved", nc.Options.NotifyOnResolve)
87-
_ = data.Set("send_test_notification", nc.Options.SendTestNotification)
87+
// do not update "send_test_notification" from the api response as it will always be "false" on subsequent reads because the fields is not persisted
8888

8989
return
9090
}

sysdig/resource_sysdig_monitor_notification_channel_custom_webhook_test.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,46 @@ func TestAccMonitorNotificationChannelCustomWebhook(t *testing.T) {
2828
Config: monitorNotificationChannelCustomWebhookWithName(rText()),
2929
},
3030
{
31-
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook1",
32-
ImportState: true,
33-
ImportStateVerify: true,
31+
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook1",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3435
},
3536
{
3637
Config: monitorNotificationChannelCustomWebhookWithNameWithAdditionalheaders(rText()),
3738
},
3839
{
39-
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook2",
40-
ImportState: true,
41-
ImportStateVerify: true,
40+
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook2",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4244
},
4345
{
4446
Config: monitorNotificationChannelCustomWebhookSharedWithCurrentTeam(rText()),
4547
},
4648
{
47-
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook3",
48-
ImportState: true,
49-
ImportStateVerify: true,
49+
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook3",
50+
ImportState: true,
51+
ImportStateVerify: true,
52+
ImportStateVerifyIgnore: []string{"send_test_notification"},
5053
},
5154
{
5255
Config: monitorNotificationChannelCustomWebhookSharedWithAllowInsecureConnections(rText()),
5356
},
5457
{
55-
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook4",
56-
ImportState: true,
57-
ImportStateVerify: true,
58+
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook4",
59+
ImportState: true,
60+
ImportStateVerify: true,
61+
ImportStateVerifyIgnore: []string{"send_test_notification"},
5862
},
5963
{
6064
Config: monitorNotificationChannelCustomWebhookSharedWithAdditionalHeaders(rText()),
6165
},
6266
{
63-
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook5",
64-
ImportState: true,
65-
ImportStateVerify: true,
67+
ResourceName: "sysdig_monitor_notification_channel_custom_webhook.sample-custom-webhook5",
68+
ImportState: true,
69+
ImportStateVerify: true,
70+
ImportStateVerifyIgnore: []string{"send_test_notification"},
6671
},
6772
},
6873
})

sysdig/resource_sysdig_monitor_notification_channel_email_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ func TestAccMonitorNotificationChannelEmail(t *testing.T) {
3434
Config: monitorNotificationChannelEmailSharedWithCurrentTeam(rText()),
3535
},
3636
{
37-
ResourceName: "sysdig_monitor_notification_channel_email.sample_email",
38-
ImportState: true,
39-
ImportStateVerify: true,
37+
ResourceName: "sysdig_monitor_notification_channel_email.sample_email",
38+
ImportState: true,
39+
ImportStateVerify: true,
40+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4041
},
4142
},
4243
})

sysdig/resource_sysdig_monitor_notification_channel_google_chat_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ func TestAccMonitorNotificationChannelGoogleChat(t *testing.T) {
2828
Config: monitorNotificationChannelGoogleChatWithName(rText()),
2929
},
3030
{
31-
ResourceName: "sysdig_monitor_notification_channel_google_chat.sample_google_chat1",
32-
ImportState: true,
33-
ImportStateVerify: true,
31+
ResourceName: "sysdig_monitor_notification_channel_google_chat.sample_google_chat1",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3435
},
3536
{
3637
Config: monitorNotificationChannelGoogleChatSharedWithCurrentTeam(rText()),
3738
},
3839
{
39-
ResourceName: "sysdig_monitor_notification_channel_google_chat.sample_google_chat2",
40-
ImportState: true,
41-
ImportStateVerify: true,
40+
ResourceName: "sysdig_monitor_notification_channel_google_chat.sample_google_chat2",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4244
},
4345
},
4446
})

sysdig/resource_sysdig_monitor_notification_channel_ibm_event_notification_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ func TestAccMonitorNotificationChannelIBMEventNotification(t *testing.T) {
3535
Config: monitorNotificationChannelIBMEventNotificationWithName(rText(), ibmEventNotificationInstanceId),
3636
},
3737
{
38-
ResourceName: "sysdig_monitor_notification_channel_ibm_event_notification.sample1",
39-
ImportState: true,
40-
ImportStateVerify: true,
38+
ResourceName: "sysdig_monitor_notification_channel_ibm_event_notification.sample1",
39+
ImportState: true,
40+
ImportStateVerify: true,
41+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4142
},
4243
{
4344
Config: monitorNotificationChannelIBMEventNotificationSharedWithCurrentTeam(rText(), ibmEventNotificationInstanceId),
4445
},
4546
{
46-
ResourceName: "sysdig_monitor_notification_channel_ibm_event_notification.sample2",
47-
ImportState: true,
48-
ImportStateVerify: true,
47+
ResourceName: "sysdig_monitor_notification_channel_ibm_event_notification.sample2",
48+
ImportState: true,
49+
ImportStateVerify: true,
50+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4951
},
5052
},
5153
})

sysdig/resource_sysdig_monitor_notification_channel_msteams_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ func TestAccMonitorNotificationChannelMSTeams(t *testing.T) {
2828
Config: monitorNotificationChannelMSTeamsWithName(rText()),
2929
},
3030
{
31-
ResourceName: "sysdig_monitor_notification_channel_msteams.sample-msteams1",
32-
ImportState: true,
33-
ImportStateVerify: true,
31+
ResourceName: "sysdig_monitor_notification_channel_msteams.sample-msteams1",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3435
},
3536
{
3637
Config: monitorNotificationChannelMSTeamsSharedWithCurrentTeam(rText()),
3738
},
3839
{
39-
ResourceName: "sysdig_monitor_notification_channel_msteams.sample-msteams2",
40-
ImportState: true,
41-
ImportStateVerify: true,
40+
ResourceName: "sysdig_monitor_notification_channel_msteams.sample-msteams2",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4244
},
4345
},
4446
})

sysdig/resource_sysdig_monitor_notification_channel_opsgenie_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,28 @@ func TestAccMonitorNotificationChannelOpsGenie(t *testing.T) {
2929
Config: monitorNotificationChannelOpsGenieWithName(rText()),
3030
},
3131
{
32-
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie",
33-
ImportState: true,
34-
ImportStateVerify: true,
32+
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie",
33+
ImportState: true,
34+
ImportStateVerify: true,
35+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3536
},
3637
{
3738
Config: monitorNotificationChannelOpsGenieWithNameAndRegion(rText()),
3839
},
3940
{
40-
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie-2",
41-
ImportState: true,
42-
ImportStateVerify: true,
41+
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie-2",
42+
ImportState: true,
43+
ImportStateVerify: true,
44+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4345
},
4446
{
4547
Config: monitorNotificationChannelOpsGenieSharedWithCurrentTeam(rText()),
4648
},
4749
{
48-
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie-3",
49-
ImportState: true,
50-
ImportStateVerify: true,
50+
ResourceName: "sysdig_monitor_notification_channel_opsgenie.sample-opsgenie-3",
51+
ImportState: true,
52+
ImportStateVerify: true,
53+
ImportStateVerifyIgnore: []string{"send_test_notification"},
5154
},
5255
},
5356
})

sysdig/resource_sysdig_monitor_notification_channel_pagerduty_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ func TestAccMonitorNotificationChannelPagerduty(t *testing.T) {
3232
Config: monitorNotificationChannelPagerdutySharedWithCurrentTeam(rText()),
3333
},
3434
{
35-
ResourceName: "sysdig_monitor_notification_channel_pagerduty.sample-pagerduty",
36-
ImportState: true,
37-
ImportStateVerify: true,
35+
ResourceName: "sysdig_monitor_notification_channel_pagerduty.sample-pagerduty",
36+
ImportState: true,
37+
ImportStateVerify: true,
38+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3839
},
3940
},
4041
})

sysdig/resource_sysdig_monitor_notification_channel_prometheus_alert_manager_test.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,37 @@ func TestAccMonitorNotificationChannelPrometheusAlertManager(t *testing.T) {
2828
Config: monitorNotificationChannelPrometheusAlertManagerWithName(rText()),
2929
},
3030
{
31-
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel1",
32-
ImportState: true,
33-
ImportStateVerify: true,
31+
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel1",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"send_test_notification"},
3435
},
3536
{
3637
Config: monitorNotificationChannelPrometheusAlertManagerWithNameWithAdditionalheaders(rText()),
3738
},
3839
{
39-
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel2",
40-
ImportState: true,
41-
ImportStateVerify: true,
40+
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel2",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"send_test_notification"},
4244
},
4345
{
4446
Config: monitorNotificationChannelPrometheusAlertManagerWithNameWithAllowInsecureConnections(rText()),
4547
},
4648
{
47-
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel3",
48-
ImportState: true,
49-
ImportStateVerify: true,
49+
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel3",
50+
ImportState: true,
51+
ImportStateVerify: true,
52+
ImportStateVerifyIgnore: []string{"send_test_notification"},
5053
},
5154
{
5255
Config: monitorNotificationChannelPrometheusAlertManagerSharedWithCurrentTeam(rText()),
5356
},
5457
{
55-
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel4",
56-
ImportState: true,
57-
ImportStateVerify: true,
58+
ResourceName: "sysdig_monitor_notification_channel_prometheus_alert_manager.sample-channel4",
59+
ImportState: true,
60+
ImportStateVerify: true,
61+
ImportStateVerifyIgnore: []string{"send_test_notification"},
5862
},
5963
},
6064
})

0 commit comments

Comments
 (0)