merged from gramsrv upstream
This commit is contained in:
parent
79c64ee916
commit
21a0856587
651 changed files with 54774 additions and 4590 deletions
|
|
@ -52,6 +52,11 @@ func TestRPCDeliveryHookExecutorBoundsAdmissionWithoutBlockingDelivery(t *testin
|
|||
if got := len(executor.slots); got != 0 {
|
||||
t.Fatalf("executor retained %d capacity slots", got)
|
||||
}
|
||||
snapshot := executor.runtimeSnapshot()
|
||||
if snapshot.workers != 1 || snapshot.capacity != 1 || snapshot.completed != 1 || snapshot.rejected != 1 ||
|
||||
snapshot.reserved != 0 || snapshot.queued != 0 || snapshot.running != 0 || snapshot.durationSeconds <= 0 {
|
||||
t.Fatalf("executor snapshot = %#v", snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRPCDeliveryHookExecutorIsolatesPanicsAndContinues(t *testing.T) {
|
||||
|
|
@ -109,3 +114,58 @@ func TestEquivalentRPCDeliveryAttemptsShareExactlyOnceCoordinator(t *testing.T)
|
|||
t.Fatalf("equivalent attempts leaked %d tickets", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRPCDeliveryHookExecutorStopRejectsNewAndDrainsReserved(t *testing.T) {
|
||||
executor := newRPCDeliveryHookExecutor(1, 2)
|
||||
ticket, ok := executor.reserve()
|
||||
if !ok {
|
||||
t.Fatal("reserve ticket")
|
||||
}
|
||||
stopped := make(chan bool, 1)
|
||||
go func() { stopped <- executor.stop(time.Second) }()
|
||||
deadline := time.Now().Add(time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
executor.mu.Lock()
|
||||
stopping := executor.stopping
|
||||
executor.mu.Unlock()
|
||||
if stopping {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if _, ok := executor.reserve(); ok {
|
||||
t.Fatal("executor accepted a reservation after stop")
|
||||
}
|
||||
select {
|
||||
case <-stopped:
|
||||
t.Fatal("stop returned while a reserved ticket was still owned")
|
||||
default:
|
||||
}
|
||||
ticket.release()
|
||||
select {
|
||||
case ok := <-stopped:
|
||||
if !ok {
|
||||
t.Fatal("executor did not drain before timeout")
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("executor stop did not finish after ticket release")
|
||||
}
|
||||
snapshot := executor.runtimeSnapshot()
|
||||
if snapshot.reserved != 0 || snapshot.queued != 0 || snapshot.running != 0 || snapshot.rejected < 1 {
|
||||
t.Fatalf("stopped executor snapshot = %#v", snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRPCDeliveryHookExecutorIsServerScoped(t *testing.T) {
|
||||
first := New(Options{RPCDeliveryHookWorkers: 2, RPCDeliveryHookMaxPending: 7})
|
||||
second := New(Options{RPCDeliveryHookWorkers: 3, RPCDeliveryHookMaxPending: 9})
|
||||
if first.rpcDeliveryHooks == nil || second.rpcDeliveryHooks == nil || first.rpcDeliveryHooks == second.rpcDeliveryHooks {
|
||||
t.Fatal("servers did not receive isolated delivery-hook executors")
|
||||
}
|
||||
firstSnapshot := first.RuntimeSnapshot()
|
||||
secondSnapshot := second.RuntimeSnapshot()
|
||||
if firstSnapshot.RPCDeliveryHookWorkers != 2 || firstSnapshot.RPCDeliveryHookCapacity != 7 ||
|
||||
secondSnapshot.RPCDeliveryHookWorkers != 3 || secondSnapshot.RPCDeliveryHookCapacity != 9 {
|
||||
t.Fatalf("server delivery-hook limits = %#v / %#v", firstSnapshot, secondSnapshot)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue