Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0231e7b
Refactor the noFailures case
hongkailiu Aug 1, 2025
bd0e775
upgrade status CLI monitortest: use slice instead of map
petr-muller Aug 13, 2025
87f9fc9
upgrade status CLI monitortest: snapshot --details=all
petr-muller Aug 13, 2025
88790b1
Add a simple "page object"-like parser for `oc adm upgrade status` ou…
petr-muller Aug 13, 2025
72fc112
upgrade status CLI monitortest: parse all outputs into models
petr-muller Aug 13, 2025
2b11ffb
upgrade status CLI monitortest: control plane section test
petr-muller Aug 13, 2025
cc074d6
upgrade status CLI monitortest: worker section test
petr-muller Aug 13, 2025
0e82fae
upgrade status CLI monitortest: health section test
petr-muller Aug 13, 2025
41649ba
upgrade status CLI monitortest: save initial ClusterVersion
petr-muller Aug 13, 2025
461503c
upgrade status CLI monitortest: add update lifecycle check
petr-muller Aug 13, 2025
218f6f4
upgrade status CLI monitortest: test parsing outputs with no alerts w…
petr-muller Aug 13, 2025
af44db0
upgrade status CLI monitortest: test `noFailures` check
petr-muller Aug 13, 2025
f496379
upgrade status CLI monitortest: fix `noFailures` check
petr-muller Aug 13, 2025
221e31b
upgrade status CLI monitortest: test `expectedLayout` check
petr-muller Aug 13, 2025
fe67027
upgrade status CLI monitortest: test `controlPlane` check
petr-muller Aug 13, 2025
36d4917
upgrade status CLI monitortest: fixes in `controlPlane` check
petr-muller Aug 13, 2025
cc663f6
upgrade status CLI monitortest: fix naming conflicts
petr-muller Aug 13, 2025
1c080bc
upgrade status CLI monitortest: test `workers` check
petr-muller Aug 13, 2025
53dc37a
upgrade status CLI monitortest: fix `workers` check
petr-muller Aug 13, 2025
a26c815
upgrade status CLI monitortest: test `health` check
petr-muller Aug 13, 2025
4e2c9a4
upgrade status CLI monitortest: fix `health` check
petr-muller Aug 13, 2025
9bd4080
upgrade status CLI monitortest: make `updateLifecycle` better testable
petr-muller Aug 13, 2025
4b4ff4d
upgrade status CLI monitortest: test `updateLifecycle` check
petr-muller Aug 13, 2025
a20d7f1
upgrade status CLI monitortest: fix `updateLifecycle` check
petr-muller Aug 13, 2025
3f71eec
upgrade status CLI monitortest: relax `controlPlane` check
petr-muller Aug 13, 2025
76fcc37
upgrade status CLI monitortest: fix `controlPlane` check
petr-muller Aug 13, 2025
5db0df8
upgrade status CLI monitortest: relax `updateLifecycle` check
petr-muller Aug 13, 2025
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
133 changes: 133 additions & 0 deletions pkg/monitortests/cli/adm_upgrade/status/controlplane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package admupgradestatus

import (
"fmt"
"regexp"
"strings"
"time"

"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
)

var (
operatorLinePattern = regexp.MustCompile(`^\S+\s+\S+\s+\S+\s+.*$`)
)

func (w *monitor) controlPlane() *junitapi.JUnitTestCase {
controlPlane := &junitapi.JUnitTestCase{
Name: "[sig-cli][OCPFeatureGate:UpgradeStatus] oc adm upgrade status control plane section is consistent",
SkipMessage: &junitapi.SkipMessage{
Message: "Test skipped because no oc adm upgrade status output was successfully collected",
},
}

failureOutputBuilder := strings.Builder{}

for _, observed := range w.ocAdmUpgradeStatusOutputModels {
if observed.output == nil {
// Failing to parse the output is handled in expectedLayout, so we can skip here
continue
}
// We saw at least one successful execution of oc adm upgrade status, so we have data to process
controlPlane.SkipMessage = nil

wroteOnce := false
fail := func(message string) {
if !wroteOnce {
wroteOnce = true
failureOutputBuilder.WriteString(fmt.Sprintf("\n===== %s\n", observed.when.Format(time.RFC3339)))
failureOutputBuilder.WriteString(observed.output.rawOutput)
failureOutputBuilder.WriteString(fmt.Sprintf("\n\n=> %s\n", message))
}
}

if !observed.output.updating {
// If the cluster is not updating, control plane should not be updating
if observed.output.controlPlane != nil {
fail("Cluster is not updating but control plane section is present")
}
continue
}

cp := observed.output.controlPlane
if cp == nil {
fail("Cluster is updating but control plane section is not present")
continue
}

if cp.Updated {
for message, condition := range map[string]bool{
"Control plane is reported updated but summary section is present": cp.Summary != nil,
"Control plane is reported updated but operators section is present": cp.Operators != nil,
"Control plane is reported updated but nodes section is present": cp.Nodes != nil,
"Control plane is reported updated but nodes are not updated": !cp.NodesUpdated,
} {
if condition {
fail(message)
}
}
continue
}

if cp.Summary == nil {
fail("Control plane is not updated but summary section is not present")
}

for _, key := range []string{"Assessment", "Target Version", "Completion", "Duration", "Operator Health"} {
value, ok := cp.Summary[key]
if !ok {
fail(fmt.Sprintf("Control plane summary does not contain %s", key))
} else if value == "" {
fail(fmt.Sprintf("%s is empty", key))
}
}

updatingOperators, ok := cp.Summary["Updating"]
if !ok {
if cp.Operators != nil {
fail("Control plane summary does not contain Updating key but operators section is present")
continue
}
} else {
if updatingOperators == "" {
fail("Control plane summary contains Updating key but it is empty")
continue
}

if cp.Operators == nil {
fail("Control plane summary contains Updating key but operators section is not present")
continue
}

items := len(strings.Split(updatingOperators, ","))
// TODO: These should actually exactly match, but `oc adm upgrade status` emits operators with linebreaks in
// messages in a crappy way which we will need to fix
if len(cp.Operators) < items {
fail(fmt.Sprintf("Control plane summary contains Updating key with %d operators but operators section has %d items", items, len(cp.Operators)))
continue
}
}

// TODO: `oc adm upgrade status` emits operators with linebreaks in messages in a crappy way which we will need to fix
// for _, operator := range cp.Operators {
// if !operatorLinePattern.MatchString(operator) {
// fail(fmt.Sprintf("Bad line in operators: %s", operator))
// }
// }

for _, node := range cp.Nodes {
if !nodeLinePattern.MatchString(node) {
fail(fmt.Sprintf("Bad line in nodes: %s", node))
}
}
}

if failureOutputBuilder.Len() > 0 {
controlPlane.FailureOutput = &junitapi.FailureOutput{
Message: fmt.Sprintf("observed unexpected outputs in oc adm upgrade status control plane section"),
Output: failureOutputBuilder.String(),
}
}

return controlPlane
}
Loading