Skip to content

Commit b19e263

Browse files
Merge pull request #29534 from neisw/infra-termination-policy
NO-JIRA: Support known namespaces for terminationMessagePolicy tests
2 parents c132eba + 200b60d commit b19e263

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/monitortestlibrary/platformidentification/operator_mapping.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func init() {
231231
utilruntime.Must(addNamespaceMapping("openshift-service-ca-operator", "service-ca"))
232232
utilruntime.Must(addNamespaceMapping("openshift-user-workload-monitoring", "Unknown"))
233233
utilruntime.Must(addNamespaceMapping("openshift-vsphere-infra", "Unknown"))
234+
utilruntime.Must(addNamespaceMapping("openshift-infra", "Unknown"))
234235

235236
KnownNamespaces = sets.StringKeySet(namespaceToBugzillaComponent)
236237
}

pkg/monitortests/clusterversionoperator/terminationmessagepolicy/monitortest.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
configclient "github.com/openshift/client-go/config/clientset/versioned"
1010
"github.com/openshift/origin/pkg/monitor/monitorapi"
1111
"github.com/openshift/origin/pkg/monitortestframework"
12+
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
1213
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
1314
corev1 "k8s.io/api/core/v1"
1415
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -89,6 +90,7 @@ func (w *terminationMessagePolicyChecker) CollectData(ctx context.Context, stora
8990
if strings.HasPrefix(pod.Namespace, "openshift-must-gather") {
9091
continue
9192
}
93+
9294
if _, ok := failuresByNamespace[pod.Namespace]; !ok {
9395
failuresByNamespace[pod.Namespace] = []string{}
9496
}
@@ -131,8 +133,10 @@ func (w *terminationMessagePolicyChecker) CollectData(ctx context.Context, stora
131133
),
132134
}
133135

136+
observedNamespace := map[string]bool{}
134137
junits := []*junitapi.JUnitTestCase{}
135138
for _, namespace := range sets.StringKeySet(failuresByNamespace).List() {
139+
observedNamespace[namespace] = true
136140
testName := fmt.Sprintf("[sig-arch] all containers in ns/%v must have terminationMessagePolicy=%v", namespace, corev1.TerminationMessageFallbackToLogsOnError)
137141
failingContainers := sets.NewString(failuresByNamespace[namespace]...)
138142
if len(failingContainers) == 0 {
@@ -207,6 +211,19 @@ func (w *terminationMessagePolicyChecker) CollectData(ctx context.Context, stora
207211

208212
}
209213

214+
knownNamespaces := platformidentification.KnownNamespaces
215+
for _, namespace := range sets.StringKeySet(knownNamespaces).List() {
216+
// if we didn't observe this namespace then create the passing test to ensure the test is always created
217+
if _, ok := observedNamespace[namespace]; !ok {
218+
testName := fmt.Sprintf("[sig-arch] all containers in ns/%v must have terminationMessagePolicy=%v", namespace, corev1.TerminationMessageFallbackToLogsOnError)
219+
junits = append(junits, &junitapi.JUnitTestCase{
220+
Name: testName,
221+
SystemOut: "",
222+
SystemErr: "",
223+
})
224+
}
225+
}
226+
210227
return nil, junits, nil
211228
}
212229

0 commit comments

Comments
 (0)