Adding Concurrency in Pool Manager (#1698)
Concurrency in the pool manager allows specializing pods concurrently based on a specified limit. Co-authored-by: Vishal <vishal-biyani@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package poolcache
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func checkErr(err error) {
|
||||
if err != nil {
|
||||
log.Panicf("err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPoolCache(t *testing.T) {
|
||||
c := NewPoolCache()
|
||||
|
||||
c.SetValue("func", "ip", "value")
|
||||
|
||||
c.SetValue("func2", "ip2", "value2")
|
||||
|
||||
c.SetValue("func2", "ip22", "value22")
|
||||
|
||||
cc := c.ListValue()
|
||||
if len(cc) != 3 {
|
||||
log.Panicf("expected 2 items")
|
||||
}
|
||||
active := c.GetTotalAvailable("func2")
|
||||
if active != 2 {
|
||||
log.Panicf("expected 2 items")
|
||||
}
|
||||
|
||||
c.DeleteValue("func2", "ip2")
|
||||
|
||||
c.MarkAvailable("func", "ip")
|
||||
|
||||
_, err := c.GetValue("func")
|
||||
checkErr(err)
|
||||
|
||||
c.DeleteValue("func", "ip")
|
||||
|
||||
_, err = c.GetValue("func")
|
||||
if err == nil {
|
||||
log.Panicf("found deleted element")
|
||||
}
|
||||
|
||||
c.SetValue("expires", "42", "all answers")
|
||||
|
||||
time.Sleep(150 * time.Millisecond)
|
||||
_, err = c.GetValue("expires")
|
||||
if err == nil {
|
||||
log.Panicf("found expired element")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user