test: parallel-safety hygiene for future multi-process execution#150
test: parallel-safety hygiene for future multi-process execution#150kuudori wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Excluded labels (none allowed) (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughE2E documentation now defines parallel-safe test requirements and when to use Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/helper/cleanup.go`:
- Around line 78-95: Update CleanupPubSubResources to construct its helper
through a Pub/Sub-specific constructor that does not create Kubernetes or
dynamic clients. Add NewPubSubCleanupHelper alongside NewCleanupHelper,
initializing only cfg and adapterDeploymentList with the same validation, then
use it for SweepPubsubTestAdapterResources so Kubernetes client failures cannot
block Pub/Sub cleanup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: f49c0414-fb75-48f5-9888-4d902a547296
📒 Files selected for processing (20)
docs/development.mde2e/adapter/adapter_failover.goe2e/adapter/adapter_with_maestro.goe2e/adapter/maestro_unavailability.goe2e/cluster/adapter_failure.goe2e/cluster/crash_recovery.goe2e/cluster/delete_edge_cases.goe2e/cluster/force_delete.goe2e/cluster/perf_cascade_delete_latency.goe2e/cluster/perf_create_latency.goe2e/cluster/perf_delete_latency.goe2e/cluster/perf_list_filtered_latency.goe2e/cluster/perf_list_latency.goe2e/cluster/perf_read_entity_size_latency.goe2e/cluster/perf_update_latency.goe2e/cluster/stuck_deletion.goe2e/nodepool/perf_create_latency.goe2e/nodepool/perf_delete_latency.gopkg/e2e/suite.gopkg/helper/cleanup.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
openshift-hyperfleet/architecture(manual)openshift-hyperfleet/hyperfleet-api(manual)openshift-hyperfleet/hyperfleet-sentinel(manual)openshift-hyperfleet/hyperfleet-adapter(manual)openshift-hyperfleet/hyperfleet-broker(manual)
| func CleanupPubSubResources() { | ||
| c, err := NewCleanupHelper() | ||
| if err != nil { | ||
| logger.Error("failed to create cleanup helper for Pub/Sub sweep", "error", err) | ||
| return | ||
| } | ||
|
|
||
| if c.cfg.BrokerType != "googlepubsub" { | ||
| return | ||
| } | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) | ||
| defer cancel() | ||
|
|
||
| if err := c.SweepPubsubTestAdapterResources(ctx); err != nil { | ||
| logger.Error("failed to cleanup Pub/Sub test resources", "error", err) | ||
| } | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Pub/Sub cleanup is blocked by unnecessary K8s client dependency.
CleanupPubSubResources calls NewCleanupHelper(), which creates a K8s client and dynamic client. Neither is used by SweepPubsubTestAdapterResources (lines 138–161 — it only uses c.adapterDeploymentList, c.cfg, and standalone Pub/Sub delete functions). If kubernetes.NewClient() fails at line 43, the function returns early at line 82 and Pub/Sub resources leak. In parallel mode, every process hits this path.
Extract Pub/Sub-only helper construction that skips K8s client creation, or make K8s client creation optional/lazy within NewCleanupHelper.
♻️ Proposed refactor: split helper construction
func CleanupPubSubResources() {
- c, err := NewCleanupHelper()
+ c, err := NewPubSubCleanupHelper()
if err != nil {
logger.Error("failed to create cleanup helper for Pub/Sub sweep", "error", err)
return
}// NewPubSubCleanupHelper creates a helper with only the fields needed for Pub/Sub cleanup,
// avoiding unnecessary K8s client creation.
func NewPubSubCleanupHelper() (*CleanupHelper, error) {
cfg := GetSuiteConfig()
if cfg == nil {
return nil, fmt.Errorf("config must be set for resource cleanup tracking")
}
adapterDeploymentList := GetAdapterDeploymentList()
if adapterDeploymentList == nil {
return nil, fmt.Errorf("adapter deployment list must be set for resource cleanup tracking")
}
return &CleanupHelper{cfg: cfg, adapterDeploymentList: adapterDeploymentList}, nil
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func CleanupPubSubResources() { | |
| c, err := NewCleanupHelper() | |
| if err != nil { | |
| logger.Error("failed to create cleanup helper for Pub/Sub sweep", "error", err) | |
| return | |
| } | |
| if c.cfg.BrokerType != "googlepubsub" { | |
| return | |
| } | |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) | |
| defer cancel() | |
| if err := c.SweepPubsubTestAdapterResources(ctx); err != nil { | |
| logger.Error("failed to cleanup Pub/Sub test resources", "error", err) | |
| } | |
| } | |
| func CleanupPubSubResources() { | |
| c, err := NewPubSubCleanupHelper() | |
| if err != nil { | |
| logger.Error("failed to create cleanup helper for Pub/Sub sweep", "error", err) | |
| return | |
| } | |
| if c.cfg.BrokerType != "googlepubsub" { | |
| return | |
| } | |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) | |
| defer cancel() | |
| if err := c.SweepPubsubTestAdapterResources(ctx); err != nil { | |
| logger.Error("failed to cleanup Pub/Sub test resources", "error", err) | |
| } | |
| } | |
| // NewPubSubCleanupHelper creates a helper with only the fields needed for Pub/Sub cleanup, | |
| // avoiding unnecessary K8s client creation. | |
| func NewPubSubCleanupHelper() (*CleanupHelper, error) { | |
| cfg := GetSuiteConfig() | |
| if cfg == nil { | |
| return nil, fmt.Errorf("config must be set for resource cleanup tracking") | |
| } | |
| adapterDeploymentList := GetAdapterDeploymentList() | |
| if adapterDeploymentList == nil { | |
| return nil, fmt.Errorf("adapter deployment list must be set for resource cleanup tracking") | |
| } | |
| return &CleanupHelper{cfg: cfg, adapterDeploymentList: adapterDeploymentList}, nil | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/helper/cleanup.go` around lines 78 - 95, Update CleanupPubSubResources to
construct its helper through a Pub/Sub-specific constructor that does not create
Kubernetes or dynamic clients. Add NewPubSubCleanupHelper alongside
NewCleanupHelper, initializing only cfg and adapterDeploymentList with the same
validation, then use it for SweepPubsubTestAdapterResources so Kubernetes client
failures cannot block Pub/Sub cleanup.
733fb70 to
008183f
Compare
- Add ginkgo CLI binary (v2.27.2) via .bingo tooling - Add e2e_suite_test.go entry point for ginkgo --procs=N - Add e2e-ginkgo Makefile target with PROCS= support - Build ginkgo CLI and e2e.test binary in Dockerfile - Add ginkgo.Serial to 5 infrastructure-modifying tests - Convert nodepool creation to Ordered+BeforeAll for isolation - Split AfterSuite into SynchronizedAfterSuite for multi-process safety - Split CleanupResources into per-process and process-1-only phases - Add parallel safety documentation
008183f to
49a425e
Compare
Phase 0 preparation for Ginkgo parallel E2E execution (--procs=N). All changes are inert at 1 process - no behavioral change.
Suite hooks:
Serial labels added to specs that are unsafe under concurrency:
Documentation:
Summary
Test Plan
make test-allpassesmake lintpassesmake test-helm(if applicable)