mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +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,38 +747,45 @@ func TestTooWide(t *testing.T) {
|
|||||||
|
|
||||||
func TestWindup(t *testing.T) {
|
func TestWindup(t *testing.T) {
|
||||||
metrics.Register()
|
metrics.Register()
|
||||||
now := time.Now()
|
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()
|
||||||
|
clk, counter := testeventclock.NewFake(now, 0, nil)
|
||||||
|
qsf := newTestableQueueSetFactory(clk, countingPromiseFactoryFactory(counter))
|
||||||
|
qCfg := fq.QueuingConfig{
|
||||||
|
Name: "TestWindup/" + subName,
|
||||||
|
DesiredNumQueues: 9,
|
||||||
|
QueueLengthLimit: 6,
|
||||||
|
HandSize: 1,
|
||||||
|
RequestWaitLimit: 10 * time.Minute,
|
||||||
|
}
|
||||||
|
qsc, err := qsf.BeginConstruction(qCfg, newObserverPair(clk))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
qs := qsc.Complete(fq.DispatchingConfig{ConcurrencyLimit: 3})
|
||||||
|
|
||||||
clk, counter := testeventclock.NewFake(now, 0, nil)
|
uniformScenario{name: qCfg.Name, qs: qs,
|
||||||
qsf := newTestableQueueSetFactory(clk, countingPromiseFactoryFactory(counter))
|
clients: []uniformClient{
|
||||||
qCfg := fq.QueuingConfig{
|
newUniformClient(1001001001, 2, 40, time.Second, -1),
|
||||||
Name: "TestWindup",
|
newUniformClient(2002002002, 2, 40, time.Second, -1).setSplit(),
|
||||||
DesiredNumQueues: 9,
|
},
|
||||||
QueueLengthLimit: 6,
|
concurrencyLimit: 3,
|
||||||
HandSize: 1,
|
evalDuration: time.Second * 40,
|
||||||
RequestWaitLimit: 10 * time.Minute,
|
expectedFair: []bool{true, testcase.expectFair2},
|
||||||
|
expectedFairnessMargin: []float64{0.1, testcase.margin2},
|
||||||
|
expectAllRequests: true,
|
||||||
|
evalInqueueMetrics: true,
|
||||||
|
evalExecutingMetrics: true,
|
||||||
|
clk: clk,
|
||||||
|
counter: counter,
|
||||||
|
}.exercise(t)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
qsc, err := qsf.BeginConstruction(qCfg, newObserverPair(clk))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
qs := qsc.Complete(fq.DispatchingConfig{ConcurrencyLimit: 3})
|
|
||||||
|
|
||||||
uniformScenario{name: qCfg.Name, qs: qs,
|
|
||||||
clients: []uniformClient{
|
|
||||||
newUniformClient(1001001001, 2, 40, time.Second, -1),
|
|
||||||
newUniformClient(2002002002, 2, 40, time.Second, -1).setSplit(),
|
|
||||||
},
|
|
||||||
concurrencyLimit: 3,
|
|
||||||
evalDuration: time.Second * 40,
|
|
||||||
expectedFair: []bool{true, true},
|
|
||||||
expectedFairnessMargin: []float64{0.1, 0.26},
|
|
||||||
expectAllRequests: true,
|
|
||||||
evalInqueueMetrics: true,
|
|
||||||
evalExecutingMetrics: true,
|
|
||||||
clk: clk,
|
|
||||||
counter: counter,
|
|
||||||
}.exercise(t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDifferentFlowsWithoutQueuing(t *testing.T) {
|
func TestDifferentFlowsWithoutQueuing(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user