mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added tests for DispatcherSv1.GetProfileForEvent
This commit is contained in:
committed by
Dan Christian Bogos
parent
48d431117b
commit
2ff69dc8b5
@@ -85,7 +85,6 @@ func testDispatcherSInitCfg(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
dispatcherCfg.DataFolderPath = *dataDir
|
||||
config.SetCgrConfig(dispatcherCfg)
|
||||
}
|
||||
|
||||
func testDispatcherSInitDataDb(t *testing.T) {
|
||||
|
||||
@@ -13,4 +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_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
|
||||
|
102
dispatchers/dispatchersv1_it_test.go
Normal file
102
dispatchers/dispatchersv1_it_test.go
Normal file
@@ -0,0 +1,102 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var sTestsDspDspv1 = []func(t *testing.T){
|
||||
testDspDspv1GetProfileForEvent,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestDspDspv1SMySQL(t *testing.T) {
|
||||
engine.KillEngine(0)
|
||||
dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true)
|
||||
dispEngine.loadData2(t, path.Join(dspDataDir, "tariffplans", "dispatchers"))
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
for _, stest := range sTestsDspDspv1 {
|
||||
t.Run("TestDspDspv1", stest)
|
||||
}
|
||||
dispEngine.stopEngine(t)
|
||||
engine.KillEngine(0)
|
||||
}
|
||||
|
||||
func TestDspDspv1SMongo(t *testing.T) {
|
||||
engine.KillEngine(0)
|
||||
dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers_mongo"), true, true)
|
||||
dispEngine.loadData2(t, path.Join(dspDataDir, "tariffplans", "dispatchers"))
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
for _, stest := range sTestsDspDspv1 {
|
||||
t.Run("TestDspDspv1", stest)
|
||||
}
|
||||
dispEngine.stopEngine(t)
|
||||
engine.KillEngine(0)
|
||||
}
|
||||
|
||||
func testDspDspv1GetProfileForEvent(t *testing.T) {
|
||||
arg := DispatcherEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testDspv1",
|
||||
Event: map[string]interface{}{
|
||||
utils.EVENT_NAME: "Event1",
|
||||
},
|
||||
},
|
||||
Subsystem: utils.META_ANY,
|
||||
}
|
||||
var reply engine.DispatcherProfile
|
||||
expected := engine.DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "EVENT1",
|
||||
Subsystems: []string{utils.META_ANY},
|
||||
FilterIDs: []string{"*string:~EventName:Event1"},
|
||||
StrategyParams: make(map[string]interface{}),
|
||||
Strategy: utils.MetaWeight,
|
||||
Weight: 30,
|
||||
Hosts: engine.DispatcherHostProfiles{
|
||||
&engine.DispatcherHostProfile{
|
||||
ID: "ALL2",
|
||||
FilterIDs: []string{},
|
||||
Weight: 20,
|
||||
Params: make(map[string]interface{}),
|
||||
},
|
||||
&engine.DispatcherHostProfile{
|
||||
ID: "ALL",
|
||||
FilterIDs: []string{},
|
||||
Weight: 10,
|
||||
Params: make(map[string]interface{}),
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RCP.Call(utils.DispatcherSv1GetProfileForEvent, &arg, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expected, reply) {
|
||||
t.Errorf("expected: %s , received: %s", utils.ToJSON(expected), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user