Skip to content

fix(test): use unique names in tests to prevent flakiness#697

Merged
tembleking merged 2 commits intomasterfrom
fix/managed-ruleset-flaky-test
Feb 6, 2026
Merged

fix(test): use unique names in tests to prevent flakiness#697
tembleking merged 2 commits intomasterfrom
fix/managed-ruleset-flaky-test

Conversation

@tembleking
Copy link
Copy Markdown
Member

@tembleking tembleking commented Feb 6, 2026

Summary

  • Use random suffixes to generate unique names in tests that create resources with unique name constraints
  • Prevents name collisions when tests run in parallel or when previous test runs don't clean up properly

Fixed tests:

  • resource_sysdig_secure_managed_ruleset_test.go: Use randomText(10) for managed ruleset names
  • data_source_sysdig_secure_custom_policy_test.go: Add missing fmt.Sprintf call to properly interpolate random suffix

Root cause

Tests were using hardcoded names or format placeholders without fmt.Sprintf, causing:

  • "The field 'name' must be unique per policy type" errors
  • Test failures in CI when running in parallel

Fixes: https://github.com/sysdiglabs/terraform-provider-sysdig/actions/runs/21728344935/job/62676378457

The test was using a hardcoded name "Sysdig Runtime Threat Detection (Copy)"
which caused name collisions when tests ran in parallel or when previous
test runs didn't clean up properly.

Generate a random suffix once and use it consistently across all test steps.
@tembleking tembleking requested a review from a team as a code owner February 6, 2026 08:28
Copilot AI review requested due to automatic review settings February 6, 2026 08:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a flaky test in the managed ruleset acceptance test by ensuring unique resource names across parallel test executions and avoiding collisions from incomplete cleanup of previous test runs.

Changes:

  • Generate a single random suffix once at test start instead of calling rText() multiple times
  • Update all config helper functions to accept and use the random suffix parameter
  • Replace hardcoded "Sysdig Runtime Threat Detection (Copy)" names with unique suffixed names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tembleking tembleking enabled auto-merge February 6, 2026 08:29
The test was using format placeholders %s but never calling fmt.Sprintf,
causing the literal "%s" to be used as the policy name. This led to
name collisions when tests ran in parallel.

Add fmt.Sprintf to properly interpolate the random suffix.
@tembleking tembleking changed the title fix(test): use unique names in managed ruleset test to prevent flakiness fix(test): use unique names in tests to prevent flakiness Feb 6, 2026
@tembleking tembleking added this pull request to the merge queue Feb 6, 2026
Merged via the queue into master with commit 1852848 Feb 6, 2026
171 checks passed
@tembleking tembleking deleted the fix/managed-ruleset-flaky-test branch February 6, 2026 10:03
fcracker79 pushed a commit that referenced this pull request Mar 5, 2026
## Summary

- Use random suffixes to generate unique names in tests that create
resources with unique name constraints
- Prevents name collisions when tests run in parallel or when previous
test runs don't clean up properly

### Fixed tests:
- `resource_sysdig_secure_managed_ruleset_test.go`: Use `randomText(10)`
for managed ruleset names
- `data_source_sysdig_secure_custom_policy_test.go`: Add missing
`fmt.Sprintf` call to properly interpolate random suffix

### Root cause
Tests were using hardcoded names or format placeholders without
`fmt.Sprintf`, causing:
- `"The field 'name' must be unique per policy type"` errors
- Test failures in CI when running in parallel

Fixes:
https://github.com/sysdiglabs/terraform-provider-sysdig/actions/runs/21728344935/job/62676378457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants