-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28543 from DennisPeriquet/trt-1452-namespaced-bac…
…koffs TRT-1452: Separate excessive Back-off restarting tests via namespace
- Loading branch information
Showing
4 changed files
with
157 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
pkg/monitortestlibrary/pathologicaleventlibrary/duplicated_events_special_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package pathologicaleventlibrary | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/openshift/origin/pkg/monitor/monitorapi" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_singleEventThresholdCheck_getNamespacedFailuresAndFlakes(t *testing.T) { | ||
namespace := "openshift-etcd-operator" | ||
samplePod := "etcd-operator-6f9b4d9d4f-4q9q8" | ||
|
||
testName := "[sig-cluster-lifecycle] pathological event should not see excessive Back-off restarting failed containers" | ||
backoffMatcher := NewSingleEventThresholdCheck(testName, AllowBackOffRestartingFailedContainer, | ||
DuplicateEventThreshold, BackoffRestartingFlakeThreshold) | ||
type fields struct { | ||
testName string | ||
matcher *SimplePathologicalEventMatcher | ||
failThreshold int | ||
flakeThreshold int | ||
} | ||
type args struct { | ||
events monitorapi.Intervals | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
expectedKeyCount int | ||
}{ | ||
{ | ||
name: "Successful test yields no keys", | ||
fields: fields{ | ||
testName: testName, | ||
matcher: backoffMatcher.matcher, | ||
failThreshold: DuplicateEventThreshold, | ||
flakeThreshold: BackoffRestartingFlakeThreshold, | ||
}, | ||
args: args{ | ||
events: monitorapi.Intervals{ | ||
BuildTestDupeKubeEvent(namespace, samplePod, | ||
"BackOff", | ||
"Back-off restarting failed container", | ||
5), | ||
}, | ||
}, | ||
expectedKeyCount: 0, | ||
}, | ||
{ | ||
name: "Failing test yields one key", | ||
fields: fields{ | ||
testName: testName, | ||
matcher: backoffMatcher.matcher, | ||
failThreshold: DuplicateEventThreshold, | ||
flakeThreshold: BackoffRestartingFlakeThreshold, | ||
}, | ||
args: args{ | ||
events: monitorapi.Intervals{ | ||
BuildTestDupeKubeEvent(namespace, samplePod, | ||
"BackOff", | ||
"Back-off restarting failed container", | ||
21), | ||
}, | ||
}, | ||
expectedKeyCount: 1, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
s := &singleEventThresholdCheck{ | ||
testName: tt.fields.testName, | ||
matcher: tt.fields.matcher, | ||
failThreshold: tt.fields.failThreshold, | ||
flakeThreshold: tt.fields.flakeThreshold, | ||
} | ||
got := s.getNamespacedFailuresAndFlakes(tt.args.events) | ||
assert.Equal(t, tt.expectedKeyCount, len(got)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters