Skip to content

Commit 36749ad

Browse files
committed
Use NotSupported for other skips in monitor tests
1 parent 8bda8be commit 36749ad

File tree

5 files changed

+106
-86
lines changed

5 files changed

+106
-86
lines changed

pkg/monitortests/kubeapiserver/disruptionlegacyapiservers/monitortest.go

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ import (
88

99
"github.com/openshift/origin/pkg/monitortestframework"
1010

11-
"github.com/openshift/origin/pkg/monitor/monitorapi"
12-
"github.com/openshift/origin/pkg/monitortestlibrary/disruptionlibrary"
13-
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
1411
apierrors "k8s.io/apimachinery/pkg/api/errors"
1512
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1613
utilerrors "k8s.io/apimachinery/pkg/util/errors"
1714
"k8s.io/client-go/kubernetes"
1815
"k8s.io/client-go/rest"
16+
17+
"github.com/openshift/origin/pkg/monitor/monitorapi"
18+
"github.com/openshift/origin/pkg/monitortestlibrary/disruptionlibrary"
19+
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
1920
)
2021

2122
type availability struct {
2223
disruptionCheckers []*disruptionlibrary.Availability
2324

24-
notSupportedReason string
25+
notSupportedReason *monitortestframework.NotSupportedError
2526
suppressJunit bool
2627
}
2728

@@ -157,16 +158,20 @@ func (w *availability) StartCollection(ctx context.Context, adminRESTConfig *res
157158

158159
_, err = kubeClient.CoreV1().Namespaces().Get(context.Background(), "openshift-apiserver", metav1.GetOptions{})
159160
if apierrors.IsNotFound(err) {
160-
w.notSupportedReason = "namespace openshift-apiserver not present"
161-
return nil
161+
w.notSupportedReason = &monitortestframework.NotSupportedError{
162+
Reason: "namespace openshift-apiserver not present",
163+
}
164+
return w.notSupportedReason
162165
}
163166
if err != nil {
164167
return err
165168
}
166169
_, err = kubeClient.CoreV1().Namespaces().Get(context.Background(), "openshift-oauth-apiserver", metav1.GetOptions{})
167170
if apierrors.IsNotFound(err) {
168-
w.notSupportedReason = "namespace openshift-oauth-apiserver not present"
169-
return nil
171+
w.notSupportedReason = &monitortestframework.NotSupportedError{
172+
Reason: "namespace openshift-oauth-apiserver not present",
173+
}
174+
return w.notSupportedReason
170175
}
171176
if err != nil {
172177
return err
@@ -217,6 +222,10 @@ func (w *availability) StartCollection(ctx context.Context, adminRESTConfig *res
217222
}
218223

219224
func (w *availability) CollectData(ctx context.Context, storageDir string, beginning, end time.Time) (monitorapi.Intervals, []*junitapi.JUnitTestCase, error) {
225+
if w.notSupportedReason != nil {
226+
return nil, nil, w.notSupportedReason
227+
}
228+
220229
intervals := monitorapi.Intervals{}
221230
junits := []*junitapi.JUnitTestCase{}
222231
errs := []error{}
@@ -238,11 +247,15 @@ func (w *availability) CollectData(ctx context.Context, storageDir string, begin
238247
return intervals, junits, utilerrors.NewAggregate(errs)
239248
}
240249

241-
func (*availability) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
242-
return nil, nil
250+
func (w *availability) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
251+
return nil, w.notSupportedReason
243252
}
244253

245254
func (w *availability) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
255+
if w.notSupportedReason != nil {
256+
return nil, w.notSupportedReason
257+
}
258+
246259
if w.suppressJunit {
247260
return nil, nil
248261
}
@@ -266,10 +279,10 @@ func (w *availability) EvaluateTestsFromConstructedIntervals(ctx context.Context
266279
return junits, utilerrors.NewAggregate(errs)
267280
}
268281

269-
func (*availability) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
270-
return nil
282+
func (w *availability) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
283+
return w.notSupportedReason
271284
}
272285

273286
func (w *availability) Cleanup(ctx context.Context) error {
274-
return nil
287+
return w.notSupportedReason
275288
}

pkg/monitortests/kubeapiserver/disruptionnewapiserver/monitortest.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import (
77

88
"github.com/openshift/origin/pkg/monitortestframework"
99

10+
"k8s.io/client-go/kubernetes"
11+
"k8s.io/client-go/rest"
12+
1013
"github.com/openshift/origin/pkg/disruption/backend/sampler"
1114
"github.com/openshift/origin/pkg/monitor/apiserveravailability"
1215
"github.com/openshift/origin/pkg/monitor/monitorapi"
1316
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
1417
exutil "github.com/openshift/origin/test/extended/util"
15-
"k8s.io/client-go/kubernetes"
16-
"k8s.io/client-go/rest"
1718
)
1819

1920
type newAPIServerDisruptionChecker struct {
2021
adminRESTConfig *rest.Config
21-
notSupportedReason string
22+
notSupportedReason *monitortestframework.NotSupportedError
2223
}
2324

2425
func NewDisruptionInvariant() monitortestframework.MonitorTest {
@@ -37,15 +38,18 @@ func (w *newAPIServerDisruptionChecker) StartCollection(ctx context.Context, adm
3738
return fmt.Errorf("unable to determine if cluster is MicroShift: %v", err)
3839
}
3940
if isMicroShift {
40-
w.notSupportedReason = "platform MicroShift not supported"
41+
w.notSupportedReason = &monitortestframework.NotSupportedError{
42+
Reason: "platform MicroShift not supported",
43+
}
4144
}
42-
return nil
45+
return w.notSupportedReason
4346
}
4447

4548
func (w *newAPIServerDisruptionChecker) CollectData(ctx context.Context, storageDir string, beginning, end time.Time) (monitorapi.Intervals, []*junitapi.JUnitTestCase, error) {
46-
if len(w.notSupportedReason) > 0 {
47-
return nil, nil, nil
49+
if w.notSupportedReason != nil {
50+
return nil, nil, w.notSupportedReason
4851
}
52+
4953
kubeClient, err := kubernetes.NewForConfig(w.adminRESTConfig)
5054
if err != nil {
5155
return nil, nil, err
@@ -55,21 +59,21 @@ func (w *newAPIServerDisruptionChecker) CollectData(ctx context.Context, storage
5559
return apiserverAvailabilityIntervals, nil, err
5660
}
5761

58-
func (*newAPIServerDisruptionChecker) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
59-
return nil, nil
62+
func (w *newAPIServerDisruptionChecker) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
63+
return nil, w.notSupportedReason
6064
}
6165

62-
func (*newAPIServerDisruptionChecker) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
63-
return nil, nil
66+
func (w *newAPIServerDisruptionChecker) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
67+
return nil, w.notSupportedReason
6468
}
6569

6670
func (w *newAPIServerDisruptionChecker) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
67-
return nil
71+
return w.notSupportedReason
6872
}
6973

7074
func (w *newAPIServerDisruptionChecker) Cleanup(ctx context.Context) error {
71-
if len(w.notSupportedReason) > 0 {
72-
return nil
75+
if w.notSupportedReason != nil {
76+
return w.notSupportedReason
7377
}
7478

7579
if err := sampler.TearDownInClusterMonitors(w.adminRESTConfig); err != nil {

pkg/monitortests/network/disruptionpodnetwork/monitortest.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ import (
1313

1414
configclient "github.com/openshift/client-go/config/clientset/versioned"
1515
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
16-
"github.com/openshift/origin/pkg/monitor/monitorapi"
17-
monitorserialization "github.com/openshift/origin/pkg/monitor/serialization"
18-
"github.com/openshift/origin/pkg/monitortestframework"
19-
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
20-
"github.com/openshift/origin/test/extended/util/image"
2116
appsv1 "k8s.io/api/apps/v1"
2217
corev1 "k8s.io/api/core/v1"
2318
rbacv1 "k8s.io/api/rbac/v1"
@@ -31,6 +26,12 @@ import (
3126
"k8s.io/client-go/rest"
3227
"k8s.io/klog/v2"
3328
k8simage "k8s.io/kubernetes/test/utils/image"
29+
30+
"github.com/openshift/origin/pkg/monitor/monitorapi"
31+
monitorserialization "github.com/openshift/origin/pkg/monitor/serialization"
32+
"github.com/openshift/origin/pkg/monitortestframework"
33+
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
34+
"github.com/openshift/origin/test/extended/util/image"
3435
)
3536

3637
var (
@@ -77,7 +78,7 @@ func init() {
7778

7879
type podNetworkAvalibility struct {
7980
payloadImagePullSpec string
80-
notSupportedReason string
81+
notSupportedReason *monitortestframework.NotSupportedError
8182
namespaceName string
8283
targetService *corev1.Service
8384
kubeClient kubernetes.Interface
@@ -97,8 +98,8 @@ func (pna *podNetworkAvalibility) StartCollection(ctx context.Context, adminREST
9798
}
9899
clusterVersion, err := configClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
99100
if apierrors.IsNotFound(err) {
100-
pna.notSupportedReason = "clusterversion/version not found and no image pull spec specified."
101-
return nil
101+
pna.notSupportedReason = &monitortestframework.NotSupportedError{Reason: "clusterversion/version not found and no image pull spec specified."}
102+
return pna.notSupportedReason
102103
}
103104
if err != nil {
104105
return err
@@ -113,8 +114,8 @@ func (pna *podNetworkAvalibility) StartCollection(ctx context.Context, adminREST
113114
cmd.Stdout = out
114115
cmd.Stderr = errOut
115116
if err := cmd.Run(); err != nil {
116-
pna.notSupportedReason = fmt.Sprintf("unable to determine openshift-tests image: %v: %v", err, errOut.String())
117-
return nil
117+
pna.notSupportedReason = &monitortestframework.NotSupportedError{Reason: fmt.Sprintf("unable to determine openshift-tests image: %v: %v", err, errOut.String())}
118+
return pna.notSupportedReason
118119
}
119120
openshiftTestsImagePullSpec := strings.TrimSpace(out.String())
120121
fmt.Printf("openshift-tests image pull spec is %v\n", openshiftTestsImagePullSpec)
@@ -235,15 +236,8 @@ func (pna *podNetworkAvalibility) serviceHasEndpoints(ctx context.Context) (bool
235236
}
236237

237238
func (pna *podNetworkAvalibility) CollectData(ctx context.Context, storageDir string, beginning, end time.Time) (monitorapi.Intervals, []*junitapi.JUnitTestCase, error) {
238-
if len(pna.notSupportedReason) > 0 {
239-
return nil, []*junitapi.JUnitTestCase{
240-
{
241-
Name: "[sig-network] can collect pod-to-pod network disruption",
242-
SkipMessage: &junitapi.SkipMessage{
243-
Message: pna.notSupportedReason,
244-
},
245-
},
246-
}, nil
239+
if pna.notSupportedReason != nil {
240+
return nil, nil, pna.notSupportedReason
247241
}
248242

249243
// create the stop collecting configmap and wait for 30s to thing to have stopped. the 30s is just a guess
@@ -351,15 +345,15 @@ func (pna *podNetworkAvalibility) collectDetailsForPoller(ctx context.Context, t
351345
}
352346

353347
func (pna *podNetworkAvalibility) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (constructedIntervals monitorapi.Intervals, err error) {
354-
return nil, nil
348+
return nil, pna.notSupportedReason
355349
}
356350

357351
func (pna *podNetworkAvalibility) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
358-
return nil, nil
352+
return nil, pna.notSupportedReason
359353
}
360354

361355
func (pna *podNetworkAvalibility) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
362-
return nil
356+
return pna.notSupportedReason
363357
}
364358

365359
func (pna *podNetworkAvalibility) Cleanup(ctx context.Context) error {

pkg/monitortests/network/disruptionserviceloadbalancer/monitortest.go

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ import (
1616
configv1 "github.com/openshift/api/config/v1"
1717
configclient "github.com/openshift/client-go/config/clientset/versioned"
1818
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
19-
"github.com/openshift/origin/pkg/monitor/backenddisruption"
20-
"github.com/openshift/origin/pkg/monitor/monitorapi"
21-
"github.com/openshift/origin/pkg/monitortestlibrary/disruptionlibrary"
22-
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
23-
exutil "github.com/openshift/origin/test/extended/util"
24-
"github.com/openshift/origin/test/extended/util/image"
2519
corev1 "k8s.io/api/core/v1"
2620
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2721
utilnet "k8s.io/apimachinery/pkg/util/net"
@@ -30,6 +24,13 @@ import (
3024
"k8s.io/client-go/rest"
3125
"k8s.io/kubernetes/test/e2e/framework/service"
3226
k8simage "k8s.io/kubernetes/test/utils/image"
27+
28+
"github.com/openshift/origin/pkg/monitor/backenddisruption"
29+
"github.com/openshift/origin/pkg/monitor/monitorapi"
30+
"github.com/openshift/origin/pkg/monitortestlibrary/disruptionlibrary"
31+
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
32+
exutil "github.com/openshift/origin/test/extended/util"
33+
"github.com/openshift/origin/test/extended/util/image"
3334
)
3435

3536
var (
@@ -52,7 +53,7 @@ func init() {
5253

5354
type availability struct {
5455
namespaceName string
55-
notSupportedReason string
56+
notSupportedReason *monitortestframework.NotSupportedError
5657
kubeClient kubernetes.Interface
5758

5859
disruptionChecker *disruptionlibrary.Availability
@@ -81,8 +82,8 @@ func (w *availability) StartCollection(ctx context.Context, adminRESTConfig *res
8182
return fmt.Errorf("unable to determine if cluster is MicroShift: %v", err)
8283
}
8384
if isMicroShift {
84-
w.notSupportedReason = "platform MicroShift not supported"
85-
return nil
85+
w.notSupportedReason = &monitortestframework.NotSupportedError{Reason: "platform MicroShift not supported"}
86+
return w.notSupportedReason
8687
}
8788

8889
configClient, err := configclient.NewForConfig(adminRESTConfig)
@@ -104,21 +105,27 @@ func (w *availability) StartCollection(ctx context.Context, adminRESTConfig *res
104105
infra.Status.PlatformStatus.Type == configv1.BareMetalPlatformType ||
105106
infra.Status.PlatformStatus.Type == configv1.OpenStackPlatformType ||
106107
infra.Status.PlatformStatus.Type == configv1.NonePlatformType {
107-
w.notSupportedReason = fmt.Sprintf("platform %q is not supported", infra.Status.PlatformStatus.Type)
108+
w.notSupportedReason = &monitortestframework.NotSupportedError{
109+
Reason: fmt.Sprintf("platform %q is not supported", infra.Status.PlatformStatus.Type),
110+
}
108111
}
109112
// single node clusters are not supported because the replication controller has 2 replicas with anti-affinity for running on the same node.
110113
if infra.Status.ControlPlaneTopology == configv1.SingleReplicaTopologyMode {
111-
w.notSupportedReason = fmt.Sprintf("topology %q is not supported", infra.Status.ControlPlaneTopology)
114+
w.notSupportedReason = &monitortestframework.NotSupportedError{
115+
Reason: fmt.Sprintf("topology %q is not supported", infra.Status.ControlPlaneTopology),
116+
}
112117
}
113118
nodeList, err := w.kubeClient.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
114119
if err != nil {
115120
return err
116121
}
117122
if len(nodeList.Items) < 2 {
118-
w.notSupportedReason = fmt.Sprintf("insufficient nodes for service load balancers")
123+
w.notSupportedReason = &monitortestframework.NotSupportedError{
124+
Reason: fmt.Sprintf("insufficient nodes for service load balancers"),
125+
}
119126
}
120-
if len(w.notSupportedReason) > 0 {
121-
return nil
127+
if w.notSupportedReason != nil {
128+
return w.notSupportedReason
122129
}
123130

124131
actualNamespace, err := w.kubeClient.CoreV1().Namespaces().Create(context.Background(), namespace, metav1.CreateOptions{})
@@ -231,8 +238,8 @@ func (w *availability) StartCollection(ctx context.Context, adminRESTConfig *res
231238
}
232239

233240
func (w *availability) CollectData(ctx context.Context, storageDir string, beginning, end time.Time) (monitorapi.Intervals, []*junitapi.JUnitTestCase, error) {
234-
if len(w.notSupportedReason) > 0 {
235-
return nil, nil, nil
241+
if w.notSupportedReason != nil {
242+
return nil, nil, w.notSupportedReason
236243
}
237244
// we failed and indicated it during setup.
238245
if w.disruptionChecker == nil {
@@ -242,13 +249,13 @@ func (w *availability) CollectData(ctx context.Context, storageDir string, begin
242249
return w.disruptionChecker.CollectData(ctx)
243250
}
244251

245-
func (*availability) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
246-
return nil, nil
252+
func (w *availability) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
253+
return nil, w.notSupportedReason
247254
}
248255

249256
func (w *availability) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
250-
if len(w.notSupportedReason) > 0 {
251-
return nil, nil
257+
if w.notSupportedReason != nil {
258+
return nil, w.notSupportedReason
252259
}
253260
if w.suppressJunit {
254261
return nil, nil
@@ -261,8 +268,8 @@ func (w *availability) EvaluateTestsFromConstructedIntervals(ctx context.Context
261268
return w.disruptionChecker.EvaluateTestsFromConstructedIntervals(ctx, finalIntervals)
262269
}
263270

264-
func (*availability) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
265-
return nil
271+
func (w *availability) WriteContentToStorage(ctx context.Context, storageDir, timeSuffix string, finalIntervals monitorapi.Intervals, finalResourceState monitorapi.ResourcesMap) error {
272+
return w.notSupportedReason
266273
}
267274

268275
func (w *availability) Cleanup(ctx context.Context) error {

0 commit comments

Comments
 (0)