mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Update TestNoRestraint and TestWindup
Make TestNoRestraint verify that fairness is NOT achieved when there is real competition. Make TestWindup run two cases, to show that 0.1 is too narrow a margin and 0.26 is wide enough.
This commit is contained in:
parent
47f381ba5e
commit
c4945fdf0c
@ -413,6 +413,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestNoRestraint tests whether the no-restraint factory gives every client what it asks for
|
// TestNoRestraint tests whether the no-restraint factory gives every client what it asks for
|
||||||
|
// even though that is unfair.
|
||||||
func TestNoRestraint(t *testing.T) {
|
func TestNoRestraint(t *testing.T) {
|
||||||
metrics.Register()
|
metrics.Register()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
@ -428,9 +429,9 @@ func TestNoRestraint(t *testing.T) {
|
|||||||
newUniformClient(1001001001, 5, 10, time.Second, time.Second),
|
newUniformClient(1001001001, 5, 10, time.Second, time.Second),
|
||||||
newUniformClient(2002002002, 2, 10, time.Second, time.Second/2),
|
newUniformClient(2002002002, 2, 10, time.Second, time.Second/2),
|
||||||
},
|
},
|
||||||
concurrencyLimit: 10,
|
concurrencyLimit: 2,
|
||||||
evalDuration: time.Second * 15,
|
evalDuration: time.Second * 15,
|
||||||
expectedFair: []bool{true},
|
expectedFair: []bool{false},
|
||||||
expectedFairnessMargin: []float64{0.1},
|
expectedFairnessMargin: []float64{0.1},
|
||||||
expectAllRequests: true,
|
expectAllRequests: true,
|
||||||
clk: clk,
|
clk: clk,
|
||||||
@ -733,9 +734,9 @@ func TestTooWide(t *testing.T) {
|
|||||||
newUniformClient(90090090090090, 15, 21, time.Second, time.Second-1).seats(7),
|
newUniformClient(90090090090090, 15, 21, time.Second, time.Second-1).seats(7),
|
||||||
},
|
},
|
||||||
concurrencyLimit: 6,
|
concurrencyLimit: 6,
|
||||||
evalDuration: time.Second * 40,
|
evalDuration: time.Second * 435,
|
||||||
expectedFair: []bool{true},
|
expectedFair: []bool{true},
|
||||||
expectedFairnessMargin: []float64{0.38},
|
expectedFairnessMargin: []float64{0.375},
|
||||||
expectAllRequests: true,
|
expectAllRequests: true,
|
||||||
evalInqueueMetrics: true,
|
evalInqueueMetrics: true,
|
||||||
evalExecutingMetrics: true,
|
evalExecutingMetrics: true,
|
||||||
@ -746,12 +747,17 @@ func TestTooWide(t *testing.T) {
|
|||||||
|
|
||||||
func TestWindup(t *testing.T) {
|
func TestWindup(t *testing.T) {
|
||||||
metrics.Register()
|
metrics.Register()
|
||||||
|
for _, testcase := range []struct {
|
||||||
|
margin2 float64
|
||||||
|
expectFair2 bool
|
||||||
|
}{{margin2: 0.26, expectFair2: true}, {margin2: 0.1, expectFair2: false}} {
|
||||||
|
subName := fmt.Sprintf("m2=%v", testcase.margin2)
|
||||||
|
t.Run(subName, func(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
clk, counter := testeventclock.NewFake(now, 0, nil)
|
clk, counter := testeventclock.NewFake(now, 0, nil)
|
||||||
qsf := newTestableQueueSetFactory(clk, countingPromiseFactoryFactory(counter))
|
qsf := newTestableQueueSetFactory(clk, countingPromiseFactoryFactory(counter))
|
||||||
qCfg := fq.QueuingConfig{
|
qCfg := fq.QueuingConfig{
|
||||||
Name: "TestWindup",
|
Name: "TestWindup/" + subName,
|
||||||
DesiredNumQueues: 9,
|
DesiredNumQueues: 9,
|
||||||
QueueLengthLimit: 6,
|
QueueLengthLimit: 6,
|
||||||
HandSize: 1,
|
HandSize: 1,
|
||||||
@ -770,14 +776,16 @@ func TestWindup(t *testing.T) {
|
|||||||
},
|
},
|
||||||
concurrencyLimit: 3,
|
concurrencyLimit: 3,
|
||||||
evalDuration: time.Second * 40,
|
evalDuration: time.Second * 40,
|
||||||
expectedFair: []bool{true, true},
|
expectedFair: []bool{true, testcase.expectFair2},
|
||||||
expectedFairnessMargin: []float64{0.1, 0.26},
|
expectedFairnessMargin: []float64{0.1, testcase.margin2},
|
||||||
expectAllRequests: true,
|
expectAllRequests: true,
|
||||||
evalInqueueMetrics: true,
|
evalInqueueMetrics: true,
|
||||||
evalExecutingMetrics: true,
|
evalExecutingMetrics: true,
|
||||||
clk: clk,
|
clk: clk,
|
||||||
counter: counter,
|
counter: counter,
|
||||||
}.exercise(t)
|
}.exercise(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDifferentFlowsWithoutQueuing(t *testing.T) {
|
func TestDifferentFlowsWithoutQueuing(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user