-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. [Update] existing protection rules test to run on basis of env fla…
…g. 2.[Update] Use test_config for uuids in protection rules tests
- Loading branch information
1 parent
5937089
commit c1f58b4
Showing
6 changed files
with
141 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,87 @@ | ||
package nutanix | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccNutanixProtectionRulesDataSource_basic(t *testing.T) { | ||
resource.ParallelTest(t, resource.TestCase{ | ||
if os.Getenv("PROTECTION_RULES_TEST_FLAG") != "true" { | ||
t.Skip() | ||
} | ||
dataSourceName := "data.nutanix_protection_rules.test" | ||
aZUUIDSource := testVars.ProtectionPolicy.LocalAz.UUID | ||
clusterUUIDSource := testVars.ProtectionPolicy.LocalAz.ClusterUUID | ||
aZUUIDTarget := testVars.ProtectionPolicy.DestinationAz.UUID | ||
clusterUUIDTarget := testVars.ProtectionPolicy.DestinationAz.UUID | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccProtectionRulesDataSourceConfig(), | ||
Config: testAccProtectionRulesDataSourceConfig(aZUUIDSource, clusterUUIDSource, aZUUIDTarget, clusterUUIDTarget, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(dataSourceName, "entities.1.metadata.uuid"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccProtectionRulesDataSourceConfig() string { | ||
return ` | ||
data "nutanix_protection_rules" "test" {} | ||
` | ||
func testAccProtectionRulesDataSourceConfig(aZUUIDSource, clusterUUIDSource, aZUUIDTarget, clusterUUIDTarget string, snapshots int64) string { | ||
return fmt.Sprintf(` | ||
locals{ | ||
category = "AnalyticsExclusions" | ||
keys = ["EfficiencyMeasurement", "AnomalyDetection"] | ||
} | ||
resource "nutanix_protection_rule" "test" { | ||
count = 2 | ||
name = "test-rule-${count.index}" | ||
description = "test-rule-desc-${count.index}" | ||
ordered_availability_zone_list{ | ||
availability_zone_url = "%s" | ||
cluster_uuid = "%s" | ||
} | ||
ordered_availability_zone_list{ | ||
availability_zone_url = "%s" | ||
cluster_uuid = "%s" | ||
} | ||
availability_zone_connectivity_list{ | ||
source_availability_zone_index = 0 | ||
destination_availability_zone_index = 1 | ||
snapshot_schedule_list{ | ||
recovery_point_objective_secs = 3600 | ||
snapshot_type= "CRASH_CONSISTENT" | ||
local_snapshot_retention_policy { | ||
num_snapshots = %[5]d | ||
} | ||
} | ||
} | ||
availability_zone_connectivity_list{ | ||
source_availability_zone_index = 1 | ||
destination_availability_zone_index = 0 | ||
snapshot_schedule_list{ | ||
recovery_point_objective_secs = 3600 | ||
snapshot_type= "CRASH_CONSISTENT" | ||
local_snapshot_retention_policy { | ||
num_snapshots = %[5]d | ||
} | ||
} | ||
} | ||
category_filter { | ||
params { | ||
name = local.category | ||
values = [local.keys[(count.index)]] | ||
} | ||
} | ||
} | ||
data "nutanix_protection_rules" "test" { | ||
depends_on = [nutanix_protection_rule.test] | ||
} | ||
`, aZUUIDSource, clusterUUIDSource, aZUUIDTarget, clusterUUIDTarget, snapshots) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,38 +4,48 @@ | |
"user_group_with_distinguished_name": { | ||
"distinguished_name": "cn=sspadmins,cn=users,dc=qa,dc=nucalm,dc=io", | ||
"display_name": "sspadmins", | ||
"uuid": "a4f29c09-2552-4c01-992f-b96061796c98" | ||
"uuid": "6d2f6c7f-9054-46aa-afab-c715fae06f1b" | ||
}, | ||
"permissions": [ | ||
{ | ||
"name": "", | ||
"uuid": "57f9b783-2a85-4684-b543-1976855027d4" | ||
"uuid": "62e795a1-5c40-4ba7-b51d-fced5cbad6d2" | ||
}, | ||
{ | ||
"name": "Delete_ACP", | ||
"uuid": "0696cac3-516b-460e-9bc1-d6a5d1b761d3" | ||
"uuid": "c98d099d-43ee-42ce-b76e-136ee8c65b72" | ||
} | ||
], | ||
"users": [ | ||
{ | ||
"principal_name": "[email protected]", | ||
"expected_display_name": "user4", | ||
"directory_service_uuid": "0791faca-1a48-499e-8171-60801dd41637" | ||
"directory_service_uuid": "0bcc5599-927b-48cb-9e5d-2bd33cfbf709" | ||
}, | ||
{ | ||
"principal_name": "[email protected]", | ||
"expected_display_name": "user6", | ||
"directory_service_uuid": "0791faca-1a48-499e-8171-60801dd41637" | ||
"directory_service_uuid": "0bcc5599-927b-48cb-9e5d-2bd33cfbf709" | ||
}, | ||
{ | ||
"principal_name": "[email protected]", | ||
"expected_display_name": "ssptest3", | ||
"directory_service_uuid": "0791faca-1a48-499e-8171-60801dd41637" | ||
"directory_service_uuid": "0bcc5599-927b-48cb-9e5d-2bd33cfbf709" | ||
} | ||
], | ||
"node_os_version": "ntnx-1.0", | ||
"ad_rule_target": { | ||
"name": "ADGroup", | ||
"values": "sspadmins" | ||
}, | ||
"protection_policy":{ | ||
"local_az":{ | ||
"uuid":"a973cd7b-7696-4ca5-b959-04b5bcb9e683", | ||
"cluster_uuid":"0005ded3-2367-7205-3507-ac1f6b60292f" | ||
}, | ||
"destination_az":{ | ||
"uuid":"97b0cc07-d838-4925-acd7-540c11bd653d", | ||
"cluster_uuid":"0005dc0f-13a7-62e0-185b-ac1f6b6f97e2" | ||
} | ||
} | ||
} |