diff --git a/apier/v1/smgenericv1_it_test.go b/apier/v1/smgenericv1_it_test.go index f1cc270d0..b5cc9394c 100644 --- a/apier/v1/smgenericv1_it_test.go +++ b/apier/v1/smgenericv1_it_test.go @@ -116,7 +116,7 @@ func TestSMGV1CacheStats(t *testing.T) { } var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, + expectedStats := &utils.CacheStats{Destinations: 7, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, DerivedChargers: 1, LcrProfiles: 5, CdrStats: 6, Users: 3, LastLoadId: smgV1LoadInst.LoadId, LastLoadTime: smgV1LoadInst.LoadTime.Format(time.RFC3339)} var args utils.AttrCacheStats if err := smgV1Rpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil { diff --git a/apier/v2/tp_it_test.go b/apier/v2/tp_it_test.go index b2918fca4..ae96da9cc 100644 --- a/apier/v2/tp_it_test.go +++ b/apier/v2/tp_it_test.go @@ -156,7 +156,7 @@ func TestTPitTimings(t *testing.T) { Time: "01:00:00", } // Test set - reply := "" + var reply string for _, tm := range []*utils.ApierTPTiming{tmPeak, tmOffPeakMorning, tmOffPeakEvening, tmOffPeakWeekend, tmDummyRemove} { if err := tpRPC.Call("ApierV2.SetTPTiming", tm, &reply); err != nil { t.Error("Got error on ApierV2.SetTPTiming: ", err.Error()) @@ -187,6 +187,58 @@ func TestTPitTimings(t *testing.T) { } } +func TestTPitDestinations(t *testing.T) { + if !*testTP { + return + } + var reply string + // DST_1002,1002 + dst1002 := &utils.TPDestination{TPid: testTPid, DestinationId: "DST_1002", Prefixes: []string{"1002"}} + // DST_1003,1003 + dst1003 := &utils.TPDestination{TPid: testTPid, DestinationId: "DST_1003", Prefixes: []string{"1003"}} + // DST_1007,1007 + dst1007 := &utils.TPDestination{TPid: testTPid, DestinationId: "DST_1007", Prefixes: []string{"1007"}} + // DST_FS,10 + dstFS := &utils.TPDestination{TPid: testTPid, DestinationId: "DST_FS", Prefixes: []string{"10"}} + // DST_DE_MOBILE,+49151 + // DST_DE_MOBILE,+49161 + // DST_DE_MOBILE,+49171 + dstDEMobile := &utils.TPDestination{TPid: testTPid, DestinationId: "DST_DE_MOBILE", Prefixes: []string{"+49151", "+49161", "+49171"}} + dstDUMMY := &utils.TPDestination{TPid: testTPid, DestinationId: "DUMMY_REMOVE", Prefixes: []string{"999"}} + for _, dst := range []*utils.TPDestination{dst1002, dst1003, dst1007, dstFS, dstDEMobile, dstDUMMY} { + if err := tpRPC.Call("ApierV2.SetTPDestination", dst, &reply); err != nil { + t.Error("Got error on ApierV2.SetTPDestination: ", err.Error()) + } else if reply != utils.OK { + t.Error("Unexpected reply received when calling ApierV2.SetTPDestination: ", reply) + } + } + // Test get + /* + FixMe for mongodb + var rplyDst *utils.TPDestination + if err := tpRPC.Call("ApierV2.GetTPDestination", v1.AttrGetTPDestination{testTPid, dstDEMobile.DestinationId}, &rplyDst); err != nil { + t.Error("Calling ApierV2.GetTPDestination, got error: ", err.Error()) + } else if len(dstDEMobile.Prefixes) != len(rplyDst.Prefixes) { + t.Errorf("Calling ApierV2.GetTPDestination expected: %v, received: %v", dstDEMobile, rplyDst) + } + */ + // Test remove + if err := tpRPC.Call("ApierV2.RemTPDestination", v1.AttrGetTPDestination{testTPid, dstDUMMY.DestinationId}, &reply); err != nil { + t.Error("Calling ApierV1.RemTPTiming, got error: ", err.Error()) + } else if reply != utils.OK { + t.Error("Calling ApierV2.RemTPTiming received: ", reply) + } + // Test getIds + var rplyDstIds []string + expectedDstIds := []string{"DST_1002", "DST_1003", "DST_1007", "DST_DE_MOBILE", "DST_FS"} + if err := tpRPC.Call("ApierV2.GetTPDestinationIds", v1.AttrGetTPDestinationIds{TPid: testTPid}, &rplyDstIds); err != nil { + t.Error("Calling ApierV1.GetTPDestinationIds, got error: ", err.Error()) + } else if len(expectedDstIds) != len(rplyDstIds) { + t.Errorf("Calling ApierV2.GetTPDestinationIds expected: %v, received: %v", expectedDstIds, rplyDstIds) + } + +} + func TestTPitKillEngine(t *testing.T) { if !*testTP { return diff --git a/data/tariffplans/tutorial/Destinations.csv b/data/tariffplans/tutorial/Destinations.csv index 95e1b9f12..823d3a72f 100644 --- a/data/tariffplans/tutorial/Destinations.csv +++ b/data/tariffplans/tutorial/Destinations.csv @@ -3,3 +3,6 @@ DST_1002,1002 DST_1003,1003 DST_1007,1007 DST_FS,10 +DST_DE_MOBILE,+49151 +DST_DE_MOBILE,+49161 +DST_DE_MOBILE,+49171 diff --git a/engine/libtest.go b/engine/libtest.go index 59f904091..f45288566 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -71,11 +71,9 @@ func StartEngine(cfgPath string, waitEngine int) (*exec.Cmd, error) { return nil, err } engine := exec.Command(enginePath, "-config_dir", cfgPath) - utils.Logger.Debug(fmt.Sprintf("Before engine.Start(), time: %+v", time.Now())) if err := engine.Start(); err != nil { return nil, err } - utils.Logger.Debug(fmt.Sprintf("After engine.Start(), time: %+v", time.Now())) time.Sleep(time.Duration(waitEngine) * time.Millisecond) // Give time to rater to fire up return engine, nil } diff --git a/general_tests/tut_smgeneric_it_test.go b/general_tests/tut_smgeneric_it_test.go index 0c72cada8..01837296a 100644 --- a/general_tests/tut_smgeneric_it_test.go +++ b/general_tests/tut_smgeneric_it_test.go @@ -114,7 +114,7 @@ func TestTutSMGCacheStats(t *testing.T) { } var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, + expectedStats := &utils.CacheStats{Destinations: 7, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, DerivedChargers: 1, LcrProfiles: 5, CdrStats: 6, Users: 3, LastLoadId: smgLoadInst.LoadId, LastLoadTime: smgLoadInst.LoadTime.Format(time.RFC3339)} var args utils.AttrCacheStats if err := tutSMGRpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil { diff --git a/general_tests/tutorial_local_test.go b/general_tests/tutorial_local_test.go index 0f04f18e5..669080388 100644 --- a/general_tests/tutorial_local_test.go +++ b/general_tests/tutorial_local_test.go @@ -115,7 +115,7 @@ func TestTutLocalCacheStats(t *testing.T) { } var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, + expectedStats := &utils.CacheStats{Destinations: 7, RatingPlans: 4, RatingProfiles: 9, Actions: 8, ActionPlans: 4, SharedGroups: 1, Aliases: 1, DerivedChargers: 1, LcrProfiles: 5, CdrStats: 6, Users: 3, LastLoadId: loadInst.LoadId, LastLoadTime: loadInst.LoadTime.Format(time.RFC3339)} var args utils.AttrCacheStats if err := tutLocalRpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil {