Skip to content

Commit d3ff09d

Browse files
stbenjamclaude
andcommitted
test/e2e/upgrade: ensure ClusterOperators test always produces a result
The ClusterOperators test was defined as a deferred function inside the clusterUpgrade function, which meant it would not run if the parent test "Cluster should remain functional during upgrade" failed before calling clusterUpgrade (e.g., during config loading or upgrade context setup). Move the deferred test to the parent test scope so it always runs and produces a result, even when earlier tests fail. Also remove the duplicate non-deferred version that only ran on success. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 523d558 commit d3ff09d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/e2e/upgrade/upgrade.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@ var _ = g.Describe("[sig-arch][Feature:ClusterUpgrade]", func() {
177177
upgCtx, err := getUpgradeContext(client, upgradeToImage)
178178
framework.ExpectNoError(err, "determining what to upgrade to version=%s image=%s", "", upgradeToImage)
179179

180+
// Ensure ClusterOperators test always runs, even if earlier tests fail
181+
defer func() {
182+
_ = disruption.RecordJUnit(
183+
f,
184+
"[sig-cluster-lifecycle] ClusterOperators are available and not degraded after upgrade",
185+
func() (error, bool) {
186+
if err := operator.WaitForOperatorsToSettle(context.TODO(), client, 5); err != nil {
187+
return err, false
188+
}
189+
return nil, false
190+
},
191+
)
192+
}()
193+
180194
disruption.Run(f, "Cluster upgrade", "upgrade",
181195
disruption.TestData{
182196
UpgradeType: upgrades.ClusterUpgrade,
@@ -690,20 +704,6 @@ func clusterUpgrade(f *framework.Framework, c configv1client.Interface, dc dynam
690704
return errMasterUpdating
691705
}
692706

693-
if err := disruption.RecordJUnit(
694-
f,
695-
"[sig-cluster-lifecycle] ClusterOperators are available and not degraded after upgrade",
696-
func() (error, bool) {
697-
if err := operator.WaitForOperatorsToSettle(context.TODO(), c, 5); err != nil {
698-
return err, false
699-
}
700-
return nil, false
701-
},
702-
); err != nil {
703-
recordClusterEvent(kubeClient, uid, "Upgrade", monitorapi.UpgradeFailedReason, fmt.Sprintf("failed to settle operators: %v", err), true)
704-
return err
705-
}
706-
707707
recordClusterEvent(kubeClient, uid, "Upgrade", monitorapi.UpgradeCompleteReason, fmt.Sprintf("version/%s image/%s", updated.Status.Desired.Version, updated.Status.Desired.Image), false)
708708
return nil
709709
}

0 commit comments

Comments
 (0)