Skip to content

Commit ae4e0c3

Browse files
committed
react to changes
1 parent 23dd96c commit ae4e0c3

14 files changed

+45
-30
lines changed

pkg/cmd/checkendpoints/controller/backoff_recorder_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
"github.com/openshift/library-go/pkg/operator/events"
99
"github.com/stretchr/testify/assert"
10+
11+
"k8s.io/utils/clock"
1012
)
1113

1214
func TestWithShortWindow(t *testing.T) {
@@ -18,7 +20,7 @@ func TestWithShortWindow(t *testing.T) {
1820
backoffDuration := longDuration
1921
excessiveEventCount := 10
2022

21-
inMemoryRecorder := events.NewInMemoryRecorder(t.Name())
23+
inMemoryRecorder := events.NewInMemoryRecorder(t.Name(), clock.RealClock{})
2224
r := NewBackoffEventRecorder(inMemoryRecorder,
2325
WithShortWindow(shortDuration, shortCountMax),
2426
WithLongWindow(longDuration, longCountMax),
@@ -61,7 +63,7 @@ func TestWithLongWindow(t *testing.T) {
6163
backoffDuration := longDuration
6264
excessiveEventCount := 10
6365

64-
inMemoryRecorder := events.NewInMemoryRecorder(t.Name())
66+
inMemoryRecorder := events.NewInMemoryRecorder(t.Name(), clock.RealClock{})
6567
r := NewBackoffEventRecorder(inMemoryRecorder,
6668
WithShortWindow(shortDuration, shortCountMax),
6769
WithLongWindow(longDuration, longCountMax),

pkg/cmd/checkendpoints/controller/connection_checker_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/stretchr/testify/assert"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414
"k8s.io/apimachinery/pkg/util/mergepatch"
15+
"k8s.io/utils/clock"
1516

1617
"github.com/openshift/cluster-kube-apiserver-operator/pkg/cmd/checkendpoints/trace"
1718
)
@@ -418,7 +419,7 @@ func TestManageStatusOutage(t *testing.T) {
418419
for _, tc := range testCases {
419420
t.Run(tc.name, func(t *testing.T) {
420421
status := tc.initial
421-
manageStatusOutage(events.NewInMemoryRecorder(t.Name()))(status)
422+
manageStatusOutage(events.NewInMemoryRecorder(t.Name(), clock.RealClock{}))(status)
422423
assert.Equal(t, tc.expected, status.Outages)
423424
if t.Failed() {
424425
t.Log("\n", mergepatch.ToYAMLOrError(tc.expected))

pkg/operator/configobservation/apiserver/observe_apiserver_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"k8s.io/apimachinery/pkg/util/diff"
1212
corelistersv1 "k8s.io/client-go/listers/core/v1"
1313
"k8s.io/client-go/tools/cache"
14+
"k8s.io/utils/clock"
1415

1516
configv1 "github.com/openshift/api/config/v1"
1617
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
@@ -71,7 +72,7 @@ func TestObserveUserClientCABundle(t *testing.T) {
7172
APIServerLister_: configlistersv1.NewAPIServerLister(indexer),
7273
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
7374
}
74-
result, errs := ObserveUserClientCABundle(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
75+
result, errs := ObserveUserClientCABundle(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
7576
if len(errs) > 0 {
7677
t.Errorf("Expected 0 errors, got %v.", len(errs))
7778
}
@@ -501,7 +502,7 @@ func TestObserveNamedCertificates(t *testing.T) {
501502
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
502503
ConfigSecretLister_: corelistersv1.NewSecretLister(indexer),
503504
}
504-
result, errs := ObserveNamedCertificates(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
505+
result, errs := ObserveNamedCertificates(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
505506
if tc.expectErrs && len(errs) == 0 {
506507
t.Error("Expected errors.", errs)
507508
}

pkg/operator/configobservation/apiserver/observe_cors_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"k8s.io/apimachinery/pkg/api/equality"
1111
"k8s.io/apimachinery/pkg/util/diff"
1212
"k8s.io/client-go/tools/cache"
13+
"k8s.io/utils/clock"
1314
)
1415

1516
func TestObserveAdditionalCORSAllowedOrigins(t *testing.T) {
@@ -73,7 +74,7 @@ func TestObserveAdditionalCORSAllowedOrigins(t *testing.T) {
7374
APIServerLister_: configlistersv1.NewAPIServerLister(indexer),
7475
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
7576
}
76-
result, errs := ObserveAdditionalCORSAllowedOrigins(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
77+
result, errs := ObserveAdditionalCORSAllowedOrigins(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
7778
if len(errs) > 0 {
7879
t.Errorf("Expected 0 errors, got %v.", len(errs))
7980
}

pkg/operator/configobservation/apiserver/observe_send_retry_after_while_not_ready_once_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
"k8s.io/client-go/tools/cache"
10+
"k8s.io/utils/clock"
1011

1112
configv1 "github.com/openshift/api/config/v1"
1213
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
@@ -94,7 +95,7 @@ func TestObserveSendRetryAfterWhileNotReadyOnce(t *testing.T) {
9495
for _, scenario := range scenarios {
9596
t.Run(scenario.name, func(t *testing.T) {
9697
// test data
97-
eventRecorder := events.NewInMemoryRecorder("")
98+
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
9899
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
99100
infrastructureIndexer.Add(&configv1.Infrastructure{
100101
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},

pkg/operator/configobservation/apiserver/observe_termination_duration_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1313
"k8s.io/client-go/tools/cache"
14+
"k8s.io/utils/clock"
1415

1516
configv1 "github.com/openshift/api/config/v1"
1617
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
@@ -69,7 +70,7 @@ func TestObserveWatchTerminationDuration(t *testing.T) {
6970
for _, scenario := range scenarios {
7071
t.Run(scenario.name, func(t *testing.T) {
7172
// test data
72-
eventRecorder := events.NewInMemoryRecorder("")
73+
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
7374
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
7475
infrastructureIndexer.Add(&configv1.Infrastructure{
7576
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
@@ -182,7 +183,7 @@ func TestObserveShutdownDelayDuration(t *testing.T) {
182183
for _, scenario := range scenarios {
183184
t.Run(scenario.name, func(t *testing.T) {
184185
// test data
185-
eventRecorder := events.NewInMemoryRecorder("")
186+
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
186187
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
187188
infrastructureIndexer.Add(&configv1.Infrastructure{
188189
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},

pkg/operator/configobservation/auth/auth_serviceaccountissuer_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1515
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
16+
"k8s.io/utils/clock"
1617

1718
configv1 "github.com/openshift/api/config/v1"
1819
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
@@ -107,7 +108,7 @@ func TestObservedConfig(t *testing.T) {
107108
},
108109
} {
109110
t.Run(tc.name, func(t *testing.T) {
110-
testRecorder := events.NewInMemoryRecorder("SAIssuerTest")
111+
testRecorder := events.NewInMemoryRecorder("SAIssuerTest", clock.RealClock{})
111112

112113
newConfig, errs := observedConfig(
113114
unstructuredAPIConfigForIssuer(t, tc.existingIssuer, tc.trustedIssuers),

pkg/operator/configobservation/auth/podsecurityadmission_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/openshift/api/features"
1616
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
1717
"github.com/openshift/library-go/pkg/operator/events"
18+
"k8s.io/utils/clock"
1819
)
1920

2021
func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {
@@ -79,7 +80,7 @@ func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {
7980
},
8081
} {
8182
t.Run(tc.name, func(t *testing.T) {
82-
testRecorder := events.NewInMemoryRecorder("SAIssuerTest")
83+
testRecorder := events.NewInMemoryRecorder("SAIssuerTest", clock.RealClock{})
8384
existingConfig := map[string]interface{}{}
8485
require.NoError(t, json.Unmarshal([]byte(tc.existingJSON), &existingConfig))
8586

pkg/operator/configobservation/auth/webhook_authenticator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation"
1919
"github.com/openshift/library-go/pkg/operator/events"
2020
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
21+
"k8s.io/utils/clock"
2122
)
2223

2324
var correctKubeConfigString = []byte(`
@@ -154,7 +155,7 @@ func TestObserveWebhookTokenAuthenticator(t *testing.T) {
154155
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
155156
}
156157

157-
eventRecorder := events.NewInMemoryRecorder("webhookauthenticatortest")
158+
eventRecorder := events.NewInMemoryRecorder("webhookauthenticatortest", clock.RealClock{})
158159

159160
gotConfig, errs := ObserveWebhookTokenAuthenticator(listers, eventRecorder, tt.existingConfig)
160161
gotAuthenticator, _, err := unstructured.NestedStringSlice(gotConfig, webhookTokenAuthenticatorPath...)

pkg/operator/configobservation/etcdendpoints/observe_etcd_endpoints_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"k8s.io/apimachinery/pkg/util/mergepatch"
1414
corev1listers "k8s.io/client-go/listers/core/v1"
1515
"k8s.io/client-go/tools/cache"
16+
"k8s.io/utils/clock"
1617

1718
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation"
1819
)
@@ -62,7 +63,7 @@ func TestObserveStorageURLs(t *testing.T) {
6263
t.Fatalf("error adding endpoint to store: %#v", err)
6364
}
6465
}
65-
actual, errs := ObserveStorageURLs(lister, events.NewInMemoryRecorder("test"), tt.currentConfig)
66+
actual, errs := ObserveStorageURLs(lister, events.NewInMemoryRecorder("test", clock.RealClock{}), tt.currentConfig)
6667
if tt.expectErrors && len(errs) == 0 {
6768
t.Errorf("errors expected")
6869
}

0 commit comments

Comments
 (0)