From fed2ec99c652550ed4a8c00b7cfc6c93abbc4ade Mon Sep 17 00:00:00 2001 From: Madhav Jivrajani Date: Tue, 21 Sep 2021 15:53:43 +0530 Subject: [PATCH] migrate k8s.io/apimachinery/util/clock -> k8s.io/utils/clock Signed-off-by: Madhav Jivrajani --- staging/src/k8s.io/client-go/tools/record/event.go | 2 +- .../src/k8s.io/client-go/tools/record/event_test.go | 10 +++++----- .../src/k8s.io/client-go/tools/record/events_cache.go | 2 +- test/integration/apiserver/flowcontrol/fight_test.go | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/record/event.go b/staging/src/k8s.io/client-go/tools/record/event.go index 55d86ee1da0..4b61d0052f0 100644 --- a/staging/src/k8s.io/client-go/tools/record/event.go +++ b/staging/src/k8s.io/client-go/tools/record/event.go @@ -25,13 +25,13 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/watch" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/record/util" ref "k8s.io/client-go/tools/reference" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) const maxTriesPerEvent = 12 diff --git a/staging/src/k8s.io/client-go/tools/record/event_test.go b/staging/src/k8s.io/client-go/tools/record/event_test.go index 78dd3d39b25..f003b1d371d 100644 --- a/staging/src/k8s.io/client-go/tools/record/event_test.go +++ b/staging/src/k8s.io/client-go/tools/record/event_test.go @@ -29,11 +29,11 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/client-go/kubernetes/scheme" restclient "k8s.io/client-go/rest" ref "k8s.io/client-go/tools/reference" + "k8s.io/utils/clock" testclocks "k8s.io/utils/clock/testing" ) @@ -110,7 +110,7 @@ func TestNonRacyShutdown(t *testing.T) { // in a goroutine. caster := NewBroadcasterForTests(0) - clock := clock.NewFakeClock(time.Now()) + clock := testclocks.NewFakeClock(time.Now()) recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, caster, clock) var wg sync.WaitGroup @@ -374,7 +374,7 @@ func TestEventf(t *testing.T) { eventBroadcaster := NewBroadcasterForTests(0) sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents) - clock := clock.NewFakeClock(time.Now()) + clock := testclocks.NewFakeClock(time.Now()) recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock) for index, item := range table { clock.Step(1 * time.Second) @@ -619,7 +619,7 @@ func TestEventfNoNamespace(t *testing.T) { eventBroadcaster := NewBroadcasterForTests(0) sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents) - clock := clock.NewFakeClock(time.Now()) + clock := testclocks.NewFakeClock(time.Now()) recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock) for index, item := range table { @@ -907,7 +907,7 @@ func TestMultiSinkCache(t *testing.T) { } eventBroadcaster := NewBroadcasterForTests(0) - clock := clock.NewFakeClock(time.Now()) + clock := testclocks.NewFakeClock(time.Now()) recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock) sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents) diff --git a/staging/src/k8s.io/client-go/tools/record/events_cache.go b/staging/src/k8s.io/client-go/tools/record/events_cache.go index d818f923f5d..4f041e8fd26 100644 --- a/staging/src/k8s.io/client-go/tools/record/events_cache.go +++ b/staging/src/k8s.io/client-go/tools/record/events_cache.go @@ -27,10 +27,10 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/client-go/util/flowcontrol" + "k8s.io/utils/clock" ) const ( diff --git a/test/integration/apiserver/flowcontrol/fight_test.go b/test/integration/apiserver/flowcontrol/fight_test.go index af1b95ed8ff..509f471e0c2 100644 --- a/test/integration/apiserver/flowcontrol/fight_test.go +++ b/test/integration/apiserver/flowcontrol/fight_test.go @@ -26,7 +26,6 @@ import ( "time" flowcontrol "k8s.io/api/flowcontrol/v1beta2" - "k8s.io/apimachinery/pkg/util/clock" genericfeatures "k8s.io/apiserver/pkg/features" utilfeature "k8s.io/apiserver/pkg/util/feature" utilfc "k8s.io/apiserver/pkg/util/flowcontrol" @@ -37,6 +36,8 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/utils/clock" + testclocks "k8s.io/utils/clock/testing" ) /* fightTest configures a test of how API Priority and Fairness config @@ -63,7 +64,7 @@ type fightTest struct { teamSize int stopCh chan struct{} now time.Time - clk *clock.FakeClock + clk *testclocks.FakeClock ctlrs map[bool][]utilfc.Interface countsMutex sync.Mutex @@ -81,7 +82,7 @@ func newFightTest(t *testing.T, loopbackConfig *rest.Config, teamSize int) *figh teamSize: teamSize, stopCh: make(chan struct{}), now: now, - clk: clock.NewFakeClock(now), + clk: testclocks.NewFakeClock(now), ctlrs: map[bool][]utilfc.Interface{ false: make([]utilfc.Interface, teamSize), true: make([]utilfc.Interface, teamSize)},