mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-06 19:49:08 +00:00
Migrate to k8s.io/utils/clock in flowcontrol backoff
Kubernetes-commit: 4ce452989bef21ab6d15bc659f463d8c706ad33e
This commit is contained in:
parent
14a51589c3
commit
8d49a0b940
@ -54,6 +54,7 @@ import (
|
|||||||
restclientwatch "k8s.io/client-go/rest/watch"
|
restclientwatch "k8s.io/client-go/rest/watch"
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
utiltesting "k8s.io/client-go/util/testing"
|
utiltesting "k8s.io/client-go/util/testing"
|
||||||
|
testingclock "k8s.io/utils/clock/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewRequestSetsAccept(t *testing.T) {
|
func TestNewRequestSetsAccept(t *testing.T) {
|
||||||
@ -1563,7 +1564,7 @@ func TestBackoffLifecycle(t *testing.T) {
|
|||||||
// which are used in the server implementation returning StatusOK above.
|
// which are used in the server implementation returning StatusOK above.
|
||||||
seconds := []int{0, 1, 2, 4, 8, 0, 1, 2, 4, 0}
|
seconds := []int{0, 1, 2, 4, 8, 0, 1, 2, 4, 0}
|
||||||
request := c.Verb("POST").Prefix("backofftest").Suffix("abc")
|
request := c.Verb("POST").Prefix("backofftest").Suffix("abc")
|
||||||
clock := clock.FakeClock{}
|
clock := testingclock.FakeClock{}
|
||||||
request.backoff = &URLBackoff{
|
request.backoff = &URLBackoff{
|
||||||
// Use a fake backoff here to avoid flakes and speed the test up.
|
// Use a fake backoff here to avoid flakes and speed the test up.
|
||||||
Backoff: flowcontrol.NewFakeBackOff(
|
Backoff: flowcontrol.NewFakeBackOff(
|
||||||
|
@ -20,7 +20,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/utils/clock"
|
||||||
|
testingclock "k8s.io/utils/clock/testing"
|
||||||
"k8s.io/utils/integer"
|
"k8s.io/utils/integer"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ type Backoff struct {
|
|||||||
perItemBackoff map[string]*backoffEntry
|
perItemBackoff map[string]*backoffEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFakeBackOff(initial, max time.Duration, tc *clock.FakeClock) *Backoff {
|
func NewFakeBackOff(initial, max time.Duration, tc *testingclock.FakeClock) *Backoff {
|
||||||
return &Backoff{
|
return &Backoff{
|
||||||
perItemBackoff: map[string]*backoffEntry{},
|
perItemBackoff: map[string]*backoffEntry{},
|
||||||
Clock: tc,
|
Clock: tc,
|
||||||
|
@ -20,12 +20,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
testingclock "k8s.io/utils/clock/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSlowBackoff(t *testing.T) {
|
func TestSlowBackoff(t *testing.T) {
|
||||||
id := "_idSlow"
|
id := "_idSlow"
|
||||||
tc := clock.NewFakeClock(time.Now())
|
tc := testingclock.NewFakeClock(time.Now())
|
||||||
step := time.Second
|
step := time.Second
|
||||||
maxDuration := 50 * step
|
maxDuration := 50 * step
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ func TestSlowBackoff(t *testing.T) {
|
|||||||
|
|
||||||
func TestBackoffReset(t *testing.T) {
|
func TestBackoffReset(t *testing.T) {
|
||||||
id := "_idReset"
|
id := "_idReset"
|
||||||
tc := clock.NewFakeClock(time.Now())
|
tc := testingclock.NewFakeClock(time.Now())
|
||||||
step := time.Second
|
step := time.Second
|
||||||
maxDuration := step * 5
|
maxDuration := step * 5
|
||||||
b := NewFakeBackOff(step, maxDuration, tc)
|
b := NewFakeBackOff(step, maxDuration, tc)
|
||||||
@ -77,7 +77,7 @@ func TestBackoffReset(t *testing.T) {
|
|||||||
|
|
||||||
func TestBackoffHighWaterMark(t *testing.T) {
|
func TestBackoffHighWaterMark(t *testing.T) {
|
||||||
id := "_idHiWaterMark"
|
id := "_idHiWaterMark"
|
||||||
tc := clock.NewFakeClock(time.Now())
|
tc := testingclock.NewFakeClock(time.Now())
|
||||||
step := time.Second
|
step := time.Second
|
||||||
maxDuration := 5 * step
|
maxDuration := 5 * step
|
||||||
b := NewFakeBackOff(step, maxDuration, tc)
|
b := NewFakeBackOff(step, maxDuration, tc)
|
||||||
@ -99,7 +99,7 @@ func TestBackoffHighWaterMark(t *testing.T) {
|
|||||||
|
|
||||||
func TestBackoffGC(t *testing.T) {
|
func TestBackoffGC(t *testing.T) {
|
||||||
id := "_idGC"
|
id := "_idGC"
|
||||||
tc := clock.NewFakeClock(time.Now())
|
tc := testingclock.NewFakeClock(time.Now())
|
||||||
step := time.Second
|
step := time.Second
|
||||||
maxDuration := 5 * step
|
maxDuration := 5 * step
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ func TestBackoffGC(t *testing.T) {
|
|||||||
|
|
||||||
func TestIsInBackOffSinceUpdate(t *testing.T) {
|
func TestIsInBackOffSinceUpdate(t *testing.T) {
|
||||||
id := "_idIsInBackOffSinceUpdate"
|
id := "_idIsInBackOffSinceUpdate"
|
||||||
tc := clock.NewFakeClock(time.Now())
|
tc := testingclock.NewFakeClock(time.Now())
|
||||||
step := time.Second
|
step := time.Second
|
||||||
maxDuration := 10 * step
|
maxDuration := 10 * step
|
||||||
b := NewFakeBackOff(step, maxDuration, tc)
|
b := NewFakeBackOff(step, maxDuration, tc)
|
||||||
|
Loading…
Reference in New Issue
Block a user