Updated integration tests

This commit is contained in:
Trial97
2020-11-27 17:53:11 +02:00
committed by Dan Christian Bogos
parent 9de6a2d172
commit bd10472bf8
9 changed files with 280 additions and 182 deletions

View File

@@ -27,6 +27,7 @@ import (
"testing"
"time"
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -1433,12 +1434,14 @@ func testDiamItEmulateTerminate(t *testing.T) {
}
var result string
//add the second charger
chargerProfile := &engine.ChargerProfile{
Tenant: "cgrates.com",
ID: "CustomCharger",
RunID: "CustomCharger",
AttributeIDs: []string{"*constant:*req.Category:custom_charger"},
Weight: 20,
chargerProfile := &v1.ChargerWithCache{
ChargerProfile: &engine.ChargerProfile{
Tenant: "cgrates.com",
ID: "CustomCharger",
RunID: "CustomCharger",
AttributeIDs: []string{"*constant:*req.Category:custom_charger"},
Weight: 20,
},
}
if err := apierRpc.Call(utils.APIerSv1SetChargerProfile, chargerProfile, &result); err != nil {
@@ -1447,12 +1450,14 @@ func testDiamItEmulateTerminate(t *testing.T) {
t.Error("Unexpected reply returned", result)
}
//add the second charger
chargerProfile2 := &engine.ChargerProfile{
Tenant: "cgrates.com",
ID: "Default",
RunID: "*default",
AttributeIDs: []string{"*none"},
Weight: 20,
chargerProfile2 := &v1.ChargerWithCache{
ChargerProfile: &engine.ChargerProfile{
Tenant: "cgrates.com",
ID: "Default",
RunID: "*default",
AttributeIDs: []string{"*none"},
Weight: 20,
},
}
if err := apierRpc.Call(utils.APIerSv1SetChargerProfile, chargerProfile2, &result); err != nil {

View File

@@ -1003,7 +1003,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != false {
if acnt.ActionTriggers[0].Executed {
t.Errorf("Expected false, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
@@ -1038,7 +1038,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != true {
if !acnt.ActionTriggers[0].Executed {
t.Errorf("Expected true, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
@@ -1053,6 +1053,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
t.Errorf("Calling APIerSv1.ExecuteAction received: %s", reply)
}
acnt = engine.Account{}
if err := accRPC.Call(utils.APIerSv2GetAccount, attrAcc, &acnt); err != nil {
t.Fatal(err)
} else {
@@ -1070,8 +1071,8 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != false {
t.Errorf("Expected true, received: %+v", acnt.ActionTriggers[0].Executed)
if acnt.ActionTriggers[0].Executed {
t.Errorf("Expected false, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
}

View File

@@ -207,6 +207,10 @@ func testAttributeSGetAttributeForEvent(t *testing.T) {
},
Weight: 10.0,
}
if *encoding == utils.MetaGOB {
eAttrPrf.Attributes[0].FilterIDs = nil
eAttrPrf.Attributes[1].FilterIDs = nil
}
eAttrPrf.Compile()
var attrReply *engine.AttributeProfile
if err := attrSRPC.Call(utils.AttributeSv1GetAttributeForEvent,

View File

@@ -170,11 +170,37 @@ func testConfigSSetConfigSessionS(t *testing.T) {
"terminate_attempts": 5.,
}
if *encoding == utils.MetaGOB {
var empty []interface{}
exp["replication_conns"] = empty
exp["scheduler_conns"] = empty
exp["stats_conns"] = empty
exp["thresholds_conns"] = empty
var empty []string
exp = map[string]interface{}{
"enabled": true,
"listen_bijson": "127.0.0.1:2014",
"chargers_conns": []string{utils.MetaInternal},
"rals_conns": []string{utils.MetaInternal},
"resources_conns": []string{utils.MetaLocalHost},
"thresholds_conns": empty,
"stats_conns": empty,
"routes_conns": []string{utils.MetaLocalHost},
"attributes_conns": []string{utils.MetaLocalHost},
"cdrs_conns": []string{utils.MetaInternal},
"replication_conns": empty,
"scheduler_conns": empty,
"session_indexes": []string{"OriginID"},
"client_protocol": 1.,
"terminate_attempts": 5,
"channel_sync_interval": "0",
"debit_interval": "0",
"session_ttl": "0",
"store_session_costs": false,
"min_dur_low_balance": "0",
"alterable_fields": empty,
"stir": map[string]interface{}{
"allowed_attest": []string{utils.META_ANY},
"default_attest": "A",
"payload_maxduration": "-1",
"privatekey_path": "",
"publickey_path": "",
},
}
}
exp = map[string]interface{}{
config.SessionSJson: exp,
@@ -221,6 +247,39 @@ func testConfigSv1GetJSONSectionWithoutTenant(t *testing.T) {
"publickey_path": "",
},
}
if *encoding == utils.MetaGOB {
var empty []string
exp = map[string]interface{}{
"enabled": true,
"listen_bijson": "127.0.0.1:2014",
"chargers_conns": []string{utils.MetaInternal},
"rals_conns": []string{utils.MetaInternal},
"resources_conns": []string{utils.MetaLocalHost},
"thresholds_conns": empty,
"stats_conns": empty,
"routes_conns": []string{utils.MetaLocalHost},
"attributes_conns": []string{utils.MetaLocalHost},
"cdrs_conns": []string{utils.MetaInternal},
"replication_conns": empty,
"scheduler_conns": empty,
"session_indexes": []string{"OriginID"},
"client_protocol": 1.,
"terminate_attempts": 5,
"channel_sync_interval": "0",
"debit_interval": "0",
"session_ttl": "0",
"store_session_costs": false,
"min_dur_low_balance": "0",
"alterable_fields": empty,
"stir": map[string]interface{}{
"allowed_attest": []string{utils.META_ANY},
"default_attest": "A",
"payload_maxduration": "-1",
"privatekey_path": "",
"publickey_path": "",
},
}
}
exp = map[string]interface{}{
config.SessionSJson: exp,
}

View File

@@ -596,31 +596,38 @@ func testV1RatePrfStopEngine(t *testing.T) {
}
func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) {
rateProfile := &engine.RateProfile{
ID: "RPWithoutTenant",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
rateProfile := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RPWithoutTenant",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
},
},
},
},
},
},
}
if *encoding == utils.MetaGOB {
rateProfile.Rates["RT_WEEK"].FilterIDs = nil
}
var reply string
if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, rateProfile, &reply); err != nil {
t.Error(err)
@@ -633,8 +640,8 @@ func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) {
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "RPWithoutTenant"}},
&result); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(result, rateProfile) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(rateProfile), utils.ToJSON(result))
} else if !reflect.DeepEqual(result, rateProfile.RateProfile) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(rateProfile.RateProfile), utils.ToJSON(result))
}
}
@@ -693,63 +700,72 @@ func testV1RatePrfGetRateProfileIDsCount(t *testing.T) {
}
func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) {
rPrf := &engine.RateProfile{
ID: "SpecialRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "SpecialRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
},
{
IntervalStart: time.Minute,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
{
IntervalStart: time.Minute,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
"RT_WEEKEND": {
ID: "RT_WEEKEND",
Weight: 10,
ActivationTimes: "* * * * 0,6",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
},
},
"RT_WEEKEND": {
ID: "RT_WEEKEND",
Weight: 10,
ActivationTimes: "* * * * 0,6",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
"RT_CHRISTMAS": {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
"RT_CHRISTMAS": {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
},
},
},
}
if *encoding == utils.MetaGOB {
rPrf.Rates["RT_WEEK"].FilterIDs = nil
rPrf.Rates["RT_WEEKEND"].FilterIDs = nil
rPrf.Rates["RT_CHRISTMAS"].FilterIDs = nil
}
var reply string
if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, rPrf, &reply); err != nil {
t.Error(err)
@@ -762,8 +778,8 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) {
utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "SpecialRate"}},
&rply); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(rPrf, rply) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(rPrf), utils.ToJSON(rply))
} else if !reflect.DeepEqual(rPrf.RateProfile, rply) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(rPrf.RateProfile), utils.ToJSON(rply))
}
}
@@ -798,12 +814,16 @@ func testV1RateCostForEventWithDefault(t *testing.T) {
},
},
}
rPrf := &engine.RateProfile{
ID: "DefaultRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 10,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "DefaultRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 10,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
},
},
},
}
var reply string
@@ -828,21 +848,17 @@ func testV1RateCostForEventWithDefault(t *testing.T) {
exp := &engine.RateProfileCost{
ID: "DefaultRate",
Cost: 0.12,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
},
CompressFactor: 1,
},
},
RateSIntervals: []*engine.RateSInterval{{
UsageStart: 0,
Increments: []*engine.RateSIncrement{{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
}},
CompressFactor: 1,
}},
}
if err := ratePrfRpc.Call(utils.RateSv1CostForEvent, &argsRt, &rply); err != nil {
t.Error(err)
@@ -891,17 +907,17 @@ func testV1RateCostForEventWithUsage(t *testing.T) {
ID: "DefaultRate",
Cost: 0.19,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: time.Minute + 10*time.Second,
Rate: rate1,
@@ -938,17 +954,17 @@ func testV1RateCostForEventWithUsage(t *testing.T) {
ID: "DefaultRate",
Cost: 15.075,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: 4*time.Hour + 9*time.Minute + 15*time.Second,
Rate: rate1,
@@ -1029,10 +1045,10 @@ func testV1RateCostForEventWithStartTime(t *testing.T) {
ID: "DefaultRate",
Cost: 0.12,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
@@ -1133,17 +1149,17 @@ func testV1RateCostForEventWithOpts(t *testing.T) {
ID: "DefaultRate",
Cost: 0.19,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: time.Minute + 10*time.Second,
Rate: rate1,
@@ -1181,17 +1197,17 @@ func testV1RateCostForEventWithOpts(t *testing.T) {
ID: "DefaultRate",
Cost: 15.075,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: 4*time.Hour + 9*time.Minute + 15*time.Second,
Rate: rate1,
@@ -1234,22 +1250,24 @@ func testV1RateCostForEventSpecial(t *testing.T) {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
IntervalRates: []*engine.IntervalRate{{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
}},
}
rPrf := &engine.RateProfile{
ID: "RateChristmas",
FilterIDs: []string{"*string:~*req.Subject:1002"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"RATE_CHRISTMAS": rtChristmas,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RateChristmas",
FilterIDs: []string{"*string:~*req.Subject:1002"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"RATE_CHRISTMAS": rtChristmas,
},
},
},
}
var reply string
@@ -1279,17 +1297,17 @@ func testV1RateCostForEventSpecial(t *testing.T) {
ID: "RateChristmas",
Cost: 93.725,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: 1 * time.Minute,
Usage: 59 * time.Minute,
Rate: rate1,
@@ -1299,10 +1317,10 @@ func testV1RateCostForEventSpecial(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: time.Hour,
Usage: 24 * time.Hour,
Rate: rtChristmas,
@@ -1312,10 +1330,10 @@ func testV1RateCostForEventSpecial(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 25 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 25 * time.Hour,
Usage: 735 * time.Second,
Rate: rate1,
@@ -1382,14 +1400,18 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
},
}
rPrf := &engine.RateProfile{
ID: "RateNewYear",
FilterIDs: []string{"*string:~*req.Subject:1003"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"NEW_YEAR1": rtNewYear1,
"NEW_YEAR2": rtNewYear2,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RateNewYear",
FilterIDs: []string{"*string:~*req.Subject:1003"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"NEW_YEAR1": rtNewYear1,
"NEW_YEAR2": rtNewYear2,
},
},
},
}
var reply string
@@ -1419,17 +1441,17 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
ID: "RateNewYear",
Cost: 157.925,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: 1 * time.Minute,
Usage: 119 * time.Minute,
Rate: rate1,
@@ -1439,10 +1461,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 2 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 2 * time.Hour,
Usage: 12 * time.Hour,
Rate: rtNewYear1,
@@ -1452,10 +1474,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 14 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 14 * time.Hour,
Usage: 46800 * time.Second,
Rate: rtNewYear2,
@@ -1465,10 +1487,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 27 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 27 * time.Hour,
Usage: 29535 * time.Second,
Rate: rate1,

View File

@@ -35,8 +35,9 @@ import (
)
var (
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication")
)
func TestLoadConfig(t *testing.T) {

View File

@@ -22,7 +22,6 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/gob"
"fmt"
"io"
"io/ioutil"
@@ -31,7 +30,6 @@ import (
"net/http"
"net/http/pprof"
"net/rpc"
"net/url"
"reflect"
"strings"
"sync"
@@ -46,14 +44,6 @@ import (
"golang.org/x/net/websocket"
)
func init() {
gob.Register(map[string]interface{}{})
gob.Register([]interface{}{})
gob.Register(time.Duration(0))
gob.Register(time.Time{})
gob.Register(url.Values{})
}
func NewServer(caps *engine.Caps) (s *Server) {
return &Server{
httpMux: http.NewServeMux(),

View File

@@ -20,7 +20,9 @@ package engine
import (
"encoding/gob"
"encoding/json"
"fmt"
"net/url"
"runtime"
"sync"
"time"
@@ -80,6 +82,16 @@ func init() {
gob.Register(new(StatDistinct))
gob.Register(new(HTTPPosterRequest))
gob.Register([]interface{}{})
gob.Register([]map[string]interface{}{})
gob.Register(map[string]interface{}{})
gob.Register(map[string][]map[string]interface{}{})
gob.Register(map[string]string{})
gob.Register(time.Duration(0))
gob.Register(time.Time{})
gob.Register(url.Values{})
gob.Register(json.RawMessage{})
}
//SetCache shared the cache from other subsystems

View File

@@ -149,7 +149,11 @@ func testReloadVerifyFirstReload(t *testing.T) {
} else if mp[utils.EnabledCfg] != true {
t.Errorf("Expecting: <true>, received: <%+v>", mp[utils.EnabledCfg])
} else if readers, canConvert := mp[utils.ReadersCfg].([]interface{}); !canConvert {
t.Errorf("Cannot cast Readers to slice")
if readers, canConvert := mp[utils.ReadersCfg].([]map[string]interface{}); !canConvert { // in case of gob
t.Errorf("Cannot cast Readers to slice<%T>", mp[utils.ReadersCfg])
} else if len(readers) != 3 { // 2 active readers and 1 default
t.Errorf("Expecting: <2>, received: <%+v>", len(readers))
}
} else if len(readers) != 3 { // 2 active readers and 1 default
t.Errorf("Expecting: <2>, received: <%+v>", len(readers))
}