mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
services/Fixed tests from actions to datadb
This commit is contained in:
committed by
Dan Christian Bogos
parent
4eefdc9a03
commit
6d66865a19
@@ -17,7 +17,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/actions"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/cores"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestActionSCoverage for cover testing
|
||||
func TestActionSCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
@@ -25,8 +38,6 @@ func TestActionSCoverage(t *testing.T) {
|
||||
chS := engine.NewCacheS(cfg, nil, nil)
|
||||
filterSChan := make(chan *engine.FilterS, 1)
|
||||
filterSChan <- nil
|
||||
close(chS.GetPrecacheChannel(utils.CacheActionProfiles))
|
||||
close(chS.GetPrecacheChannel(utils.CacheActionProfilesFilterIndexes))
|
||||
server := cores.NewServer(nil)
|
||||
srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
db := NewDataDBService(cfg, nil, srvDep)
|
||||
@@ -102,4 +113,3 @@ func TestActionSCoverage(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
@@ -32,7 +31,7 @@ import (
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestNewAnalyzerCoverage for cover testing
|
||||
//TestAnalyzerCoverage for cover testing
|
||||
func TestAnalyzerCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
shdChan := utils.NewSyncedChan()
|
||||
@@ -96,4 +95,3 @@ func TestAnalyzerCoverage(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
@@ -125,4 +124,3 @@ func TestApiersCoverage(t *testing.T) {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", nil, shutdownApi2)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,18 @@ 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"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestAsteriskAgentCoverage for cover testing
|
||||
func TestAsteriskAgentCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
@@ -76,4 +87,3 @@ func TestAsteriskAgentCoverage(t *testing.T) {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
@@ -89,4 +88,3 @@ func TestAttributeSCoverage(t *testing.T) {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/cores"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestCdrsCoverage for cover testing
|
||||
func TestCdrsCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
@@ -88,4 +98,3 @@ func TestCdrsCoverage(t *testing.T) {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -42,6 +42,12 @@ func TestChargerSCoverage(t *testing.T) {
|
||||
server := cores.NewServer(nil)
|
||||
db := NewDataDBService(cfg, nil, srvDep)
|
||||
anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, make(chan rpcclient.ClientConnector, 1), srvDep)
|
||||
chrS1 := NewChargerService(cfg, db, chS,
|
||||
filterSChan, server, make(chan rpcclient.ClientConnector, 1),
|
||||
nil, anz, srvDep)
|
||||
if chrS1.IsRunning() {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
chrS := &ChargerService{
|
||||
connChan: make(chan rpcclient.ClientConnector, 1),
|
||||
cfg: cfg,
|
||||
@@ -69,5 +75,19 @@ func TestChargerSCoverage(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
}
|
||||
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 rpcclient.ClientConnector, 1)
|
||||
chrS.connChan <- chS
|
||||
shutErr := chrS.Shutdown()
|
||||
if shutErr != nil {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", nil, shutErr)
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/cores"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestCoreSCoverage for cover testing
|
||||
func TestCoreSCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
@@ -74,4 +85,3 @@ func TestCoreSCoverage(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
/*
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -39,10 +39,141 @@ func TestDataDBCoverage(t *testing.T) {
|
||||
if db.IsRunning() {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
db.dm = &engine.DataManager{}
|
||||
//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")
|
||||
}
|
||||
errStart := db.Start()
|
||||
if errStart == nil || errStart != utils.ErrServiceAlreadyRunning {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, errStart)
|
||||
}
|
||||
oldcfg := &config.DataDbCfg{
|
||||
DataDbType: utils.MONGO,
|
||||
DataDbHost: "127.0.0.1",
|
||||
DataDbPort: "27017",
|
||||
DataDbName: "10",
|
||||
DataDbUser: "cgrates",
|
||||
Opts: map[string]interface{}{
|
||||
utils.QueryTimeoutCfg: "10s",
|
||||
utils.RedisClusterOnDownDelayCfg: "0",
|
||||
utils.RedisClusterSyncCfg: "5s",
|
||||
utils.RedisClusterCfg: false,
|
||||
utils.RedisSentinelNameCfg: "",
|
||||
utils.RedisTLS: false,
|
||||
utils.RedisClientCertificate: "",
|
||||
utils.RedisClientKey: "",
|
||||
utils.RedisCACertificate: "",
|
||||
},
|
||||
RmtConns: []string{},
|
||||
RplConns: []string{},
|
||||
Items: map[string]*config.ItemOpt{
|
||||
utils.MetaAccounts: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaReverseDestinations: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaDestinations: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaRatingPlans: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaRatingProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActions: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActionPlans: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaAccountActionPlans: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActionTriggers: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaSharedGroups: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaTimings: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaResourceProfile: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaStatQueues: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaResources: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaStatQueueProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaThresholds: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaThresholdProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaFilters: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaRouteProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaAttributeProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaDispatcherHosts: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaChargerProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaDispatcherProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaLoadIDs: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaIndexes: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaRateProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActionProfiles: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
},
|
||||
}
|
||||
db.oldDBCfg = oldcfg
|
||||
err := db.Reload()
|
||||
if err != nil {
|
||||
t.Errorf("\nExpecting <nil>,\n Received <%+v>", err)
|
||||
}
|
||||
serviceName := db.ServiceName()
|
||||
if !reflect.DeepEqual(serviceName, utils.DataDB) {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.DataDB, serviceName)
|
||||
}
|
||||
shouldRun := db.ShouldRun()
|
||||
if !reflect.DeepEqual(shouldRun, false) {
|
||||
t.Errorf("\nExpecting <false>,\n Received <%+v>", shouldRun)
|
||||
}
|
||||
getDMChan := db.GetDMChan()
|
||||
if !reflect.DeepEqual(getDMChan, db.dbchan) {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", db.dbchan, getDMChan)
|
||||
}
|
||||
db.dm = &engine.DataManager{}
|
||||
getDM := db.GetDM()
|
||||
if !reflect.DeepEqual(getDM, db.dm) {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", db.dm, getDM)
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user