Migrate apiserver/pkg/util/flowcontrol to use k8s.io/utils/clock
.. instead of apimachinery/pkt/util/clock Kubernetes-commit: 9f45c0f8c07cd0adfe38c887aa618d33b8a4ee1c
This commit is contained in:
parent
a9b32ae425
commit
e417abf592
|
@ -35,7 +35,6 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
apitypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -51,6 +50,7 @@ import (
|
|||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
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/wait"
|
||||
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
|
@ -41,6 +40,7 @@ import (
|
|||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
|
||||
// Some tests print a lot of debug logs which slows down tests considerably,
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
"k8s.io/apiserver/pkg/util/flowcontrol/metrics"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
|
||||
// Integrator computes the moments of some variable X over time as
|
||||
|
|
|
@ -21,12 +21,12 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
testclock "k8s.io/utils/clock/testing"
|
||||
)
|
||||
|
||||
func TestIntegrator(t *testing.T) {
|
||||
now := time.Now()
|
||||
clk := clock.NewFakeClock(now)
|
||||
clk := testclock.NewFakeClock(now)
|
||||
igr := NewIntegrator(clk)
|
||||
igr.Add(3)
|
||||
clk.Step(time.Second)
|
||||
|
|
|
@ -22,10 +22,10 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
compbasemetrics "k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
basemetricstestutil "k8s.io/component-base/metrics/testutil"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -20,9 +20,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
compbasemetrics "k8s.io/component-base/metrics"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -22,10 +22,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
compbasemetrics "k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
"k8s.io/klog/v2"
|
||||
testclock "k8s.io/utils/clock/testing"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -52,7 +52,7 @@ const (
|
|||
*/
|
||||
func TestSampler(t *testing.T) {
|
||||
t0 := time.Now()
|
||||
clk := clock.NewFakePassiveClock(t0)
|
||||
clk := testclock.NewFakePassiveClock(t0)
|
||||
buckets := []float64{0, 1}
|
||||
gen := NewSampleAndWaterMarkHistogramsGenerator(clk, samplingPeriod,
|
||||
&compbasemetrics.HistogramOpts{Name: samplesHistName, Buckets: buckets},
|
||||
|
|
|
@ -21,9 +21,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
testclock "k8s.io/utils/clock/testing"
|
||||
)
|
||||
|
||||
func TestStorageObjectCountTracker(t *testing.T) {
|
||||
|
@ -66,7 +66,7 @@ func TestStorageObjectCountTracker(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
fakeClock := &clock.FakePassiveClock{}
|
||||
fakeClock := &testclock.FakePassiveClock{}
|
||||
tracker := &objectCountTracker{
|
||||
clock: fakeClock,
|
||||
counts: map[string]*timestampedCount{},
|
||||
|
@ -93,7 +93,7 @@ func TestStorageObjectCountTracker(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStorageObjectCountTrackerWithPrune(t *testing.T) {
|
||||
fakeClock := &clock.FakePassiveClock{}
|
||||
fakeClock := &testclock.FakePassiveClock{}
|
||||
tracker := &objectCountTracker{
|
||||
clock: fakeClock,
|
||||
counts: map[string]*timestampedCount{},
|
||||
|
|
Loading…
Reference in New Issue