Skip to content

Commit 4e2c9a4

Browse files
committed
upgrade status CLI monitortest: fix health check
1 parent a26c815 commit 4e2c9a4

File tree

1 file changed

+12
-13
lines changed
  • pkg/monitortests/cli/adm_upgrade/status

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import (
1212
var (
1313
healthLinePattern = regexp.MustCompile(`^\S+\s+\S+\S+\s+\S+.*$`)
1414
healthMessageFields = map[string]*regexp.Regexp{
15-
"Message": regexp.MustCompile(`^Message:\s+\S+.*$`),
16-
"Since": regexp.MustCompile(`^ {2}Since:\s+\S+.*$`),
17-
"Level": regexp.MustCompile(`^ {2}Level:\s+\S+.*$`),
18-
"Impact": regexp.MustCompile(`^ {2}Impact:\s+\S+.*$`),
19-
"Reference": regexp.MustCompile(`^ {2}Reference:\s+\S+.*$`),
20-
"Resources": regexp.MustCompile(`^ {2}Resources:$`),
21-
"resource reference": regexp.MustCompile(`^ {4}[a-z0-9_.-]+: \S+$`),
22-
"Description": regexp.MustCompile(`^ {2}Description:\s+\S+.*$`),
15+
"Message": regexp.MustCompile(`(?m)^Message: +\S+.*$`),
16+
"Since": regexp.MustCompile(`(?m)^ {2}Since: +\S+.*$`),
17+
"Level": regexp.MustCompile(`(?m)^ {2}Level: +\S+.*$`),
18+
"Impact": regexp.MustCompile(`(?m)^ {2}Impact: +\S+.*$`),
19+
"Reference": regexp.MustCompile(`(?m)^ {2}Reference: +\S+.*$`),
20+
"Resources": regexp.MustCompile(`(?m)^ {2}Resources:$`),
21+
"resource reference": regexp.MustCompile(`(?m)^ {4}[a-z0-9_.-]+: +\S+$`),
22+
"Description": regexp.MustCompile(`(?m)^ {2}Description: +\S+.*$`),
2323
}
2424
)
2525

@@ -47,12 +47,11 @@ func (w *monitor) health() *junitapi.JUnitTestCase {
4747
wroteOnce = true
4848
failureOutputBuilder.WriteString(fmt.Sprintf("\n===== %s\n", observed.when.Format(time.RFC3339)))
4949
failureOutputBuilder.WriteString(observed.output.rawOutput)
50-
failureOutputBuilder.WriteString(fmt.Sprintf("=> %s\n", message))
50+
failureOutputBuilder.WriteString(fmt.Sprintf("\n\n=> %s\n", message))
5151
}
5252
}
5353

5454
if !observed.output.updating {
55-
// If the cluster is not updating, workers should not be updating
5655
if observed.output.health != nil {
5756
fail("Cluster is not updating but health section is present")
5857
}
@@ -68,13 +67,13 @@ func (w *monitor) health() *junitapi.JUnitTestCase {
6867
for _, item := range h.Messages {
6968
if h.Detailed {
7069
for field, pattern := range healthMessageFields {
71-
if !pattern.MatchString(item) {
72-
fail(fmt.Sprintf("Health message does not contain field %s: %s", field, item))
70+
if pattern.FindString(item) == "" {
71+
fail(fmt.Sprintf("Health message does not contain field %s", field))
7372
}
7473
}
7574
} else {
7675
if !healthLinePattern.MatchString(item) {
77-
fail(fmt.Sprintf("Health message does not match expected pattern: %s", item))
76+
fail(fmt.Sprintf("Health message does not match expected pattern:\n%s", item))
7877
}
7978
}
8079
}

0 commit comments

Comments
 (0)