test fixes

This commit is contained in:
Radu Ioan Fericean
2016-06-06 13:02:06 +03:00
parent eb071e49f2
commit 95e8230a5c
11 changed files with 28 additions and 14 deletions

View File

@@ -204,7 +204,7 @@ func TestDmtAgentTPFromFolder(t *testing.T) {
return
}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
var loadInst engine.LoadInstance
var loadInst utils.LoadInstance
if err := apierRpc.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
t.Error(err)
}

View File

@@ -3,6 +3,7 @@ package cache2go
import (
"encoding/gob"
"log"
"os"
"path/filepath"
"strings"
@@ -28,6 +29,11 @@ type cacheStore interface {
// easy to be counted exported by prefix
type cacheDoubleStore map[string]map[string]interface{}
type KeyValue struct {
Key string
Value interface{}
}
func newDoubleStore() cacheDoubleStore {
return make(cacheDoubleStore)
}
@@ -117,7 +123,7 @@ func (cs cacheDoubleStore) GetKeysForPrefix(prefix string) (keys []string) {
func (cs cacheDoubleStore) Save(path string, keys []string) error {
// create a the path
if err := os.MkdirAll(path, 0766); err != nil {
utils.Logger.Err("<cache encoder>:" + err.Error())
utils.Logger.Info("<cache encoder>:" + err.Error())
return err
}
@@ -134,13 +140,17 @@ func (cs cacheDoubleStore) Save(path string, keys []string) error {
dataFile, err := os.Create(filepath.Join(path, fileName) + ".cache")
defer dataFile.Close()
if err != nil {
utils.Logger.Err("<cache encoder>:" + err.Error())
utils.Logger.Info("<cache encoder>:" + err.Error())
}
// serialize the data
dataEncoder := gob.NewEncoder(dataFile)
log.Print("start: ", fileName)
if err := dataEncoder.Encode(data); err != nil {
utils.Logger.Err("<cache encoder>:" + err.Error())
log.Print("err: ", fileName, err)
utils.Logger.Info("<cache encoder>:" + err.Error())
} else {
log.Print("end: ", fileName, err)
}
}(key, value)
}
@@ -161,14 +171,14 @@ func (cs cacheDoubleStore) Load(path string, keys []string) error {
dataFile, err := os.Open(fileName)
defer dataFile.Close()
if err != nil {
utils.Logger.Err("<cache decoder>: " + err.Error())
utils.Logger.Info("<cache decoder>: " + err.Error())
}
val := make(map[string]interface{})
dataDecoder := gob.NewDecoder(dataFile)
err = dataDecoder.Decode(&val)
if err != nil {
utils.Logger.Err("<cache decoder>: " + err.Error())
utils.Logger.Info("<cache decoder>: " + err.Error())
}
cs[key] = val
}(file, key)

View File

@@ -4,6 +4,10 @@
// Used for cgradmin
// Starts rater, scheduler
"general": {
"internal_ttl": "30m",
},
"listen": {
"rpc_json": ":2012", // RPC JSON listening address
"rpc_gob": ":2013", // RPC GOB listening address

View File

@@ -16,7 +16,7 @@ import (
var destCfgPath string
var destCfg *config.CGRConfig
var destRPC *rpc.Client
var destLoadInst engine.LoadInstance // Share load information between tests
var destLoadInst utils.LoadInstance // Share load information between tests
func TestDestManagInitCfg(t *testing.T) {
if !*testIntegration {

View File

@@ -410,7 +410,7 @@ func TestRPCITStatusBcastCmd(t *testing.T) {
} else if stats.LastLoadId != utils.NOT_AVAILABLE {
t.Errorf("Received unexpected stats: %+v", stats)
}
var loadInst engine.LoadInstance
var loadInst utils.LoadInstance
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
if err := rpcRAL1.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
t.Error(err)

View File

@@ -42,7 +42,7 @@ var tpDir = flag.String("tp_dir", "", "CGR config dir path here")
var stiCfg *config.CGRConfig
var stiRpc *rpc.Client
var stiLoadInst engine.LoadInstance
var stiLoadInst utils.LoadInstance
func TestSTIInitCfg(t *testing.T) {
if !*testSureTax {

View File

@@ -17,7 +17,7 @@ import (
var tpCfgPath string
var tpCfg *config.CGRConfig
var tpRPC *rpc.Client
var tpLoadInst engine.LoadInstance // Share load information between tests
var tpLoadInst utils.LoadInstance // Share load information between tests
func TestTpInitCfg(t *testing.T) {
if !*testIntegration {

View File

@@ -34,7 +34,7 @@ import (
var tutSMGCfgPath string
var tutSMGCfg *config.CGRConfig
var tutSMGRpc *rpc.Client
var smgLoadInst engine.LoadInstance // Share load information between tests
var smgLoadInst utils.LoadInstance // Share load information between tests
func TestTutSMGInitCfg(t *testing.T) {
if !*testLocal {

View File

@@ -35,7 +35,7 @@ import (
var tutLocalCfgPath string
var tutFsLocalCfg *config.CGRConfig
var tutLocalRpc *rpc.Client
var loadInst engine.LoadInstance // Share load information between tests
var loadInst utils.LoadInstance // Share load information between tests
func TestTutLocalInitCfg(t *testing.T) {
if !*testLocal {

View File

@@ -74,7 +74,7 @@ func TestSMGDataTPFromFolder(t *testing.T) {
return
}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
var loadInst engine.LoadInstance
var loadInst utils.LoadInstance
if err := smgRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
t.Error(err)
}

View File

@@ -103,7 +103,7 @@ func TestSMGVoiceTPFromFolder(t *testing.T) {
return
}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
var loadInst engine.LoadInstance
var loadInst utils.LoadInstance
if err := smgRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
t.Error(err)
}