Skip to content

Commit

Permalink
monitor - fix test for 4.0 (#26846)
Browse files Browse the repository at this point in the history
* fix test for monitor

* fix dcr tests

* fix prometheus rule group update test
  • Loading branch information
teowa authored Aug 1, 2024
1 parent 974d598 commit 3c45554
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

type MonitorActionRuleActionGroupResource struct{}

func TestAccMonitorActionRuleActionGroup_basic(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_action_group' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_action_group", "test")
r := MonitorActionRuleActionGroupResource{}

Expand All @@ -34,6 +39,10 @@ func TestAccMonitorActionRuleActionGroup_basic(t *testing.T) {
}

func TestAccMonitorActionRuleActionGroup_requiresImport(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_action_group' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_action_group", "test")
r := MonitorActionRuleActionGroupResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -48,6 +57,10 @@ func TestAccMonitorActionRuleActionGroup_requiresImport(t *testing.T) {
}

func TestAccMonitorActionRuleActionGroup_complete(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_action_group' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_action_group", "test")
r := MonitorActionRuleActionGroupResource{}

Expand All @@ -63,6 +76,10 @@ func TestAccMonitorActionRuleActionGroup_complete(t *testing.T) {
}

func TestAccMonitorActionRuleActionGroup_update(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_action_group' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_action_group", "test")
r := MonitorActionRuleActionGroupResource{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

type MonitorActionRuleSuppressionResource struct{}

func TestAccMonitorActionRuleSuppression_basic(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_suppression' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_suppression", "test")
r := MonitorActionRuleSuppressionResource{}

Expand All @@ -34,6 +39,10 @@ func TestAccMonitorActionRuleSuppression_basic(t *testing.T) {
}

func TestAccMonitorActionRuleSuppression_requiresImport(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_suppression' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_suppression", "test")
r := MonitorActionRuleSuppressionResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
Expand All @@ -48,6 +57,10 @@ func TestAccMonitorActionRuleSuppression_requiresImport(t *testing.T) {
}

func TestAccMonitorActionRuleSuppression_complete(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_suppression' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_suppression", "test")
r := MonitorActionRuleSuppressionResource{}

Expand All @@ -63,6 +76,10 @@ func TestAccMonitorActionRuleSuppression_complete(t *testing.T) {
}

func TestAccMonitorActionRuleSuppression_updateSuppressionConfig(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip(`This resource has been deprecated in favour of the 'azurerm_monitor_alert_processing_rule_suppression' resource and will be removed in v4.0 of the AzureRM Provider`)
}

data := acceptance.BuildTestData(t, "azurerm_monitor_action_rule_suppression", "test")
r := MonitorActionRuleSuppressionResource{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
name = "acctestActivityLogAlert-%d"
resource_group_name = azurerm_resource_group.test.name
scopes = [azurerm_resource_group.test.id]
location = "global"
criteria {
category = "Recommendation"
Expand All @@ -361,6 +362,7 @@ resource "azurerm_monitor_activity_log_alert" "import" {
name = azurerm_monitor_activity_log_alert.test.name
resource_group_name = azurerm_monitor_activity_log_alert.test.resource_group_name
scopes = [azurerm_resource_group.test.id]
location = azurerm_monitor_activity_log_alert.test.location
criteria {
category = "Recommendation"
Expand Down Expand Up @@ -398,6 +400,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
name = "acctestActivityLogAlert-%d"
resource_group_name = azurerm_resource_group.test.name
scopes = [azurerm_resource_group.test.id]
location = "global"
criteria {
operation_name = "Microsoft.Storage/storageAccounts/write"
Expand Down Expand Up @@ -447,6 +450,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
name = "acctestActivityLogAlert-%d"
resource_group_name = azurerm_resource_group.test.name
scopes = [azurerm_resource_group.test.id]
location = "global"
criteria {
operation_name = "Microsoft.Storage/storageAccounts/write"
Expand Down Expand Up @@ -507,6 +511,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
name = "acctestActivityLogAlert-%d"
resource_group_name = azurerm_resource_group.test.name
scopes = [azurerm_resource_group.test.id]
location = "global"
criteria {
operation_name = "Microsoft.Storage/storageAccounts/write"
Expand Down Expand Up @@ -570,6 +575,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
azurerm_resource_group.test.id,
Expand Down Expand Up @@ -652,6 +658,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
data.azurerm_subscription.current.id,
Expand Down Expand Up @@ -709,6 +716,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
azurerm_resource_group.test.id,
Expand Down Expand Up @@ -779,6 +787,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
data.azurerm_subscription.current.id
Expand Down Expand Up @@ -848,6 +857,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
data.azurerm_subscription.current.id
Expand Down Expand Up @@ -927,6 +937,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
data.azurerm_subscription.current.id
Expand Down Expand Up @@ -988,6 +999,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
azurerm_resource_group.test.id,
Expand Down Expand Up @@ -1055,6 +1067,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
azurerm_resource_group.test.id,
Expand Down Expand Up @@ -1132,6 +1145,7 @@ resource "azurerm_monitor_activity_log_alert" "test" {
resource_group_name = azurerm_resource_group.test.name
enabled = true
description = "This is just a test acceptance."
location = "global"
scopes = [
azurerm_resource_group.test.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ resource "azurerm_kubernetes_cluster" "test" {
node_count = 1
vm_size = "Standard_DS2_v2"
enable_host_encryption = true
upgrade_settings {
max_surge = "10%%"
}
}
identity {
Expand Down Expand Up @@ -267,6 +270,9 @@ resource "azurerm_kubernetes_cluster" "test" {
node_count = 1
vm_size = "Standard_DS2_v2"
enable_host_encryption = true
upgrade_settings {
max_surge = "10%%"
}
}
identity {
Expand All @@ -285,6 +291,9 @@ resource "azurerm_kubernetes_cluster" "test2" {
node_count = 2
vm_size = "Standard_DS2_v2"
enable_host_encryption = true
upgrade_settings {
max_surge = "10%%"
}
}
identity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,6 @@ resource "azurerm_monitor_data_collection_rule" "test" {
name = "test-datasource-prometheus"
}
platform_telemetry {
streams = ["Microsoft.Cache/redis:Metrics-Group-All"]
name = "test-datasource-telemetry"
}
windows_event_log {
streams = ["Microsoft-WindowsEvent"]
x_path_queries = ["System!*[System[EventID=4648]]"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestAccDataSourceMonitorDiagnosticCategories_appService(t *testing.T) {
Config: r.appService(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("metrics.#").Exists(),
check.That(data.ResourceName).Key("logs.#").Exists(),
check.That(data.ResourceName).Key("log_category_types.#").Exists(),
check.That(data.ResourceName).Key("log_category_groups.#").Exists(),
),
Expand All @@ -39,7 +38,6 @@ func TestAccDataSourceMonitorDiagnosticCategories_storageAccount(t *testing.T) {
Config: r.storageAccount(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("metrics.#").Exists(),
check.That(data.ResourceName).Key("logs.#").Exists(),
check.That(data.ResourceName).Key("log_category_types.#").Exists(),
check.That(data.ResourceName).Key("log_category_groups.#").Exists(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestAccMonitorDiagnosticSetting_eventhub(t *testing.T) {
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("eventhub_name").Exists(),
check.That(data.ResourceName).Key("eventhub_authorization_rule_id").Exists(),
check.That(data.ResourceName).Key("log.#").HasValue("2"),
check.That(data.ResourceName).Key("metric.#").HasValue("1"),
),
},
Expand All @@ -46,7 +45,7 @@ func TestAccMonitorDiagnosticSetting_CategoryGroup(t *testing.T) {
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("eventhub_name").Exists(),
check.That(data.ResourceName).Key("eventhub_authorization_rule_id").Exists(),
check.That(data.ResourceName).Key("log.#").HasValue("2"),
check.That(data.ResourceName).Key("enabled_log.#").HasValue("1"),
check.That(data.ResourceName).Key("metric.#").HasValue("1"),
),
},
Expand Down Expand Up @@ -82,7 +81,6 @@ func TestAccMonitorDiagnosticSetting_logAnalyticsWorkspace(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("log_analytics_workspace_id").Exists(),
check.That(data.ResourceName).Key("log.#").HasValue("2"),
check.That(data.ResourceName).Key("metric.#").HasValue("1"),
),
},
Expand Down Expand Up @@ -115,7 +113,6 @@ func TestAccMonitorDiagnosticSetting_partnerSolution(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("partner_solution_id").Exists(),
check.That(data.ResourceName).Key("log.#").HasValue("2"),
check.That(data.ResourceName).Key("metric.#").HasValue("1"),
),
},
Expand All @@ -133,7 +130,6 @@ func TestAccMonitorDiagnosticSetting_storageAccount(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("storage_account_id").Exists(),
check.That(data.ResourceName).Key("log.#").HasValue("2"),
check.That(data.ResourceName).Key("metric.#").HasValue("1"),
),
},
Expand Down

0 comments on commit 3c45554

Please sign in to comment.