Skip to content

Commit e2a4755

Browse files
petr-mullerhongkailiu
authored andcommitted
OTA-1580: Simple "never fails" test
1 parent 1bd2e97 commit e2a4755

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"strings"
89
"time"
910

1011
"github.com/openshift/origin/pkg/monitortestframework"
@@ -43,6 +44,7 @@ func snapshotOcAdmUpgradeStatus(ch chan *snapshot) {
4344
// how to do pass that to exutil.NewCLI* or if it is even possible. It seems to work this way though.
4445
oc := exutil.NewCLIWithoutNamespace("adm-upgrade-status").AsAdmin()
4546
now := time.Now()
47+
// TODO: Consider retrying on brief apiserver unavailability
4648
cmd := oc.Run("adm", "upgrade", "status").EnvVar("OC_ENABLE_CMD_UPGRADE_STATUS", "true")
4749
out, err := cmd.Output()
4850
ch <- &snapshot{when: now, out: out, err: err}
@@ -77,7 +79,29 @@ func (w *monitor) CollectData(ctx context.Context, storageDir string, beginning,
7779
// The framework cancels the context it gave StartCollection before it calls CollectData, but we need to wait for
7880
// the collection goroutines spawned in StartedCollection to finish
7981
<-w.collectionDone
80-
return nil, nil, nil
82+
83+
noFailures := &junitapi.JUnitTestCase{
84+
Name: "[sig-cli][OCPFeatureGate:UpgradeStatus] oc amd upgrade status never fails",
85+
}
86+
87+
var failures []string
88+
for when, observed := range w.ocAdmUpgradeStatus {
89+
if observed.err != nil {
90+
failures = append(failures, fmt.Sprintf("- %s: %v", when.Format(time.RFC3339), observed.err))
91+
}
92+
}
93+
94+
// TODO: Zero failures is too strict for at least SNO clusters
95+
if len(failures) > 0 {
96+
noFailures.FailureOutput = &junitapi.FailureOutput{
97+
Message: fmt.Sprintf("oc adm upgrade status failed %d times (of %d)", len(failures), len(w.ocAdmUpgradeStatus)),
98+
Output: strings.Join(failures, "\n"),
99+
}
100+
}
101+
102+
// TODO: Maybe utilize Intervals somehow and do tests in ComputeComputedIntervals and EvaluateTestsFromConstructedIntervals
103+
104+
return nil, []*junitapi.JUnitTestCase{noFailures}, nil
81105
}
82106

83107
func (*monitor) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {

0 commit comments

Comments
 (0)