Skip to content

Commit a1be868

Browse files
temblekingfcracker79
authored andcommitted
fix(ci): use owned resource in posture zone test to prevent flakiness (#703)
`TestAccSecurePostureZone` fails intermittently in CI (IBM Secure Acceptance Tests) at Step 3/4 with "plan was not empty" on `policy_ids`. The test used `data.sysdig_secure_posture_policies.all.policies[0].id` to get a policy ID, but the data source returns policies in non-deterministic order from the API. Between apply and refresh, the data source is re-read and `policies[0]` can resolve to a different policy, causing drift. This replaces the data source lookup with a test-owned `sysdig_secure_posture_policy` resource so the ID is stable across reads.
1 parent e28d86b commit a1be868

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

sysdig/resource_sysdig_secure_posture_zone_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ resource "sysdig_secure_posture_zone" "z1" {
6666

6767
func securePostureZoneWithPolicies(name string) string {
6868
return fmt.Sprintf(`
69-
data "sysdig_secure_posture_policies" "all" {}
69+
resource "sysdig_secure_posture_policy" "test" {
70+
name = "%s-policy"
71+
description = "test policy for posture zone"
72+
is_active = true
73+
type = "Unknown"
74+
}
7075
7176
resource "sysdig_secure_posture_zone" "z1" {
72-
name = "%s"
73-
policy_ids = [data.sysdig_secure_posture_policies.all.policies[0].id]
74-
}`, name)
77+
name = "%s"
78+
policy_ids = [sysdig_secure_posture_policy.test.id]
79+
}`, name, name)
7580
}

0 commit comments

Comments
 (0)