Use channel instead of context to handle shutdown

This commit is contained in:
ionutboangiu
2024-12-12 20:27:23 +02:00
committed by Dan Christian Bogos
parent d9359a4005
commit c8a3ebe5e8
50 changed files with 281 additions and 333 deletions

View File

@@ -60,8 +60,8 @@ func TestCoreSSleep(t *testing.T) {
func TestCoreSShutdown(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
caps := engine.NewCaps(2, utils.MetaTopUp)
var closed bool
coreService := cores.NewCoreService(cfg, caps, nil, make(chan struct{}), nil, func() { closed = true })
shutdown := make(chan struct{})
coreService := cores.NewCoreService(cfg, caps, nil, make(chan struct{}), nil, shutdown)
cS := NewCoreSv1(coreService)
arg := &utils.CGREvent{}
var reply string
@@ -70,8 +70,10 @@ func TestCoreSShutdown(t *testing.T) {
} else if reply != "OK" {
t.Errorf("Expected OK, received %+v", reply)
}
if !closed {
t.Error("Did not stop the engine")
select {
case <-shutdown:
default:
t.Error("engine did not shut down")
}
}