mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
remove redundant services tests
replaced by TestServiceToggle (general_tests/service_toggle_it_test.go)
This commit is contained in:
committed by
Dan Christian Bogos
parent
487062a708
commit
e92b5fd026
@@ -1,110 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestAccountSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAccounts))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAccountsFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// acctRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// acctS := NewAccountService(cfg, db, css, filterSChan, nil, cls, acctRPC, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(acctS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if acctS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.AccountSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-acctRPC:
|
||||
// acctRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !acctS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := acctS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = acctS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.AccountSCfg().Enabled = false
|
||||
//
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.AccountSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// if acctS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// }
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/accounts"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestAccountSCoverage for cover testing
|
||||
// func TestAccountSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// actRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// actS := NewAccountService(cfg, db,
|
||||
// chS, filterSChan, nil, cls, actRPC,
|
||||
// anz, srvDep)
|
||||
// if actS == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(actS))
|
||||
// }
|
||||
// //initialises an empty chan to call the reload function
|
||||
// testChan := make(chan struct{})
|
||||
// //populates actRPC with something in order to call the close function
|
||||
// actS2 := &AccountService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// rldChan: testChan,
|
||||
// stopChan: make(chan struct{}, 1),
|
||||
// connChan: actRPC,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if actS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// actS2.acts = accounts.NewAccountS(cfg, &engine.FilterS{}, nil, &engine.DataManager{})
|
||||
// if !actS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := actS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.AccountS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.AccountS, serviceName)
|
||||
// }
|
||||
// shouldRun := actS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,109 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestActionSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// close(chS.GetPrecacheChannel(utils.CacheActionProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheActionProfilesFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// actRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// actS := NewActionService(cfg, db, css, filterSChan, nil, cls, actRPC, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(actS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if actS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ActionSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-actRPC:
|
||||
// actRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !actS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := actS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = actS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ActionSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ActionSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// if actS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// }
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/actions"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestActionSCoverage for cover testing
|
||||
// func TestActionSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// actRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// actS := NewActionService(cfg, db,
|
||||
// chS, filterSChan, nil, cls, actRPC,
|
||||
// anz, srvDep)
|
||||
// if actS == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(actS))
|
||||
// }
|
||||
// //initialises an empty chan to call the reload function
|
||||
// testChan := make(chan struct{})
|
||||
// //populates actRPC with something in order to call the close function
|
||||
//
|
||||
// actS2 := &ActionService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// rldChan: testChan,
|
||||
// stopChan: make(chan struct{}, 1),
|
||||
// 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{}, nil)
|
||||
// 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 <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,150 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "os"
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestAnalyzerSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// if err := os.MkdirAll("/tmp/analyzers", 0700); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anzRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, anzRPC, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(anz,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if anz.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "analyzers")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.AnalyzerSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-anzRPC:
|
||||
// anzRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !anz.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := anz.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = anz.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.AnalyzerSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.AnalyzerSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// if anz.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if err := os.RemoveAll("/tmp/analyzers"); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestAnalyzerSReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// if err := os.MkdirAll("/tmp/analyzers", 0700); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anzRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, anzRPC, srvDep)
|
||||
// // anz.stopChan = make(chan struct{})
|
||||
// // anz.start()
|
||||
// // close(anz.stopChan)
|
||||
// // anz.start()
|
||||
// anz.anz = nil
|
||||
// if err := os.RemoveAll("/tmp/analyzers"); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestAnalyzerSReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// if err := os.MkdirAll("/tmp/analyzers_test3", 0700); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// cfg.AnalyzerSCfg().DBPath = "/tmp/analyzers_test3"
|
||||
// err := os.RemoveAll("/tmp/analyzers_test3")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// cfg.AnalyzerSCfg().IndexType = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anzRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, anzRPC, srvDep)
|
||||
// // anz.stopChan = make(chan struct{})
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// anz.Start(ctx, cancel)
|
||||
//
|
||||
// anz.anz = nil
|
||||
// // close(anz.stopChan)
|
||||
//
|
||||
// }
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/analyzers"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestAnalyzerCoverage for cover testing
|
||||
// func TestAnalyzerCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// connChan := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, connChan, srvDep)
|
||||
// if anz == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(anz))
|
||||
// }
|
||||
// anz2 := &AnalyzerService{
|
||||
// RWMutex: sync.RWMutex{},
|
||||
// cfg: cfg,
|
||||
// cls: cls,
|
||||
// filterSChan: filterSChan,
|
||||
// connChan: connChan,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if anz2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var rpcClientCnctr birpc.ClientConnector
|
||||
// getIntrnCdc := anz2.GetInternalCodec(rpcClientCnctr, utils.EmptyString)
|
||||
// if !reflect.DeepEqual(getIntrnCdc, rpcClientCnctr) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(rpcClientCnctr), utils.ToJSON(getIntrnCdc))
|
||||
// }
|
||||
//
|
||||
// anz2.anz, _ = analyzers.NewAnalyzerS(cfg)
|
||||
// if !anz2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// 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 <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// var rpcClientCnctr2 birpc.ClientConnector
|
||||
// getIntrnCdc2 := anz2.GetInternalCodec(rpcClientCnctr2, utils.EmptyString)
|
||||
// expected2 := anz2.anz.NewAnalyzerConnector(nil, utils.MetaInternal, utils.EmptyString, utils.EmptyString)
|
||||
// if !reflect.DeepEqual(getIntrnCdc2, expected2) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expected2), utils.ToJSON(getIntrnCdc2))
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,164 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestAsteriskAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewAsteriskAgent(cfg, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "tutorial_tests", "asterisk_ari", "cgrates", "etc", "cgrates")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.AsteriskAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// srvReload := srv.Reload(ctx, cancel)
|
||||
// if srvReload != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", srvReload)
|
||||
// }
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// cfg.AsteriskAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.AsteriskAgentJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestAsteriskAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewAsteriskAgent(cfg, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "tutorial_tests", "asterisk_ari", "cgrates", "etc", "cgrates")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.AsteriskAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// srvReload := srv.Reload(ctx, cancel)
|
||||
// if srvReload != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", srvReload)
|
||||
// }
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// cfg.AsteriskAgentCfg().AsteriskConns = []*config.AsteriskConnCfg{
|
||||
// {
|
||||
// Alias: "127.0.0.1:8448",
|
||||
// Address: "127.0.0.1:8088",
|
||||
// User: "cgrates",
|
||||
// Password: "CGRateS.org",
|
||||
// ConnectAttempts: 0,
|
||||
// Reconnects: 0,
|
||||
// }}
|
||||
// srvReload = srv.Reload(ctx, cancel)
|
||||
// if srvReload != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", srvReload)
|
||||
// }
|
||||
// cfg.AsteriskAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.AsteriskAgentJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestAsteriskAgentCoverage for cover testing
|
||||
// func TestAsteriskAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewAsteriskAgent(cfg, nil, srvDep)
|
||||
// if srv == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
// }
|
||||
// srv2 := &AsteriskAgent{
|
||||
// RWMutex: sync.RWMutex{},
|
||||
// cfg: cfg,
|
||||
// stopChan: nil,
|
||||
// smas: nil,
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2.smas = []*agents.AsteriskAgent{}
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// astxAgent := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(astxAgent, utils.AsteriskAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.AsteriskAgent, astxAgent)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
|
||||
// }
|
||||
//
|
||||
// srv2.stopChan = make(chan struct{}, 1)
|
||||
// //no error for now
|
||||
// err2 := srv2.Shutdown()
|
||||
// if err2 != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err2)
|
||||
// }
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,111 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestAttributeSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// attrRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// attrS := NewAttributeService(cfg, db,
|
||||
// css, filterSChan, cls, attrRPC,
|
||||
// anz, &DispatcherService{srvsReload: make(map[string]chan struct{})}, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(attrS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if attrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.AttributeSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-attrRPC:
|
||||
// attrRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !attrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := attrS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = attrS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.AttributeSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.AttributeSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// if attrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// }
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestAttributeSCoverage for cover testing
|
||||
// func TestAttributeSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// attrRPC := make(chan birpc.ClientConnector, 1)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// attrS := NewAttributeService(cfg, db, chS, filterSChan, cls, attrRPC, anz, &DispatcherService{srvsReload: map[string]chan struct{}{}}, srvDep)
|
||||
// if attrS == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(attrS))
|
||||
// }
|
||||
// attrS2 := &AttributeService{
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// dspS: &DispatcherService{srvsReload: map[string]chan struct{}{}},
|
||||
// }
|
||||
// if attrS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// attrS2.attrS = &engine.AttributeS{}
|
||||
// if !attrS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// shouldRun := attrS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
|
||||
// }
|
||||
// serviceName := attrS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.AttributeS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.AttributeS, serviceName)
|
||||
// }
|
||||
//
|
||||
// attrS2.connChan <- &testMockClients{}
|
||||
// shutdownErr := attrS2.Shutdown()
|
||||
// if shutdownErr != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", shutdownErr)
|
||||
// }
|
||||
// if attrS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,120 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestCdrsReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
//
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
//
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// cfg.StorDbCfg().Type = utils.MetaInternal
|
||||
// stordb := NewStorDBService(cfg, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chrS := NewChargerService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// cdrsRPC := make(chan birpc.ClientConnector, 1)
|
||||
// cdrS := NewCDRServer(cfg, db, stordb, filterSChan, cls,
|
||||
// cdrsRPC, nil, anz, srvDep)
|
||||
// srvMngr.AddServices(cdrS, chrS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls,
|
||||
// make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if cdrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if stordb.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.CDRsJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-cdrsRPC:
|
||||
// cdrsRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !cdrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !stordb.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// err := cdrS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = cdrS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.CdrsCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.CDRsJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if cdrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/cdrs"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestCdrsCoverage for cover testing
|
||||
// func TestCdrsCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// cdrsRPC := make(chan birpc.ClientConnector, 1)
|
||||
// cfg.StorDbCfg().Type = utils.MetaInternal
|
||||
// stordb := NewStorDBService(cfg, false, srvDep)
|
||||
// cdrS := NewCDRServer(cfg, db, stordb, filterSChan, cls,
|
||||
// cdrsRPC, nil, anz, srvDep)
|
||||
// if cdrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// //populates cdrS2 with something in order to call the close funct
|
||||
// cdrS2 := &CDRService{
|
||||
// RWMutex: sync.RWMutex{},
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// storDB: stordb,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// connMgr: nil,
|
||||
// stopChan: make(chan struct{}, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// cdrS: &cdrs.CDRServer{},
|
||||
// }
|
||||
// cdrS2.connChan <- &testMockClients{}
|
||||
// cdrS2.stopChan <- struct{}{}
|
||||
// if !cdrS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// serviceName := cdrS2.ServiceName()
|
||||
// if serviceName != utils.CDRServer {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.AdminS, serviceName)
|
||||
// }
|
||||
// shouldRun := cdrS.ShouldRun()
|
||||
// if shouldRun != false {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
|
||||
// }
|
||||
//
|
||||
// shutdownApi1 := cdrS2.Shutdown()
|
||||
// if shutdownApi1 != nil {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", nil, shutdownApi1)
|
||||
// }
|
||||
//
|
||||
// if cdrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,107 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestChargerSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// attrS := NewAttributeService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), anz, &DispatcherService{srvsReload: make(map[string]chan struct{})}, srvDep)
|
||||
// chrS := NewChargerService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(attrS, chrS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls,
|
||||
// make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if chrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ChargerSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !chrS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := chrS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = chrS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ChargerSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ChargerSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if chrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestChargerSCoverage for cover testing
|
||||
// func TestChargerSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// chrS1 := NewChargerService(cfg, db, chS,
|
||||
// filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// if chrS1.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// chrS := &ChargerService{
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// connMgr: nil,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if chrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// chrS.chrS = &engine.ChargerS{}
|
||||
// if !chrS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := chrS.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.ChargerS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ChargerS, serviceName)
|
||||
// }
|
||||
// shouldRun := chrS.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// chrS.connChan = make(chan birpc.ClientConnector, 1)
|
||||
// chrS.connChan <- &testMockClients{}
|
||||
// shutErr := chrS.Shutdown()
|
||||
// if shutErr != nil {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", nil, shutErr)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,100 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestCoreSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// coreRPC := make(chan birpc.ClientConnector, 1)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// caps := engine.NewCaps(1, "test_caps")
|
||||
// coreS := NewCoreService(cfg, caps, cls, coreRPC, anz, nil, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(coreS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if coreS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "caps_queue")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.CoreSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// select {
|
||||
// case d := <-coreRPC:
|
||||
// coreRPC <- d
|
||||
// case <-time.After(time.Second):
|
||||
// t.Fatal("It took to long to reload the cache")
|
||||
// }
|
||||
// if !coreS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// err := coreS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = coreS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// err = coreS.Shutdown()
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.CoreSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if !coreS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// }
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/cores"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestCoreSCoverage for cover testing
|
||||
// func TestCoreSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// caps := engine.NewCaps(1, "test_caps")
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// internalCoreSChan := make(chan birpc.ClientConnector, 1)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewCoreService(cfg, caps, cls, internalCoreSChan, anz, nil, nil, srvDep)
|
||||
// if srv == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv.cS = &cores.CoreS{}
|
||||
// if !srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.CoreS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.CoreS, serviceName)
|
||||
// }
|
||||
// shouldRun := srv.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, true) {
|
||||
// t.Errorf("\nExpecting <true>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// //populates connChan with something in order to call the shutdown function
|
||||
// srv.connChan <- &testMockClients{}
|
||||
// srv.stopChan = make(chan struct{})
|
||||
// // srv.csCh = make(chan *cores.CoreService, 1)
|
||||
// srv.csCh <- nil
|
||||
// getShut := srv.Shutdown()
|
||||
// if getShut != nil {
|
||||
// t.Errorf("\nExpecting not <nil>,\n Received <%+v>", getShut)
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,487 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestDataDBReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srvMngr.AddServices(NewAttributeService(cfg, db,
|
||||
// css, filterSChan, cls, make(chan birpc.ClientConnector, 1), anz, &DispatcherService{srvsReload: make(map[string]chan struct{})}, srvDep),
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.DataDBJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// oldcfg := &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {Limit: -1},
|
||||
// utils.MetaActions: {Limit: -1},
|
||||
// utils.MetaResourceProfile: {Limit: -1},
|
||||
// utils.MetaStatQueues: {Limit: -1},
|
||||
// utils.MetaResources: {Limit: -1},
|
||||
// utils.MetaStatQueueProfiles: {Limit: -1},
|
||||
// utils.MetaThresholds: {Limit: -1},
|
||||
// utils.MetaThresholdProfiles: {Limit: -1},
|
||||
// utils.MetaFilters: {Limit: -1},
|
||||
// utils.MetaRouteProfiles: {Limit: -1},
|
||||
// utils.MetaAttributeProfiles: {Limit: -1},
|
||||
// utils.MetaDispatcherHosts: {Limit: -1},
|
||||
// utils.MetaChargerProfiles: {Limit: -1},
|
||||
// utils.MetaDispatcherProfiles: {Limit: -1},
|
||||
// utils.MetaLoadIDs: {Limit: -1},
|
||||
// utils.MetaRateProfiles: {Limit: -1},
|
||||
// utils.MetaActionProfiles: {Limit: -1},
|
||||
//
|
||||
// utils.CacheResourceFilterIndexes: {Limit: -1},
|
||||
// utils.CacheStatFilterIndexes: {Limit: -1},
|
||||
// utils.CacheThresholdFilterIndexes: {Limit: -1},
|
||||
// utils.CacheRouteFilterIndexes: {Limit: -1},
|
||||
// utils.CacheAttributeFilterIndexes: {Limit: -1},
|
||||
// utils.CacheChargerFilterIndexes: {Limit: -1},
|
||||
// utils.CacheDispatcherFilterIndexes: {Limit: -1},
|
||||
// utils.CacheRateProfilesFilterIndexes: {Limit: -1},
|
||||
// utils.CacheActionProfilesFilterIndexes: {Limit: -1},
|
||||
// utils.CacheAccountsFilterIndexes: {Limit: -1},
|
||||
// utils.CacheVersions: {Limit: -1},
|
||||
// utils.CacheReverseFilterIndexes: {Limit: -1},
|
||||
// utils.CacheRateFilterIndexes: {Limit: -1},
|
||||
// },
|
||||
// }
|
||||
// if !reflect.DeepEqual(oldcfg, db.oldDBCfg) {
|
||||
// t.Errorf("Expected %s \n received:%s", utils.ToJSON(oldcfg), utils.ToJSON(db.oldDBCfg))
|
||||
// }
|
||||
//
|
||||
// err := db.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// // cfg.AttributeSCfg().Enabled = false
|
||||
// // cfg.GetReloadChan() <- config.SectionToService[config.DataDBJSON]
|
||||
// // runtime.Gosched()
|
||||
// // time.Sleep(10 * time.Millisecond)
|
||||
// // if db.IsRunning() {
|
||||
// // t.Errorf("Expected service to be down")
|
||||
// // }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDataDBReloadBadType(t *testing.T) {
|
||||
// cfg, err := config.NewCGRConfigFromPath(context.Background(), path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"))
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// dbConn, err := engine.NewDataDBConn(cfg.DataDbCfg().Type,
|
||||
// cfg.DataDbCfg().Host, cfg.DataDbCfg().Port,
|
||||
// cfg.DataDbCfg().Name, cfg.DataDbCfg().User,
|
||||
// cfg.DataDbCfg().Password, cfg.GeneralCfg().DBDataEncoding,
|
||||
// cfg.DataDbCfg().Opts, cfg.DataDbCfg().Items)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer func() {
|
||||
// dbConn.Flush("")
|
||||
// dbConn.Close()
|
||||
// }()
|
||||
//
|
||||
// err = dbConn.SetVersions(engine.Versions{
|
||||
// utils.Stats: 4,
|
||||
// utils.Accounts: 3,
|
||||
// utils.Actions: 2,
|
||||
// utils.Thresholds: 4,
|
||||
// utils.Routes: 2,
|
||||
// // old version for Attributes
|
||||
// utils.Attributes: 5,
|
||||
// utils.RQF: 5,
|
||||
// utils.Resource: 1,
|
||||
// utils.Subscribers: 1,
|
||||
// utils.Chargers: 2,
|
||||
// utils.Dispatchers: 2,
|
||||
// utils.LoadIDsVrs: 1,
|
||||
// utils.RateProfiles: 1,
|
||||
// utils.ActionProfiles: 1,
|
||||
// }, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// db.oldDBCfg = &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {},
|
||||
// utils.MetaActions: {},
|
||||
// utils.MetaCronExp: {},
|
||||
// utils.MetaResourceProfile: {},
|
||||
// utils.MetaStatQueues: {},
|
||||
// utils.MetaResources: {},
|
||||
// utils.MetaStatQueueProfiles: {},
|
||||
// utils.MetaThresholds: {},
|
||||
// utils.MetaThresholdProfiles: {},
|
||||
// utils.MetaFilters: {},
|
||||
// utils.MetaRouteProfiles: {},
|
||||
// utils.MetaAttributeProfiles: {},
|
||||
// utils.MetaDispatcherHosts: {},
|
||||
// utils.MetaChargerProfiles: {},
|
||||
// utils.MetaDispatcherProfiles: {},
|
||||
// utils.MetaLoadIDs: {},
|
||||
// utils.MetaRateProfiles: {},
|
||||
// utils.MetaActionProfiles: {},
|
||||
// },
|
||||
// }
|
||||
// cfg.DataDbCfg().Type = "dbtype"
|
||||
// db.dm = nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err = db.Reload(ctx, cancel)
|
||||
// if err == nil || err.Error() != "unsupported db_type <dbtype>" {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDataDBReloadErrorMarsheler(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.GeneralCfg().DBDataEncoding = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
//
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// db.oldDBCfg = &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {},
|
||||
// utils.MetaActions: {},
|
||||
// utils.MetaCronExp: {},
|
||||
// utils.MetaResourceProfile: {},
|
||||
// utils.MetaStatQueues: {},
|
||||
// utils.MetaResources: {},
|
||||
// utils.MetaStatQueueProfiles: {},
|
||||
// utils.MetaThresholds: {},
|
||||
// utils.MetaThresholdProfiles: {},
|
||||
// utils.MetaFilters: {},
|
||||
// utils.MetaRouteProfiles: {},
|
||||
// utils.MetaAttributeProfiles: {},
|
||||
// utils.MetaDispatcherHosts: {},
|
||||
// utils.MetaChargerProfiles: {},
|
||||
// utils.MetaDispatcherProfiles: {},
|
||||
// utils.MetaLoadIDs: {},
|
||||
// utils.MetaRateProfiles: {},
|
||||
// utils.MetaActionProfiles: {},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := db.Reload(ctx, cancel)
|
||||
// if err == nil || err.Error() != "Unsupported marshaler: " {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDataDBStartVersion(t *testing.T) {
|
||||
// cfg, err := config.NewCGRConfigFromPath(context.Background(), path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"))
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// dbConn, err := engine.NewDataDBConn(cfg.DataDbCfg().Type,
|
||||
// cfg.DataDbCfg().Host, cfg.DataDbCfg().Port,
|
||||
// cfg.DataDbCfg().Name, cfg.DataDbCfg().User,
|
||||
// cfg.DataDbCfg().Password, cfg.GeneralCfg().DBDataEncoding,
|
||||
// cfg.DataDbCfg().Opts, cfg.DataDbCfg().Items)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer func() {
|
||||
// dbConn.Flush("")
|
||||
// dbConn.Close()
|
||||
// }()
|
||||
// err = dbConn.SetVersions(engine.Versions{
|
||||
// utils.Stats: 4,
|
||||
// utils.Accounts: 3,
|
||||
// utils.Actions: 2,
|
||||
// utils.Thresholds: 4,
|
||||
// utils.Routes: 2,
|
||||
// // old version for Attributes
|
||||
// utils.Attributes: 5,
|
||||
// utils.RQF: 5,
|
||||
// utils.Resource: 1,
|
||||
// utils.Subscribers: 1,
|
||||
// utils.Chargers: 2,
|
||||
// utils.Dispatchers: 2,
|
||||
// utils.LoadIDsVrs: 1,
|
||||
// utils.RateProfiles: 1,
|
||||
// utils.ActionProfiles: 1,
|
||||
// }, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err = db.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*attributes>" {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*attributes>", err)
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDataDBReloadCastError(t *testing.T) {
|
||||
// cfg, err := config.NewCGRConfigFromPath(context.Background(), path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"))
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// dbConn, err := engine.NewDataDBConn(cfg.DataDbCfg().Type,
|
||||
// cfg.DataDbCfg().Host, cfg.DataDbCfg().Port,
|
||||
// cfg.DataDbCfg().Name, cfg.DataDbCfg().User,
|
||||
// cfg.DataDbCfg().Password, cfg.GeneralCfg().DBDataEncoding,
|
||||
// cfg.DataDbCfg().Opts, cfg.DataDbCfg().Items)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer func() {
|
||||
// dbConn.Flush("")
|
||||
// dbConn.Close()
|
||||
// }()
|
||||
//
|
||||
// err = dbConn.SetVersions(engine.Versions{
|
||||
// utils.Stats: 4,
|
||||
// utils.Accounts: 3,
|
||||
// utils.Actions: 2,
|
||||
// utils.Thresholds: 4,
|
||||
// utils.Routes: 2,
|
||||
// // old version for Attributes
|
||||
// utils.Attributes: 5,
|
||||
// utils.RQF: 5,
|
||||
// utils.Resource: 1,
|
||||
// utils.Subscribers: 1,
|
||||
// utils.Chargers: 2,
|
||||
// utils.Dispatchers: 2,
|
||||
// utils.LoadIDsVrs: 1,
|
||||
// utils.RateProfiles: 1,
|
||||
// utils.ActionProfiles: 1,
|
||||
// }, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// db.oldDBCfg = &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {},
|
||||
// utils.MetaActions: {},
|
||||
// utils.MetaCronExp: {},
|
||||
// utils.MetaResourceProfile: {},
|
||||
// utils.MetaStatQueues: {},
|
||||
// utils.MetaResources: {},
|
||||
// utils.MetaStatQueueProfiles: {},
|
||||
// utils.MetaThresholds: {},
|
||||
// utils.MetaThresholdProfiles: {},
|
||||
// utils.MetaFilters: {},
|
||||
// utils.MetaRouteProfiles: {},
|
||||
// utils.MetaAttributeProfiles: {},
|
||||
// utils.MetaDispatcherHosts: {},
|
||||
// utils.MetaChargerProfiles: {},
|
||||
// utils.MetaDispatcherProfiles: {},
|
||||
// utils.MetaLoadIDs: {},
|
||||
// utils.MetaRateProfiles: {},
|
||||
// utils.MetaActionProfiles: {},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// db.dm = nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err = db.Reload(ctx, cancel)
|
||||
// if err == nil || err.Error() != "can't conver DataDB of type mongo to MongoStorage" {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDataDBStartAttributeSCfgErr(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// cfg.DataDbCfg().Type = "badtype"
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := db.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "unsupported db_type <badtype>" {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", "unsupported db_type <badtype>", err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestDataDBReloadError(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// cfg.GeneralCfg().DBDataEncoding = utils.JSON
|
||||
// db.oldDBCfg = &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {},
|
||||
// utils.MetaActions: {},
|
||||
// utils.MetaCronExp: {},
|
||||
// utils.MetaResourceProfile: {},
|
||||
// utils.MetaStatQueues: {},
|
||||
// utils.MetaResources: {},
|
||||
// utils.MetaStatQueueProfiles: {},
|
||||
// utils.MetaThresholds: {},
|
||||
// utils.MetaThresholdProfiles: {},
|
||||
// utils.MetaFilters: {},
|
||||
// utils.MetaRouteProfiles: {},
|
||||
// utils.MetaAttributeProfiles: {},
|
||||
// utils.MetaDispatcherHosts: {},
|
||||
// utils.MetaChargerProfiles: {},
|
||||
// utils.MetaDispatcherProfiles: {},
|
||||
// utils.MetaLoadIDs: {},
|
||||
// utils.MetaRateProfiles: {},
|
||||
// utils.MetaActionProfiles: {},
|
||||
// },
|
||||
// }
|
||||
// data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
|
||||
// db.dm = engine.NewDataManager(data, nil, nil)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := db.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestDataDBCoverage for cover testing
|
||||
// func TestDataDBCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// //chS := engine.NewCacheS(cfg, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, cM, false, srvDep)
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// //populates dataDb with something in order to call the close function
|
||||
// dataDb := new(engine.RedisStorage)
|
||||
// db.dm = engine.NewDataManager(dataDb,
|
||||
// &config.CacheCfg{}, nil)
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// oldcfg := &config.DataDbCfg{
|
||||
// Type: utils.MetaMongo,
|
||||
// Host: "127.0.0.1",
|
||||
// Port: "27017",
|
||||
// Name: "10",
|
||||
// User: "cgrates",
|
||||
// Opts: &config.DataDBOpts{
|
||||
// MongoQueryTimeout: 10 * time.Second,
|
||||
// RedisClusterSync: 5 * time.Second,
|
||||
// },
|
||||
// RmtConns: []string{},
|
||||
// RplConns: []string{},
|
||||
// Items: map[string]*config.ItemOpts{
|
||||
// utils.MetaAccounts: {},
|
||||
// utils.MetaActions: {},
|
||||
// utils.MetaCronExp: {},
|
||||
// utils.MetaResourceProfile: {},
|
||||
// utils.MetaStatQueues: {},
|
||||
// utils.MetaResources: {},
|
||||
// utils.MetaStatQueueProfiles: {},
|
||||
// utils.MetaThresholds: {},
|
||||
// utils.MetaThresholdProfiles: {},
|
||||
// utils.MetaFilters: {},
|
||||
// utils.MetaRouteProfiles: {},
|
||||
// utils.MetaAttributeProfiles: {},
|
||||
// utils.MetaDispatcherHosts: {},
|
||||
// utils.MetaChargerProfiles: {},
|
||||
// utils.MetaDispatcherProfiles: {},
|
||||
// utils.MetaLoadIDs: {},
|
||||
// utils.MetaRateProfiles: {},
|
||||
// utils.MetaActionProfiles: {},
|
||||
// },
|
||||
// }
|
||||
// db.oldDBCfg = oldcfg
|
||||
// serviceName := db.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.DataDB) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.DataDB, serviceName)
|
||||
// }
|
||||
// if shouldRun := db.ShouldRun(); !shouldRun {
|
||||
// t.Errorf("\nExpecting <true>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,138 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestDiameterAgentReload1(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewDiameterAgent(cfg, filterSChan, nil, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "diamagent_mysql")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.DiameterAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
//
|
||||
// cfg.DiameterAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.DiameterAgentJSON]
|
||||
// srv.(*DiameterAgent).lnet = "bad_lnet_test"
|
||||
// err2 := srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err2)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestDiameterAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDiameterAgent(cfg, filterSChan, nil, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cfg.DiameterAgentCfg().Enabled = false
|
||||
// srv.(*DiameterAgent).stopChan = make(chan struct{}, 1)
|
||||
// srv.Shutdown()
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestDiameterAgentReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDiameterAgent(cfg, filterSChan, nil, nil, srvDep)
|
||||
//
|
||||
// cfg.DiameterAgentCfg().ListenNet = "bad"
|
||||
// cfg.DiameterAgentCfg().DictionariesPath = ""
|
||||
//
|
||||
// err := srv.(*DiameterAgent).start(nil, func() {}, nil)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// cfg.DiameterAgentCfg().Enabled = false
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,261 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestDNSAgentStartReloadShut(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// cfg.DNSAgentCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Listeners = []config.Listener{
|
||||
// {
|
||||
// Network: "udp",
|
||||
// Address: ":2055",
|
||||
// },
|
||||
// {
|
||||
// Network: "tcp",
|
||||
// Address: ":2056",
|
||||
// },
|
||||
// }
|
||||
// utils.Logger, _ = utils.NewSysLogger(cfg.GeneralCfg().NodeID, 7)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// engine.NewConnManager(cfg)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if err := srv.Shutdown(); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if err := srv.Start(ctx, cancel); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if err := srv.Reload(ctx, cancel); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if err := srv.Shutdown(); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("service is still running")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestDNSAgentReloadFirst(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// utils.Logger, _ = utils.NewLogger(utils.MetaSysLog, cfg.GeneralCfg().NodeID, 7)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// time.Sleep(100 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "dnsagent_reload")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.DNSAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
//
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// cfg.DNSAgentCfg().Enabled = false
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.DNSAgentJSON]
|
||||
// time.Sleep(100 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestDNSAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// cfg.DNSAgentCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Listeners[0].Network = "test"
|
||||
// cfg.DNSAgentCfg().Listeners[0].Address = "test"
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// agentSrv, err := agents.NewDNSAgent(cfg, nil, nil)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// dnsSrv := srv.(*DNSAgent)
|
||||
// dnsSrv.dns = agentSrv
|
||||
// err = dnsSrv.listenAndServe(make(chan struct{}), func() {})
|
||||
// if err == nil || err.Error() != "dns: bad network" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "dns: bad network", err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestDNSAgentReload4(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Listeners[0].Network = "tls"
|
||||
// cfg.TLSCfg().ServerCerificate = "bad_certificate"
|
||||
// cfg.TLSCfg().ServerKey = "bad_key"
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
//
|
||||
// runtime.Gosched()
|
||||
// dnsSrv := srv.(*DNSAgent)
|
||||
// dnsSrv.dns = nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := dnsSrv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "load certificate error <open bad_certificate: no such file or directory>" {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "load certificate error <open bad_certificate: no such file or directory>", err)
|
||||
// }
|
||||
// dnsSrv.dns = nil
|
||||
// }
|
||||
//
|
||||
// func TestDNSAgentReload5(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Enabled = true
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestDNSAgentReload6(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.DNSAgentCfg().Enabled = true
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// cfg.DNSAgentCfg().Listeners[0].Address = "127.0.0.1:0"
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// cfg.DNSAgentCfg().Listeners[0].Network = "tls"
|
||||
// cfg.TLSCfg().ServerCerificate = "bad_certificate"
|
||||
// cfg.TLSCfg().ServerKey = "bad_key"
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err == nil || err.Error() != "load certificate error <open bad_certificate: no such file or directory>" {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "load certificate error <open bad_certificate: no such file or directory>", err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestDNSAgentCoverage for cover testing
|
||||
// func TestDNSAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewDNSAgent(cfg, filterSChan, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// dns, _ := agents.NewDNSAgent(cfg, &engine.FilterS{}, nil)
|
||||
// srv2 := DNSAgent{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// stopChan: make(chan struct{}),
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// dns: dns,
|
||||
// }
|
||||
//
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if serviceName != utils.DNSAgent {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.DNSAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if shouldRun != false {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
|
||||
// }
|
||||
// srv2.Shutdown()
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,143 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "os"
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestEventExporterSReload(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/testCSV", "/tmp/testComposedCSV", "/tmp/testFWV", "/tmp/testCSVMasked",
|
||||
// "/tmp/testCSVfromVirt", "/tmp/testCSVExpTemp"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// attrS := NewAttributeService(cfg, db,
|
||||
// css, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// anz, &DispatcherService{srvsReload: make(map[string]chan struct{})}, srvDep)
|
||||
// ees := NewEventExporterService(cfg, filterSChan, engine.NewConnManager(cfg),
|
||||
// cls, make(chan birpc.ClientConnector, 2), anz, srvDep)
|
||||
// srvMngr.AddServices(ees, attrS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if ees.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// fcTmp := &config.FCTemplate{Tag: "TenantID",
|
||||
// Path: "Tenant",
|
||||
// Type: utils.MetaVariable,
|
||||
// Value: utils.NewRSRParsersMustCompile("~*req.0", utils.InfieldSep),
|
||||
// Mandatory: true,
|
||||
// Layout: time.RFC3339,
|
||||
// }
|
||||
// fcTmp.ComputePath()
|
||||
// cfg.TemplatesCfg()["requiredFields"] = []*config.FCTemplate{fcTmp}
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "ees")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.EEsJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !ees.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// err := ees.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = ees.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.EEsCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.EEsJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if ees.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestEventExporterSReload2(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/testCSV", "/tmp/testComposedCSV", "/tmp/testFWV", "/tmp/testCSVMasked",
|
||||
// "/tmp/testCSVfromVirt", "/tmp/testCSVExpTemp"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// ees := NewEventExporterService(cfg, filterSChan, engine.NewConnManager(cfg),
|
||||
// cls, make(chan birpc.ClientConnector, 2), anz, srvDep)
|
||||
// if ees.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/ees"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestEventExporterSCoverage for cover testing
|
||||
// func TestEventExporterSCoverage(t *testing.T) {
|
||||
//
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.AttributeSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewEventExporterService(cfg, filterSChan, engine.NewConnManager(cfg), cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := &EventExporterService{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// connMgr: engine.NewConnManager(cfg),
|
||||
// cls: cls,
|
||||
// intConnChan: make(chan birpc.ClientConnector, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// eeS: &ees.EeS{},
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if serviceName != utils.EEs {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.EEs, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if shouldRun != false {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
|
||||
// }
|
||||
// srv2.intConnChan <- &testMockClients{}
|
||||
// shutErr := srv2.Shutdown()
|
||||
// if shutErr != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", shutErr)
|
||||
// }
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,144 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "os"
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/ers"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestEventReaderSReload(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// intERsConn := make(chan birpc.ClientConnector, 1)
|
||||
// erS := NewEventReaderService(cfg, filterSChan, nil, cls, intERsConn, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(erS, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if erS.IsRunning() {
|
||||
// t.Fatal("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "ers_reload", "internal")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ERsJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// if !erS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// runtime.Gosched()
|
||||
// err := erS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// runtime.Gosched()
|
||||
// err = erS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ERsCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ERsJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if erS.IsRunning() {
|
||||
// t.Fatal("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestEventReaderSReload2(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.ERsCfg().Enabled = true
|
||||
// cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
// {
|
||||
// Type: "bad_type",
|
||||
// },
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// erS := NewEventReaderService(cfg, filterSChan, nil, cls, nil, nil, srvDep)
|
||||
// ers := ers.NewERService(cfg, nil, nil)
|
||||
//
|
||||
// runtime.Gosched()
|
||||
// srv := erS.(*EventReaderService)
|
||||
// srv.stopChan = make(chan struct{})
|
||||
// srv.rldChan = make(chan struct{})
|
||||
// err := srv.listenAndServe(ers, srv.stopChan, srv.rldChan, func() {})
|
||||
// if err == nil || err.Error() != "unsupported reader type: <bad_type>" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "unsupported reader type: <bad_type>", err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/ers"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestEventReaderSCoverage for cover testing
|
||||
// func TestEventReaderSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srv := NewEventReaderService(cfg, filterSChan, nil, cls, nil, nil, srvDep)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// srv2 := EventReaderService{
|
||||
// RWMutex: sync.RWMutex{},
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// ers: &ers.ERService{},
|
||||
// rldChan: make(chan struct{}, 1),
|
||||
// stopChan: make(chan struct{}, 1),
|
||||
// connMgr: nil,
|
||||
// cls: cls,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.ERs) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ERs, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// srv2.Shutdown()
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,192 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestFreeSwitchAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "tutorial_tests", "fs_evsock", "cgrates", "etc", "cgrates")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.FreeSWITCHAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
//
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// // the engine should be stopped as we could not connect to freeswitch
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestFreeSwitchAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// srv.(*FreeswitchAgent).fS = &agents.FSsessions{}
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "service already running" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "service already running", err)
|
||||
// }
|
||||
// err = srv.Shutdown()
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
// func TestFreeSwitchAgentReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// srv.(*FreeswitchAgent).fS = &agents.FSsessions{}
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "service already running" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "service already running", err)
|
||||
// }
|
||||
// err = srv.Shutdown()
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestFreeSwitchAgentReload4(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// srv.(*FreeswitchAgent).fS = nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestFreeSwitchAgentReload6(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// agentCfg := &config.FsAgentCfg{
|
||||
// Enabled: true,
|
||||
// SessionSConns: nil,
|
||||
// SubscribePark: true,
|
||||
// CreateCDR: true,
|
||||
// ExtraFields: nil,
|
||||
// LowBalanceAnnFile: "",
|
||||
// EmptyBalanceContext: "",
|
||||
// EmptyBalanceAnnFile: "",
|
||||
// MaxWaitConnection: 0,
|
||||
// EventSocketConns: []*config.FsConnCfg{
|
||||
// {
|
||||
// Address: "",
|
||||
// Password: "",
|
||||
// Reconnects: 0,
|
||||
// Alias: "",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// srv.(*FreeswitchAgent).fS = agents.NewFSsessions(agentCfg, "", nil)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestFreeSwitchAgentCoverage for cover testing
|
||||
// func TestFreeSwitchAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
//
|
||||
// srv := NewFreeswitchAgent(cfg, nil, srvDep)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := FreeswitchAgent{
|
||||
// cfg: cfg,
|
||||
// fS: &agents.FSsessions{},
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.FreeSWITCHAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.FreeSWITCHAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,63 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestGlobalVarsReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewGlobalVarS(cfg, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if !srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpected <nil>, \nReceived <%+v>", err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpected <nil>, \nReceived <%+v>", err)
|
||||
// }
|
||||
//
|
||||
// err2 := srv.ServiceName()
|
||||
// if err2 != utils.GlobalVarS {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.GlobalVarS, err2)
|
||||
// }
|
||||
//
|
||||
// err3 := srv.ShouldRun()
|
||||
// if err3 != true {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", true, err3)
|
||||
// }
|
||||
// err = srv.Shutdown()
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpected <nil>, \nReceived <%+v>", err)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,97 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestHTTPAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewHTTPAgent(cfg, filterSChan, cls, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "httpagent_mysql_test")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.HTTPAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// srvReload := srv.Reload(ctx, cancel)
|
||||
// if srvReload != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", srvReload)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = srv.Shutdown()
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", nil, err)
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestHTTPAgent for cover testing
|
||||
// func TestHTTPAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// srv := NewHTTPAgent(cfg, filterSChan, cls, cM, srvDep)
|
||||
// if srv == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := &HTTPAgent{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// started: true,
|
||||
// connMgr: cM,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.HTTPAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.HTTPAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// shutdownError := srv.Shutdown()
|
||||
// if shutdownError != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", shutdownError)
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,144 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestKamailioAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewKamailioAgent(cfg, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "tutorial_tests", "kamevapi", "cgrates", "etc", "cgrates")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.KamailioAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
//
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// kaCfg := &config.KamAgentCfg{
|
||||
// Enabled: true,
|
||||
// SessionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)},
|
||||
// CreateCdr: true,
|
||||
// EvapiConns: []*config.KamConnCfg{{Address: "127.0.0.1:8448", Reconnects: 10, Alias: "randomAlias"}},
|
||||
// Timezone: "Local",
|
||||
// }
|
||||
//
|
||||
// srv.(*KamailioAgent).kam = agents.NewKamailioAgent(kaCfg, nil, "")
|
||||
//
|
||||
// err := srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// // the engine should be stopped as we could not connect to kamailio
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestKamailioAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewKamailioAgent(cfg, nil, srvDep)
|
||||
// srvKam := &agents.KamailioAgent{}
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// srv.(*KamailioAgent).kam = srvKam
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "service already running" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "service already running", err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestKamailioAgentReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewKamailioAgent(cfg, nil, srvDep)
|
||||
// srvKam := &agents.KamailioAgent{}
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// srv.(*KamailioAgent).kam = srvKam
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "service already running" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "service already running", err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// //TestKamailioAgentCoverage for cover testing
|
||||
//
|
||||
// func TestKamailioAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewKamailioAgent(cfg, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := KamailioAgent{
|
||||
// cfg: cfg,
|
||||
// kam: &agents.KamailioAgent{},
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.KamailioAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.KamailioAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// srv2.Shutdown()
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,195 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "os"
|
||||
// "path"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func testCreateDirs(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/In", "/tmp/Out", "/tmp/LoaderIn", "/tmp/SubpathWithoutMove",
|
||||
// "/tmp/SubpathLoaderWithMove", "/tmp/SubpathOut", "/tmp/templateLoaderIn", "/tmp/templateLoaderOut",
|
||||
// "/tmp/customSepLoaderIn", "/tmp/customSepLoaderOut"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// if err := os.WriteFile(path.Join("/tmp/In", utils.AttributesCsv), []byte(`
|
||||
// #Tenant,ID,FilterIDs,Weights,Blockers,AttributeFilterIDs,AttributeBlockers,Path,Type,Value
|
||||
// cgrates.org,ALS1,*string:~*req.Account:1001;*string:~*opts.*context:con1,;20,;true,*string:~*req.Field1:Initial,;true,*req.Field1,*variable,Sub1
|
||||
// cgrates.org,ALS1,*string:~*opts.*context:con2|con3,,,,*string:~*req.Account:1002;true,*req.Field2,*variable,Sub2
|
||||
// `), 0644); err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestLoaderSReload(t *testing.T) {
|
||||
// testCreateDirs(t)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.TemplatesCfg()["attrTemplateLoader"] = []*config.FCTemplate{
|
||||
// {
|
||||
// Type: utils.MetaVariable,
|
||||
// Path: "*req.Accounts",
|
||||
// Value: utils.NewRSRParsersMustCompile("1001", utils.InfieldSep),
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// conMngr := engine.NewConnManager(cfg)
|
||||
// srv := NewLoaderService(cfg, db, filterSChan,
|
||||
// cls, make(chan birpc.ClientConnector, 1),
|
||||
// conMngr, anz, srvDep)
|
||||
// srvMngr.AddServices(srv, db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
//
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "loaders", "tutinternal")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.LoaderSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if !db.IsRunning() {
|
||||
// t.Fatal("Expected service to be running")
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatal("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// for _, v := range cfg.LoaderCfg() {
|
||||
// v.Enabled = false
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.LoaderSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// testCleanupFiles(t)
|
||||
// }
|
||||
// func testCleanupFiles(t *testing.T) {
|
||||
// for _, dir := range []string{"/tmp/In", "/tmp/Out", "/tmp/LoaderIn", "/tmp/SubpathWithoutMove",
|
||||
// "/tmp/SubpathLoaderWithMove", "/tmp/SubpathOut"} {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestLoaderSReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// for _, ld := range cfg.LoaderCfg() {
|
||||
// ld.Enabled = false
|
||||
// }
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// db.dbchan <- new(engine.DataManager)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewLoaderService(cfg, db, filterSChan,
|
||||
// cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestLoaderSReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// for _, ld := range cfg.LoaderCfg() {
|
||||
// ld.Enabled = false
|
||||
// }
|
||||
// cfg.LoaderCfg()[0].Enabled = true
|
||||
// cfg.LoaderCfg()[0].TpInDir = "/tmp/TestLoaderSReload3"
|
||||
// cfg.LoaderCfg()[0].RunDelay = -1
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// db.dbchan <- new(engine.DataManager)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewLoaderService(cfg, db, filterSChan,
|
||||
// cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "no such file or directory" {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "no such file or directory", err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err == nil || err.Error() != "no such file or directory" {
|
||||
// t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "no such file or directory", err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/loaders"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestLoaderSCoverage for cover testing
|
||||
// func TestLoaderSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// internalLoaderSChan := make(chan birpc.ClientConnector, 1)
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// cfg.LoaderCfg()[0] = &config.LoaderSCfg{
|
||||
// ID: "test_id",
|
||||
// Enabled: true,
|
||||
// Tenant: "",
|
||||
// RunDelay: 0,
|
||||
// LockFilePath: "",
|
||||
// CacheSConns: nil,
|
||||
// FieldSeparator: "",
|
||||
// TpInDir: "",
|
||||
// TpOutDir: "",
|
||||
// Data: nil,
|
||||
// }
|
||||
// srv := NewLoaderService(cfg, db,
|
||||
// filterSChan, cls, internalLoaderSChan,
|
||||
// cM, anz, srvDep)
|
||||
// if srv == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
// }
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv.ldrs = loaders.NewLoaderS(cfg, &engine.DataManager{},
|
||||
// &engine.FilterS{}, nil)
|
||||
// if !srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.LoaderS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.LoaderS, serviceName)
|
||||
// }
|
||||
// if shouldRun := srv.ShouldRun(); !shouldRun {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// if !reflect.DeepEqual(srv.GetLoaderS(), srv.ldrs) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", srv.ldrs, srv.GetLoaderS())
|
||||
// }
|
||||
// srv.stopChan = make(chan struct{}, 1)
|
||||
// srv.connChan <- &testMockClients{}
|
||||
// srv.Shutdown()
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,219 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestRadiusAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewRadiusAgent(cfg, filterSChan, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "radagent_mysql")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.RadiusAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// runtime.Gosched()
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.RadiusAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.RadiusAgentJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestRadiusAgentReload2(t *testing.T) {
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewRadiusAgent(cfg, filterSChan, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "radagent_mysql")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.RadiusAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// castSrv, canCastSrv := srv.(*RadiusAgent)
|
||||
// if !canCastSrv {
|
||||
// t.Fatalf("cannot cast")
|
||||
// }
|
||||
//
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// castSrv.lnet = "test_string"
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.RadiusAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.RadiusAgentJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestRadiusAgentReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.RadiusAgentCfg().ClientDictionaries = map[string]string{
|
||||
// "test": "test",
|
||||
// }
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.RadiusAgentCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// defer func() {
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }()
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewRadiusAgent(cfg, filterSChan, nil, srvDep)
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "stat test: no such file or directory" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "stat test: no such file or directory", err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestRadiusAgentReload4(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.RadiusAgentCfg().Enabled = true
|
||||
// cfg.RadiusAgentCfg().ListenNet = "test"
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewRadiusAgent(cfg, filterSChan, nil, srvDep)
|
||||
// r, err := agents.NewRadiusAgent(cfg, nil, nil)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// rad := srv.(*RadiusAgent)
|
||||
// rad.stopChan = make(chan struct{})
|
||||
// err = rad.listenAndServe(r, func() {})
|
||||
// if err == nil || err.Error() != "unsupported network: <test>" {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", "unsupported network: <test>", err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestLoaderSCoverage for cover testing
|
||||
// func TestRadiusAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewRadiusAgent(cfg, filterSChan, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := RadiusAgent{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// rad: &agents.RadiusAgent{},
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.RadiusAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.RadiusAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// srv2.stopChan = make(chan struct{}, 1)
|
||||
// srv2.Shutdown()
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestNewRankingService(t *testing.T) {
|
||||
// cfg := &config.CGRConfig{}
|
||||
// dm := &DataDBService{}
|
||||
// cacheS := &CacheService{}
|
||||
// filterSChan := make(chan *engine.FilterS)
|
||||
// birpc := make(chan birpc.ClientConnector)
|
||||
// server := &commonlisteners.CommonListenerS{}
|
||||
// connMgr := &engine.ConnManager{}
|
||||
// anz := &AnalyzerService{}
|
||||
// srvDep := make(map[string]*sync.WaitGroup)
|
||||
//
|
||||
// rankingService := NewRankingService(cfg, dm, cacheS, filterSChan, server, birpc, connMgr, anz, srvDep)
|
||||
//
|
||||
// if rankingService == nil {
|
||||
// t.Error("Expected non-nil RankingService, got nil")
|
||||
// }
|
||||
//
|
||||
// if _, ok := rankingService.(*RankingService); !ok {
|
||||
// t.Errorf("Expected type *RankingService, got %T", rankingService)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestRankingServiceName(t *testing.T) {
|
||||
// rankingService := &RankingService{}
|
||||
//
|
||||
// serviceName := rankingService.ServiceName()
|
||||
//
|
||||
// expectedServiceName := utils.RankingS
|
||||
// if serviceName != expectedServiceName {
|
||||
// t.Errorf("Expected service name '%s', but got '%s'", expectedServiceName, serviceName)
|
||||
// }
|
||||
// }
|
||||
@@ -1,97 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestRateSReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheRateProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheRateProfilesFilterIndexes))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheRateFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// rS := NewRateService(cfg, css, filterSChan, db, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// srvMngr.AddServices(rS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if rS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "rates")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.RateSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !rS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := rS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = rS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.RateSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.RateSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if rS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/rates"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestRateSCoverage for cover testing
|
||||
// func TestRateSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// rS := NewRateService(cfg, chS, filterSChan, db, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
//
|
||||
// if rS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// rS2 := RateService{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// dmS: db,
|
||||
// cacheS: chS,
|
||||
// cls: cls,
|
||||
// stopChan: make(chan struct{}),
|
||||
// intConnChan: make(chan birpc.ClientConnector, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// rateS: &rates.RateS{},
|
||||
// }
|
||||
// if !rS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := rS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.RateS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.RateS, serviceName)
|
||||
// }
|
||||
// shouldRun := rS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// rS2.intConnChan <- &testMockClients{}
|
||||
// rS2.Shutdown()
|
||||
// if rS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,137 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "os"
|
||||
// "path/filepath"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// "github.com/cgrates/rpcclient"
|
||||
// )
|
||||
//
|
||||
// func TestDispatcherHReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.RPCConns()["dispConn"] = &config.RPCConn{
|
||||
// Strategy: rpcclient.PoolFirst,
|
||||
// Conns: []*config.RemoteHost{{
|
||||
// Address: "http://127.0.0.1:2080/dispatchers_registrar",
|
||||
// Transport: rpcclient.HTTPjson,
|
||||
// }},
|
||||
// }
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// connMngr := engine.NewConnManager(cfg)
|
||||
// srv := NewRegistrarCService(cfg, cls, connMngr, anz, srvDep)
|
||||
// srvMngr.AddServices(srv,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls,
|
||||
// make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
//
|
||||
// cfgPath := t.TempDir()
|
||||
// filePath := filepath.Join(cfgPath, "cgrates.json")
|
||||
// if err := os.WriteFile(filePath, []byte(`{
|
||||
// "general": {
|
||||
// "node_id": "ALL"
|
||||
// },
|
||||
// "listen": {
|
||||
// "rpc_json": ":6012",
|
||||
// "rpc_gob": ":6013",
|
||||
// "http": ":6080"
|
||||
// },
|
||||
// "rpc_conns": {
|
||||
// "dispConn": {
|
||||
// "strategy": "*first",
|
||||
// "conns": [{
|
||||
// "address": "http://127.0.0.1:2080/registrar",
|
||||
// "transport": "*http_jsonrpc"
|
||||
// }]
|
||||
// }
|
||||
// },
|
||||
// "registrarc": {
|
||||
// "dispatchers": {
|
||||
// "enabled": true,
|
||||
// "registrars_conns": ["dispConn"],
|
||||
// "hosts": [{
|
||||
// "Tenant": "*default",
|
||||
// "ID": "hostB",
|
||||
// "transport": "*json",
|
||||
// "tls": false
|
||||
// }],
|
||||
// "refresh_interval": "1s"
|
||||
// }
|
||||
// }
|
||||
// }`), 0644); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// var reply string
|
||||
// cfg.ConfigPath = cfgPath
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.RegistrarCJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.RegistrarCCfg().Dispatchers.RegistrarSConns = []string{}
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.RegistrarCJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/registrarc"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestDispatcherCoverage for cover testing
|
||||
// func TestDispatcherHCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// cM := engine.NewConnManager(cfg)
|
||||
// srv := NewRegistrarCService(cfg, cls, cM, anz, srvDep)
|
||||
// if srv == nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
// }
|
||||
// srv2 := &RegistrarCService{
|
||||
// cfg: cfg,
|
||||
// server: cls,
|
||||
// connMgr: cM,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2.dspS = ®istrarc.RegistrarCService{}
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.RegistrarC) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.RegistrarC, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// srv2.stopChan = make(chan struct{}, 1)
|
||||
// srv2.dspS = registrarc.NewRegistrarCService(cfg, cM)
|
||||
// shutdownSrv := srv2.Shutdown()
|
||||
// if shutdownSrv != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", shutdownSrv)
|
||||
// }
|
||||
// if srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,109 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestResourceSReload(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.ThresholdSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholds))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdFilterIndexes))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheResourceProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheResources))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheResourceFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// tS := NewThresholdService(cfg, db, css, filterSChan, nil, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// reS := NewResourceService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(tS, reS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if reS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ResourceSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !reS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := reS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = reS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ResourceSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ResourceSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if reS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestResourceSCoverage for cover testing
|
||||
// func TestResourceSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.ThresholdSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// reS := NewResourceService(cfg, db, chS, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
//
|
||||
// if reS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// reS2 := ResourceService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// connMgr: nil,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// reS: &engine.ResourceS{},
|
||||
// }
|
||||
// if !reS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := reS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.ResourceS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ResourceS, serviceName)
|
||||
// }
|
||||
// shouldRun := reS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,104 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestRouteSReload(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheRouteProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheRouteFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// routeS := NewRouteService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(routeS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if routeS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "cluelrn")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.RouteSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !routeS.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
//
|
||||
// err := routeS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = routeS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.RouteSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.RouteSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if routeS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestSupplierSCoverage for cover testing
|
||||
// func TestSupplierSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.StatSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// supS := NewRouteService(cfg, db, chS, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
//
|
||||
// if supS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// supS2 := &RouteService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// connMgr: nil,
|
||||
// routeS: &engine.RouteS{},
|
||||
// // rpc: nil,
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !supS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := supS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.RouteS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.RouteS, serviceName)
|
||||
// }
|
||||
// shouldRun := supS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// supS2.connChan <- &testMockClients{}
|
||||
// supS2.Shutdown()
|
||||
// if supS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// }
|
||||
@@ -1,215 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "io"
|
||||
// "log"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/sessions"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// "github.com/cgrates/rpcclient"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
// log.SetOutput(io.Discard)
|
||||
// }
|
||||
//
|
||||
// func TestSessionSReload1(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ChargerSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaChargers)}
|
||||
// cfg.RPCConns()["cache1"] = &config.RPCConn{
|
||||
// Strategy: rpcclient.PoolFirst,
|
||||
// Conns: []*config.RemoteHost{{
|
||||
// Address: "127.0.0.1:9999",
|
||||
// Transport: utils.MetaGOB,
|
||||
// }},
|
||||
// }
|
||||
// cfg.CacheCfg().ReplicationConns = []string{"cache1"}
|
||||
// cfg.CacheCfg().Partitions[utils.CacheClosedSessions].Limit = 0
|
||||
// cfg.CacheCfg().Partitions[utils.CacheClosedSessions].Replicate = true
|
||||
// temporaryCache := engine.Cache
|
||||
// defer func() {
|
||||
// engine.Cache = temporaryCache
|
||||
// }()
|
||||
// engine.Cache = engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
//
|
||||
// clientConect := make(chan birpc.ClientConnector, 1)
|
||||
// clientConect <- &testMockClients{
|
||||
// calls: func(ctx *context.Context, args, reply any) error {
|
||||
// rply, cancast := reply.(*[]*engine.ChrgSProcessEventReply)
|
||||
// if !cancast {
|
||||
// return fmt.Errorf("can't cast")
|
||||
// }
|
||||
// *rply = []*engine.ChrgSProcessEventReply{
|
||||
// {
|
||||
// ChargerSProfile: "raw",
|
||||
// AlteredFields: []*engine.FieldsAltered{
|
||||
// {
|
||||
// MatchedProfileID: utils.MetaDefault,
|
||||
// Fields: []string{utils.MetaOptsRunID, utils.MetaOpts + utils.NestingSep + utils.MetaChargeID, utils.MetaOpts + utils.NestingSep + utils.MetaSubsys},
|
||||
// },
|
||||
// {
|
||||
// MatchedProfileID: utils.MetaNone,
|
||||
// Fields: []string{"~*req.RunID"},
|
||||
// },
|
||||
// },
|
||||
// CGREvent: args.(*utils.CGREvent),
|
||||
// },
|
||||
// }
|
||||
// return nil
|
||||
// },
|
||||
// }
|
||||
// conMng := engine.NewConnManager(cfg)
|
||||
// conMng.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaChargers), utils.ChargerSv1, clientConect)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, conMng, false, srvDep)
|
||||
// db.dbchan = make(chan *engine.DataManager, 1)
|
||||
// db.dbchan <- nil
|
||||
// srv := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), conMng, anz, srvDep)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatal("Expected service to be running")
|
||||
// }
|
||||
// args := &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "testSSv1ItProcessEventInitiateSession",
|
||||
// Event: map[string]any{
|
||||
// utils.Tenant: "cgrates.org",
|
||||
// utils.ToR: utils.MetaVoice,
|
||||
// utils.OriginID: "testSSv1ItProcessEvent",
|
||||
// utils.RequestType: utils.MetaPostpaid,
|
||||
// utils.AccountField: "1001",
|
||||
// utils.CGRDebitInterval: 10,
|
||||
// utils.Destination: "1002",
|
||||
// utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
|
||||
// utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
|
||||
// utils.Usage: 0,
|
||||
// },
|
||||
// APIOpts: map[string]any{
|
||||
// utils.MetaRunID: utils.MetaDefault,
|
||||
// utils.OptsSesInitiate: true,
|
||||
// utils.MetaThresholds: true,
|
||||
// },
|
||||
// }
|
||||
// var rply sessions.V1InitSessionReply
|
||||
// ss := srv.(*SessionService)
|
||||
// if ss.sm == nil {
|
||||
// t.Fatal("sessions is nil")
|
||||
// }
|
||||
// ss.sm.BiRPCv1InitiateSession(context.Background(), args, &rply)
|
||||
// if err = srv.Shutdown(); err == nil || err != utils.ErrPartiallyExecuted {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrPartiallyExecuted, err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestSessionSReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cfg.CdrsCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerFilterIndexes))
|
||||
//
|
||||
// internalChan := make(chan birpc.ClientConnector, 1)
|
||||
// internalChan <- nil
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
//
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
//
|
||||
// srv.(*SessionService).sm = &sessions.SessionS{}
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("\nExpecting service to be running")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err2 := srv.Start(ctx, cancel)
|
||||
// if err2 != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err2)
|
||||
// }
|
||||
// cfg.SessionSCfg().Enabled = false
|
||||
// err := srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// srv.(*SessionService).sm = nil
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestSessionSReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cfg.CdrsCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheChargerFilterIndexes))
|
||||
//
|
||||
// internalChan := make(chan birpc.ClientConnector, 1)
|
||||
// internalChan <- nil
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
//
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
//
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// err2 := srv.(*SessionService).start(func() {})
|
||||
// if err2 != nil {
|
||||
// t.Fatalf("\nExpected <%+v>, \nReceived <%+v>", nil, err2)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/sessions"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// type testMockClients struct {
|
||||
// calls func(_ *context.Context, _, _ any) error
|
||||
// }
|
||||
//
|
||||
// func (sT *testMockClients) Call(ctx *context.Context, method string, arg, rply any) error {
|
||||
// return sT.calls(ctx, arg, rply)
|
||||
// }
|
||||
//
|
||||
// // TestSessionSCoverage for cover testing
|
||||
// func TestSessionSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.ChargerSCfg().Enabled = true
|
||||
// cfg.CdrsCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// srv := NewSessionService(cfg, db, nil, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := SessionService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cls: cls,
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// connMgr: nil,
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// sm: &sessions.SessionS{},
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.SessionS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.SessionS, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,147 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestSIPAgentReload(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
//
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// sS := NewSessionService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1),
|
||||
// nil, anz, srvDep)
|
||||
// srv := NewSIPAgent(cfg, filterSChan, nil, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(srv, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "sipagent_mysql")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.SIPAgentJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Fatalf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// if !srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be running")
|
||||
// }
|
||||
// srvStart := srv.Start(ctx, cancel)
|
||||
// if srvStart != utils.ErrServiceAlreadyRunning {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, srvStart)
|
||||
// }
|
||||
// err := srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// cfg.SIPAgentCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.SIPAgentJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// func TestSIPAgentReload2(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewSIPAgent(cfg, filterSChan, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// cfg.SIPAgentCfg().RequestProcessors = []*config.RequestProcessor{
|
||||
// {
|
||||
// RequestFields: []*config.FCTemplate{
|
||||
// {
|
||||
// Type: utils.MetaTemplate,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err == nil || err.Error() != "no template with id: <>" {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", "no template with id: <>", err)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestSIPAgentReload3(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewSIPAgent(cfg, filterSChan, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Fatalf("Expected service to be down")
|
||||
// }
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// err := srv.Start(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", nil, err)
|
||||
// }
|
||||
// srv.(*SIPAgent).oldListen = "test"
|
||||
// err = srv.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Fatalf("\nExpecting <%+v>,\n Received <%+v>", nil, err)
|
||||
// }
|
||||
// }
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/cgrates/agents"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestSIPAgentCoverage for cover testing
|
||||
// func TestSIPAgentCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.SessionSCfg().Enabled = true
|
||||
// cfg.SessionSCfg().ListenBijson = ""
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// srv := NewSIPAgent(cfg, filterSChan, nil, srvDep)
|
||||
// if srv.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// srv2 := SIPAgent{
|
||||
// cfg: cfg,
|
||||
// filterSChan: filterSChan,
|
||||
// sip: &agents.SIPAgent{},
|
||||
// connMgr: nil,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !srv2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := srv2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.SIPAgent) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.SIPAgent, serviceName)
|
||||
// }
|
||||
// shouldRun := srv2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -1,109 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestStatSReload(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
//
|
||||
// cfg.ThresholdSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholds))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdFilterIndexes))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheStatQueueProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheStatQueues))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheStatFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// tS := NewThresholdService(cfg, db, css, filterSChan, nil, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// sS := NewStatService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(tS, sS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if sS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.StatSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !sS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := sS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = sS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.StatSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.StatSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if sS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestStatSCoverage for cover testing
|
||||
// func TestStatSCoverage(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// cfg.ThresholdSCfg().Enabled = true
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// sS := NewStatService(cfg, db, chS, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
|
||||
// if sS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// sS2 := StatService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// connMgr: nil,
|
||||
// sts: &engine.StatS{},
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !sS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := sS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.StatS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.StatS, serviceName)
|
||||
// }
|
||||
// shouldRun := sS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,170 +0,0 @@
|
||||
//go:build integration
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
// "runtime"
|
||||
// "sync"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/servmanager"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestThresholdSReload(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholds))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// tS := NewThresholdService(cfg, db, css, filterSChan, nil, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(tS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ThresholdSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// runtime.Gosched()
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// runtime.Gosched()
|
||||
// err := tS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = tS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ThresholdSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ThresholdSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
//
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
// func TestThresholdSReload2(t *testing.T) {
|
||||
// // utils.Logger.SetLogLevel(7)
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// ctx, cancel := context.WithCancel(context.TODO())
|
||||
//
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// shdWg := new(sync.WaitGroup)
|
||||
// chS := engine.NewCacheS(cfg, nil, nil, nil)
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdProfiles))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholds))
|
||||
// close(chS.GetPrecacheChannel(utils.CacheThresholdFilterIndexes))
|
||||
// chSCh := make(chan *engine.CacheS, 1)
|
||||
// chSCh <- chS
|
||||
// css := &CacheService{cacheCh: chSCh}
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// tS := NewThresholdService(cfg, db, css, filterSChan, nil, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// engine.NewConnManager(cfg)
|
||||
// srvMngr.AddServices(tS,
|
||||
// NewLoaderService(cfg, db, filterSChan, cls, make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
|
||||
// srvMngr.StartServices(ctx, cancel)
|
||||
// if tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// if db.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// var reply string
|
||||
// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo")
|
||||
// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
|
||||
// Section: config.ThresholdSJSON,
|
||||
// }, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Expecting OK ,received %s", reply)
|
||||
// }
|
||||
// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// if !tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// if !db.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// err := tS.Start(ctx, cancel)
|
||||
// if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
// }
|
||||
// err = tS.Reload(ctx, cancel)
|
||||
// if err != nil {
|
||||
// t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
// }
|
||||
// cfg.ThresholdSCfg().Enabled = false
|
||||
// cfg.GetReloadChan() <- config.SectionToService[config.ThresholdSJSON]
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// if tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// cancel()
|
||||
// time.Sleep(10 * time.Millisecond)
|
||||
// }
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "reflect"
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// // TestThresholdSCoverage for cover testing
|
||||
// func TestThresholdSCoverage(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// filterSChan := make(chan *engine.FilterS, 1)
|
||||
// filterSChan <- nil
|
||||
// cls := commonlisteners.NewCommonListenerS(nil)
|
||||
// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
|
||||
// db := NewDataDBService(cfg, nil, false, srvDep)
|
||||
// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
|
||||
// tS := NewThresholdService(cfg, db, chS, filterSChan, nil, cls, make(chan birpc.ClientConnector, 1), anz, srvDep)
|
||||
// if tS.IsRunning() {
|
||||
// t.Errorf("Expected service to be down")
|
||||
// }
|
||||
// thrs1 := engine.NewThresholdService(&engine.DataManager{}, &config.CGRConfig{}, &engine.FilterS{}, nil)
|
||||
// tS2 := &ThresholdService{
|
||||
// cfg: cfg,
|
||||
// dm: db,
|
||||
// cacheS: chS,
|
||||
// filterSChan: filterSChan,
|
||||
// cls: cls,
|
||||
// thrs: thrs1,
|
||||
// connChan: make(chan birpc.ClientConnector, 1),
|
||||
// anz: anz,
|
||||
// srvDep: srvDep,
|
||||
// }
|
||||
// if !tS2.IsRunning() {
|
||||
// t.Errorf("Expected service to be running")
|
||||
// }
|
||||
// serviceName := tS2.ServiceName()
|
||||
// if !reflect.DeepEqual(serviceName, utils.ThresholdS) {
|
||||
// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ThresholdS, serviceName)
|
||||
// }
|
||||
// shouldRun := tS2.ShouldRun()
|
||||
// if !reflect.DeepEqual(shouldRun, false) {
|
||||
// t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
// }
|
||||
// }
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
// import (
|
||||
// "sync"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/cgrates/commonlisteners"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
//
|
||||
// func TestNewTrendService(t *testing.T) {
|
||||
// cfg := &config.CGRConfig{}
|
||||
// dm := &DataDBService{}
|
||||
// cacheS := &CacheService{}
|
||||
// filterSChan := make(chan *engine.FilterS)
|
||||
// server := &commonlisteners.CommonListenerS{}
|
||||
// internalTrendSChan := make(chan birpc.ClientConnector)
|
||||
// connMgr := &engine.ConnManager{}
|
||||
// anz := &AnalyzerService{}
|
||||
// srvDep := make(map[string]*sync.WaitGroup)
|
||||
//
|
||||
// service := NewTrendService(cfg, dm, cacheS, filterSChan, server, internalTrendSChan, connMgr, anz, srvDep)
|
||||
//
|
||||
// trendService, ok := service.(*TrendService)
|
||||
// if !ok {
|
||||
// t.Errorf("Expected type *TrendService, but got %T", service)
|
||||
// }
|
||||
//
|
||||
// if trendService.cfg != cfg {
|
||||
// t.Errorf("Expected cfg to be %v, but got %v", cfg, trendService.cfg)
|
||||
// }
|
||||
// if trendService.dm != dm {
|
||||
// t.Errorf("Expected dm to be %v, but got %v", dm, trendService.dm)
|
||||
// }
|
||||
// if trendService.cacheS != cacheS {
|
||||
// t.Errorf("Expected cacheS to be %v, but got %v", cacheS, trendService.cacheS)
|
||||
// }
|
||||
//
|
||||
// if trendService.cls != server {
|
||||
// t.Errorf("Expected server to be %v, but got %v", server, trendService.cls)
|
||||
// }
|
||||
// if trendService.connChan != internalTrendSChan {
|
||||
// t.Errorf("Expected connChan to be %v, but got %v", internalTrendSChan, trendService.connChan)
|
||||
// }
|
||||
// if trendService.connMgr != connMgr {
|
||||
// t.Errorf("Expected connMgr to be %v, but got %v", connMgr, trendService.connMgr)
|
||||
// }
|
||||
// if trendService.anz != anz {
|
||||
// t.Errorf("Expected anz to be %v, but got %v", anz, trendService.anz)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func TestTrendServiceServiceName(t *testing.T) {
|
||||
// tr := &TrendService{}
|
||||
//
|
||||
// serviceName := tr.ServiceName()
|
||||
//
|
||||
// expected := utils.TrendS
|
||||
// if serviceName != expected {
|
||||
// t.Errorf("Expected service name to be %s, but got %s", expected, serviceName)
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user