feat: 为执行后端增加独立容量池
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package backendpool
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPoolSeparatesRuntimeCapacityFromDeliveries(t *testing.T) {
|
||||
pool := New(2)
|
||||
if !pool.Acquire("one") || !pool.Acquire("two") || pool.Acquire("three") {
|
||||
t.Fatal("capacity was not enforced")
|
||||
}
|
||||
if !pool.Acquire("one") {
|
||||
t.Fatal("redelivery must be idempotent")
|
||||
}
|
||||
pool.Release("one")
|
||||
if !pool.Acquire("three") || pool.Active() != 2 {
|
||||
t.Fatalf("active=%d", pool.Active())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestoreMayTemporarilyExceedReducedCapacity(t *testing.T) {
|
||||
pool := New(1)
|
||||
pool.Restore("one")
|
||||
pool.Restore("two")
|
||||
if pool.Active() != 2 || pool.Acquire("three") {
|
||||
t.Fatalf("active=%d", pool.Active())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user