Skip to content

Commit 9bd4080

Browse files
committed
upgrade status CLI monitortest: make updateLifecycle better testable
1 parent 4e2c9a4 commit 9bd4080

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pkg/monitortests/cli/adm_upgrade/status/monitortest.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,21 @@ func (w *monitor) CollectData(ctx context.Context, storageDir string, beginning,
162162

163163
// TODO: Maybe utilize Intervals somehow and do tests in ComputeComputedIntervals and EvaluateTestsFromConstructedIntervals
164164

165+
wasUpdated := func() (bool, error) {
166+
cv, err := w.configv1client.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
167+
if err != nil {
168+
return false, fmt.Errorf("failed to get cluster version: %w", err)
169+
}
170+
return len(cv.Status.History) > len(w.initialClusterVersion.Status.History), nil
171+
}
172+
165173
return nil, []*junitapi.JUnitTestCase{
166174
w.noFailures(),
167175
w.expectedLayout(),
168176
w.controlPlane(),
169177
w.workers(),
170178
w.health(),
171-
w.updateLifecycle(ctx),
179+
w.updateLifecycle(wasUpdated),
172180
}, nil
173181
}
174182

pkg/monitortests/cli/adm_upgrade/status/updatelifecycle.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package admupgradestatus
22

33
import (
4-
"context"
54
"fmt"
65
"strings"
76
"time"
87

98
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
10-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
119
)
1210

13-
func (w *monitor) updateLifecycle(ctx context.Context) *junitapi.JUnitTestCase {
11+
type wasUpdatedFn func() (bool, error)
12+
13+
func (w *monitor) updateLifecycle(wasUpdated wasUpdatedFn) *junitapi.JUnitTestCase {
1414
health := &junitapi.JUnitTestCase{
1515
Name: "[sig-cli][OCPFeatureGate:UpgradeStatus] oc adm upgrade status snapshots reflect the cluster upgrade lifecycle",
1616
}
1717

18-
cv, err := w.configv1client.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
18+
clusterUpdated, err := wasUpdated()
1919
if err != nil {
2020
health.FailureOutput = &junitapi.FailureOutput{
2121
Message: fmt.Sprintf("failed to get cluster version: %v", err),
@@ -71,7 +71,6 @@ func (w *monitor) updateLifecycle(ctx context.Context) *junitapi.JUnitTestCase {
7171
},
7272
}
7373

74-
clusterUpdated := len(cv.Status.History) > len(w.initialClusterVersion.Status.History)
7574
current := beforeUpdate
7675
failureOutputBuilder := strings.Builder{}
7776

0 commit comments

Comments
 (0)