mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Complete test in dispatchers/cdrs_it_test.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
9e11a67d31
commit
c61fc5764e
@@ -13,5 +13,5 @@ cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,*const
|
||||
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~APIKey:chc12345,,,APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
|
||||
cgrates.org,ATTR_API_GRD_AUTH,*auth,*string:~APIKey:grd12345,,,APIMethods,*constant,GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock,false,20
|
||||
cgrates.org,ATTR_API_SCHD_AUTH,*auth,*string:~APIKey:sched12345,,,APIMethods,*constant,SchedulerSv1.Ping,false,20
|
||||
cgrates.org,ATTR_API_CDRS_AUTH,*auth,*string:~APIKey:cdrs12345,,,APIMethods,*constant,CDRsV1.Ping,false,20
|
||||
cgrates.org,ATTR_API_DSP_AUTH,*auth,*string:~APIKey:dsp12345,,,APIMethods,*constant,DispatcherSv1.Ping&DispatcherSv1.GetProfileForEvent,false,20
|
||||
cgrates.org,ATTR_API_CDRS_AUTH,*auth,*string:~APIKey:cdrs12345,,,APIMethods,*constant,CDRsV1.Ping&CDRsV1.ProcessEvent&CDRsV1.GetCDRs&CDRsV1.CountCDRs,false,20
|
||||
cgrates.org,ATTR_API_DSP_AUTH,*auth,*string:~APIKey:dsp12345,,,APIMethods,*constant,DispatcherSv1.Ping&DispatcherSv1.GetProfileForEvent,false,20
|
||||
|
||||
|
@@ -22,12 +22,17 @@ package dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var sTestsDspCDRs = []func(t *testing.T){
|
||||
testDspCDRsPing,
|
||||
testDspCDRsProcessEvent,
|
||||
testDspCDRsCountCDR,
|
||||
testDspCDRsGetCDR,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
@@ -59,3 +64,85 @@ func testDspCDRsPing(t *testing.T) {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsProcessEvent(t *testing.T) {
|
||||
var reply string
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
utils.OriginID: "testV2CDRsProcessCDR1",
|
||||
utils.OriginHost: "192.168.1.1",
|
||||
utils.Source: "testDspCDRsProcessEvent",
|
||||
utils.RequestType: utils.META_RATED,
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1001",
|
||||
utils.Destination: "1002",
|
||||
utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC),
|
||||
utils.Usage: time.Duration(1) * time.Minute,
|
||||
"field_extr1": "val_extr1",
|
||||
"fieldextr2": "valextr2",
|
||||
},
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testDspCDRsCountCDR(t *testing.T) {
|
||||
var reply int64
|
||||
args := &utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsGetCDR(t *testing.T) {
|
||||
var reply []*engine.CDR
|
||||
args := utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(reply) != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
} else if reply[0].CGRID != "1888cd1ba89f9654ca22b45787db217182f9da0d" {
|
||||
t.Errorf("Expected: 1888cd1ba89f9654ca22b45787db217182f9da0d , received:%v", reply[0].CGRID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user