diff --git a/services/actions_it_test.go b/services/actions_it_test.go new file mode 100644 index 000000000..962b97398 --- /dev/null +++ b/services/actions_it_test.go @@ -0,0 +1,85 @@ +// +build integration + +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ +package services + +import ( + "reflect" + "sync" + "testing" + + "github.com/cgrates/cgrates/actions" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/cores" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" + "github.com/cgrates/rpcclient" +) + +//TestNewActionService for cover testing +func TestActionSCoverage(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + utils.Logger, _ = utils.Newlogger(utils.MetaSysLog, cfg.GeneralCfg().NodeID) + utils.Logger.SetLogLevel(7) + shdChan := utils.NewSyncedChan() + chS := engine.NewCacheS(cfg, nil, nil) + filterSChan := make(chan *engine.FilterS, 1) + filterSChan <- nil + close(chS.GetPrecacheChannel(utils.CacheActionProfiles)) + close(chS.GetPrecacheChannel(utils.CacheActionProfilesFilterIndexes)) + server := cores.NewServer(nil) + srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)} + db := NewDataDBService(cfg, nil, srvDep) + actRPC := make(chan rpcclient.ClientConnector, 1) + anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, make(chan rpcclient.ClientConnector, 1), srvDep) + actS := NewActionService(cfg, db, + chS, filterSChan, server, actRPC, + anz, srvDep) + if actS == nil { + t.Errorf("\nExpecting ,\n Received <%+v>", utils.ToJSON(actS)) + } + actS2 := &ActionService{ + cfg: cfg, + dm: db, + cacheS: chS, + filterSChan: filterSChan, + server: server, + rldChan: make(chan struct{}), + connChan: actRPC, + anz: anz, + srvDep: srvDep, + } + if actS2.IsRunning() { + t.Errorf("Expected service to be down") + } + actS2.acts = actions.NewActionS(cfg, &engine.FilterS{}, &engine.DataManager{}) + if !actS2.IsRunning() { + t.Errorf("Expected service to be running") + } + serviceName := actS2.ServiceName() + if !reflect.DeepEqual(serviceName, utils.ActionS) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ActionS, serviceName) + } + shouldRun := actS2.ShouldRun() + if !reflect.DeepEqual(shouldRun, false) { + t.Errorf("\nExpecting ,\n Received <%+v>", shouldRun) + } + +} diff --git a/services/analyzers_it_test.go b/services/analyzers_it_test.go new file mode 100644 index 000000000..79f93bcd9 --- /dev/null +++ b/services/analyzers_it_test.go @@ -0,0 +1,82 @@ +// +build integration + +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ +package services + +import ( + "reflect" + "sync" + "testing" + + "github.com/cgrates/cgrates/analyzers" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/cores" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" + "github.com/cgrates/rpcclient" +) + +//TestNewActionService for cover testing +func TestNewAnalyzerCoverage(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + utils.Logger, _ = utils.Newlogger(utils.MetaSysLog, cfg.GeneralCfg().NodeID) + utils.Logger.SetLogLevel(7) + shdChan := utils.NewSyncedChan() + filterSChan := make(chan *engine.FilterS, 1) + filterSChan <- nil + server := cores.NewServer(nil) + srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)} + connChan := make(chan rpcclient.ClientConnector, 1) + anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, connChan, srvDep) + if anz == nil { + t.Errorf("\nExpecting ,\n Received <%+v>", utils.ToJSON(anz)) + } + anz2 := &AnalyzerService{ + connChan: connChan, + cfg: cfg, + server: server, + filterSChan: filterSChan, + shdChan: shdChan, + srvDep: srvDep, + } + if anz2.IsRunning() { + t.Errorf("Expected service to be down") + } + anz2.anz = &analyzers.AnalyzerService{} + if !anz2.IsRunning() { + t.Errorf("Expected service to be running") + } + err := anz2.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } + serviceName := anz2.ServiceName() + if !reflect.DeepEqual(serviceName, utils.AnalyzerS) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.AnalyzerS, serviceName) + } + shouldRun := anz2.ShouldRun() + if !reflect.DeepEqual(shouldRun, false) { + t.Errorf("\nExpecting ,\n Received <%+v>", shouldRun) + } + getAnalyzerS := anz2.GetAnalyzerS() + if !reflect.DeepEqual(anz2.anz, getAnalyzerS) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(anz2.anz), utils.ToJSON(getAnalyzerS)) + } +} diff --git a/services/apiers_it_test.go b/services/apiers_it_test.go index a727fab5c..a668831ad 100644 --- a/services/apiers_it_test.go +++ b/services/apiers_it_test.go @@ -21,10 +21,13 @@ package services import ( "path" + "reflect" "sync" "testing" "time" + v1 "github.com/cgrates/cgrates/apier/v1" + "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/cores" "github.com/cgrates/cgrates/engine" @@ -102,6 +105,27 @@ func TestApiersReload(t *testing.T) { if !stordb.IsRunning() { t.Errorf("Expected service to be running") } + err := apiSv1.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err2 := apiSv2.Start() + if err2 == nil || err2 != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err2) + } + err = apiSv1.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } + err2 = apiSv2.Reload() + if err2 != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err2) + } + expected := &v1.APIerSv1{} + getAPIerSv1 := apiSv1.GetAPIerSv1() + if reflect.DeepEqual(expected, getAPIerSv1) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", expected, utils.ToJSON(getAPIerSv1)) + } cfg.ApierCfg().Enabled = false cfg.GetReloadChan(config.ApierS) <- struct{}{} time.Sleep(100 * time.Millisecond) diff --git a/services/asteriskagent_it_test.go b/services/asteriskagent_it_test.go index 4d5563c19..2393626ee 100644 --- a/services/asteriskagent_it_test.go +++ b/services/asteriskagent_it_test.go @@ -78,6 +78,10 @@ func TestAsteriskAgentReload(t *testing.T) { if !srv.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } cfg.AsteriskAgentCfg().Enabled = false cfg.GetReloadChan(config.AsteriskAgentJSN) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/attributes.go b/services/attributes.go index d3e723283..9afe9a980 100644 --- a/services/attributes.go +++ b/services/attributes.go @@ -65,7 +65,7 @@ type AttributeService struct { srvDep map[string]*sync.WaitGroup } -// Start should handle the sercive start +// Start should handle the service start func (attrS *AttributeService) Start() (err error) { if attrS.IsRunning() { return utils.ErrServiceAlreadyRunning diff --git a/services/attributes_it_test.go b/services/attributes_it_test.go index cc05173ff..a564b06cb 100644 --- a/services/attributes_it_test.go +++ b/services/attributes_it_test.go @@ -90,12 +90,23 @@ func TestAttributeSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := attrS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = attrS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.AttributeSCfg().Enabled = false cfg.GetReloadChan(config.ATTRIBUTE_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) + if attrS.IsRunning() { t.Errorf("Expected service to be down") } + shdChan.CloseOnce() time.Sleep(10 * time.Millisecond) + } diff --git a/services/cdrs_it_test.go b/services/cdrs_it_test.go index dc921e652..094d14c03 100644 --- a/services/cdrs_it_test.go +++ b/services/cdrs_it_test.go @@ -90,6 +90,7 @@ func TestCdrsReload(t *testing.T) { if stordb.IsRunning() { t.Errorf("Expected service to be down") } + cfg.RalsCfg().Enabled = true var reply string if err := cfg.V1ReloadConfig(&config.ReloadArgs{ @@ -115,6 +116,14 @@ func TestCdrsReload(t *testing.T) { if !stordb.IsRunning() { t.Errorf("Expected service to be running") } + err := cdrS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = cdrS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.CdrsCfg().Enabled = false cfg.GetReloadChan(config.CDRS_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/chargers_it_test.go b/services/chargers_it_test.go index 29eae2e25..4bc0786cd 100644 --- a/services/chargers_it_test.go +++ b/services/chargers_it_test.go @@ -85,6 +85,14 @@ func TestChargerSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := chrS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = chrS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.ChargerSCfg().Enabled = false cfg.GetReloadChan(config.ChargerSCfgJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/cores_it_test.go b/services/cores_it_test.go new file mode 100644 index 000000000..090bfdaf6 --- /dev/null +++ b/services/cores_it_test.go @@ -0,0 +1,20 @@ +// +build integration + +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ +package services diff --git a/services/diameteragent_it_test.go b/services/diameteragent_it_test.go index e899814c4..dc6b22fa3 100644 --- a/services/diameteragent_it_test.go +++ b/services/diameteragent_it_test.go @@ -78,6 +78,14 @@ func TestDiameterAgentReload(t *testing.T) { if !srv.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.DiameterAgentCfg().Enabled = false cfg.GetReloadChan(config.DA_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/dispatchers_it_test.go b/services/dispatchers_it_test.go index db60bee32..a5e8f435f 100644 --- a/services/dispatchers_it_test.go +++ b/services/dispatchers_it_test.go @@ -88,6 +88,14 @@ func TestDispatcherSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.DispatcherSCfg().Enabled = false cfg.GetReloadChan(config.DispatcherSJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/dnsagent_it_test.go b/services/dnsagent_it_test.go index 3bf33615b..937f14d7c 100644 --- a/services/dnsagent_it_test.go +++ b/services/dnsagent_it_test.go @@ -78,6 +78,14 @@ func TestDNSAgentReload(t *testing.T) { if !srv.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.DNSAgentCfg().Enabled = false cfg.GetReloadChan(config.DNSAgentJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/ees_it_test.go b/services/ees_it_test.go index 559e76108..3c24457cc 100644 --- a/services/ees_it_test.go +++ b/services/ees_it_test.go @@ -96,6 +96,14 @@ func TestEventExporterSReload(t *testing.T) { if !ees.IsRunning() { t.Errorf("Expected service to be running") } + err := ees.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = ees.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.EEsCfg().Enabled = false cfg.GetReloadChan(config.EEsJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/ers_it_test.go b/services/ers_it_test.go index ac798a6ea..eba2eebbd 100644 --- a/services/ers_it_test.go +++ b/services/ers_it_test.go @@ -82,6 +82,14 @@ func TestEventReaderSReload(t *testing.T) { if !attrS.IsRunning() { t.Errorf("Expected service to be running") } + err := attrS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = attrS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.ERsCfg().Enabled = false cfg.GetReloadChan(config.ERsJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/kamailioagent_it_test.go b/services/kamailioagent_it_test.go index 0666827ee..24a84cc0d 100644 --- a/services/kamailioagent_it_test.go +++ b/services/kamailioagent_it_test.go @@ -76,6 +76,7 @@ func TestKamailioAgentReload(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expecting OK ,received %s", reply) } + runtime.Gosched() time.Sleep(10 * time.Millisecond) //need to switch to gorutine // the engine should be stoped as we could not connect to kamailio diff --git a/services/radiusagent_it_test.go b/services/radiusagent_it_test.go index 785c7493d..319d06e5a 100644 --- a/services/radiusagent_it_test.go +++ b/services/radiusagent_it_test.go @@ -78,6 +78,14 @@ func TestRadiusAgentReload(t *testing.T) { if !srv.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.RadiusAgentCfg().Enabled = false cfg.GetReloadChan(config.RA_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/rals_it_test.go b/services/rals_it_test.go index 92ec686c6..b443e5107 100644 --- a/services/rals_it_test.go +++ b/services/rals_it_test.go @@ -110,13 +110,20 @@ func TestRalsReload(t *testing.T) { if !stordb.IsRunning() { t.Errorf("Expected service to be running") } + err := ralS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = ralS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.RalsCfg().Enabled = false cfg.GetReloadChan(config.RALS_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) if ralS.IsRunning() { t.Errorf("Expected service to be down") } - if resp := ralS.GetResponder(); resp.IsRunning() { t.Errorf("Expected service to be down") } diff --git a/services/rates_it_test.go b/services/rates_it_test.go index 666a7ce1d..e2a5c2d8e 100644 --- a/services/rates_it_test.go +++ b/services/rates_it_test.go @@ -74,6 +74,14 @@ func TestRateSReload(t *testing.T) { if !rS.IsRunning() { t.Errorf("Expected service to be running") } + err := rS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = rS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.RateSCfg().Enabled = false cfg.GetReloadChan(config.RateSJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/resources_it_test.go b/services/resources_it_test.go index 4a2acb812..64d5028a1 100644 --- a/services/resources_it_test.go +++ b/services/resources_it_test.go @@ -87,6 +87,14 @@ func TestResourceSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := reS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = reS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.ResourceSCfg().Enabled = false cfg.GetReloadChan(config.RESOURCES_JSON) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/routes_it_test.go b/services/routes_it_test.go index c26ee79a4..249f9b928 100644 --- a/services/routes_it_test.go +++ b/services/routes_it_test.go @@ -85,6 +85,14 @@ func TestSupplierSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := supS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = supS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.RouteSCfg().Enabled = false cfg.GetReloadChan(config.RouteSJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/schedulers_it_test.go b/services/schedulers_it_test.go index 46ed5346e..2d0129cdb 100644 --- a/services/schedulers_it_test.go +++ b/services/schedulers_it_test.go @@ -21,6 +21,7 @@ package services import ( "path" + "reflect" "sync" "testing" "time" @@ -78,6 +79,18 @@ func TestSchedulerSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := schS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = schS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } + getScheduler := schS.GetScheduler() + if !reflect.DeepEqual(schS.schS, getScheduler) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(schS.schS), utils.ToJSON(getScheduler)) + } cfg.SchedulerCfg().Enabled = false cfg.GetReloadChan(config.SCHEDULER_JSN) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/sessions_it_test.go b/services/sessions_it_test.go index a45685878..9b10be355 100644 --- a/services/sessions_it_test.go +++ b/services/sessions_it_test.go @@ -113,6 +113,14 @@ func TestSessionSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.SessionSCfg().Enabled = false cfg.GetReloadChan(config.SessionSJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/sipagent_it_test.go b/services/sipagent_it_test.go index 5912634ac..e22d8a851 100644 --- a/services/sipagent_it_test.go +++ b/services/sipagent_it_test.go @@ -78,6 +78,10 @@ func TestSIPAgentReload(t *testing.T) { if !srv.IsRunning() { t.Errorf("Expected service to be running") } + err := srv.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.SIPAgentCfg().Enabled = false cfg.GetReloadChan(config.SIPAgentJson) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/stats_it_test.go b/services/stats_it_test.go index 1eaf7905f..1070ee05b 100644 --- a/services/stats_it_test.go +++ b/services/stats_it_test.go @@ -87,6 +87,14 @@ func TestStatSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := sS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = sS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.StatSCfg().Enabled = false cfg.GetReloadChan(config.STATS_JSON) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/services/thresholds_it_test.go b/services/thresholds_it_test.go index 518e237d3..ae204ffbc 100644 --- a/services/thresholds_it_test.go +++ b/services/thresholds_it_test.go @@ -81,6 +81,14 @@ func TestThresholdSReload(t *testing.T) { if !db.IsRunning() { t.Errorf("Expected service to be running") } + err := tS.Start() + if err == nil || err != utils.ErrServiceAlreadyRunning { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err) + } + err = tS.Reload() + if err != nil { + t.Errorf("\nExpecting ,\n Received <%+v>", err) + } cfg.ThresholdSCfg().Enabled = false cfg.GetReloadChan(config.THRESHOLDS_JSON) <- struct{}{} time.Sleep(10 * time.Millisecond) diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go index e7264ffbd..3839ffa6e 100644 --- a/servmanager/servmanager.go +++ b/servmanager/servmanager.go @@ -304,7 +304,7 @@ func (srvMngr *ServiceManager) ShutdownServices() { // Service interface that describes what functions should a service implement type Service interface { - // Start should handle the sercive start + // Start should handle the service start Start() error // Reload handles the change of config Reload() error