Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/cvo/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator r
})

g.It("should report PDB count matching actual PodDisruptionBudgets", func() {
// Ground truth: list PDBs across all namespaces
// Run the readiness check first to capture cluster state at a specific point in time
output := readiness.RunAll(ctx, dynamicClient, currentVersion, targetVersion)
result := output.Checks["pdb_drain"]
o.Expect(result.Status).To(o.Equal("ok"))

// Immediately list PDBs to minimize timing drift between the check and verification.
// PDBs can be created or deleted by controllers during test execution, so we list
// after the check to reduce the window for discrepancies caused by cluster state changes.
pdbList, err := kubeClient.PolicyV1().PodDisruptionBudgets("").List(ctx, metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

Expand All @@ -197,10 +204,6 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator r
}
}

// Our check
output := readiness.RunAll(ctx, dynamicClient, currentVersion, targetVersion)
result := output.Checks["pdb_drain"]
o.Expect(result.Status).To(o.Equal("ok"))
o.Expect(result.Data["total_pdbs"]).To(o.Equal(expectedTotal),
"PDB count should match actual PDBs in cluster")

Expand Down