mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixed config tests & added new stordb tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
d003b8c2ae
commit
37e5a54ea9
@@ -142,26 +142,27 @@ func testConfigSSetConfigSessionS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
exp := map[string]any{
|
||||
"enabled": true,
|
||||
"channel_sync_interval": "0",
|
||||
"alterable_fields": []any{},
|
||||
"client_protocol": 1.,
|
||||
"debit_interval": "0",
|
||||
"listen_bijson": "127.0.0.1:2014",
|
||||
"listen_bigob": "",
|
||||
"session_ttl": "0",
|
||||
"session_indexes": []any{utils.OriginID},
|
||||
"attributes_conns": []any{utils.MetaLocalHost},
|
||||
"cdrs_conns": []any{utils.MetaInternal},
|
||||
"chargers_conns": []any{utils.MetaInternal},
|
||||
"rals_conns": []any{utils.MetaInternal},
|
||||
"replication_conns": []any{},
|
||||
"resources_conns": []any{utils.MetaLocalHost},
|
||||
"routes_conns": []any{utils.MetaLocalHost},
|
||||
"scheduler_conns": []any{},
|
||||
"thresholds_conns": []any{},
|
||||
"stats_conns": []any{},
|
||||
"min_dur_low_balance": "0",
|
||||
"enabled": true,
|
||||
"channel_sync_interval": "0",
|
||||
"alterable_fields": []any{},
|
||||
"client_protocol": 1.,
|
||||
"debit_interval": "0",
|
||||
"listen_bijson": "127.0.0.1:2014",
|
||||
"listen_bigob": "",
|
||||
"stale_chan_max_extra_usage": "0",
|
||||
"session_ttl": "0",
|
||||
"session_indexes": []any{utils.OriginID},
|
||||
"attributes_conns": []any{utils.MetaLocalHost},
|
||||
"cdrs_conns": []any{utils.MetaInternal},
|
||||
"chargers_conns": []any{utils.MetaInternal},
|
||||
"rals_conns": []any{utils.MetaInternal},
|
||||
"replication_conns": []any{},
|
||||
"resources_conns": []any{utils.MetaLocalHost},
|
||||
"routes_conns": []any{utils.MetaLocalHost},
|
||||
"scheduler_conns": []any{},
|
||||
"thresholds_conns": []any{},
|
||||
"stats_conns": []any{},
|
||||
"min_dur_low_balance": "0",
|
||||
"stir": map[string]any{
|
||||
"allowed_attest": []any{utils.MetaAny},
|
||||
"default_attest": "A",
|
||||
@@ -234,28 +235,29 @@ func testConfigSSetConfigSessionS(t *testing.T) {
|
||||
|
||||
func testConfigSv1GetJSONSectionWithoutTenant(t *testing.T) {
|
||||
exp := map[string]any{
|
||||
"enabled": true,
|
||||
"listen_bijson": "127.0.0.1:2014",
|
||||
"listen_bigob": "",
|
||||
"chargers_conns": []any{utils.MetaInternal},
|
||||
"rals_conns": []any{utils.MetaInternal},
|
||||
"resources_conns": []any{utils.MetaLocalHost},
|
||||
"thresholds_conns": []any{},
|
||||
"stats_conns": []any{},
|
||||
"routes_conns": []any{utils.MetaLocalHost},
|
||||
"attributes_conns": []any{utils.MetaLocalHost},
|
||||
"cdrs_conns": []any{utils.MetaInternal},
|
||||
"replication_conns": []any{},
|
||||
"scheduler_conns": []any{},
|
||||
"session_indexes": []any{"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": []any{},
|
||||
"enabled": true,
|
||||
"listen_bijson": "127.0.0.1:2014",
|
||||
"listen_bigob": "",
|
||||
"chargers_conns": []any{utils.MetaInternal},
|
||||
"rals_conns": []any{utils.MetaInternal},
|
||||
"resources_conns": []any{utils.MetaLocalHost},
|
||||
"thresholds_conns": []any{},
|
||||
"stats_conns": []any{},
|
||||
"routes_conns": []any{utils.MetaLocalHost},
|
||||
"attributes_conns": []any{utils.MetaLocalHost},
|
||||
"cdrs_conns": []any{utils.MetaInternal},
|
||||
"replication_conns": []any{},
|
||||
"scheduler_conns": []any{},
|
||||
"session_indexes": []any{"OriginID"},
|
||||
"client_protocol": 1.,
|
||||
"terminate_attempts": 5.,
|
||||
"channel_sync_interval": "0",
|
||||
"debit_interval": "0",
|
||||
"session_ttl": "0",
|
||||
"stale_chan_max_extra_usage": "0",
|
||||
"store_session_costs": false,
|
||||
"min_dur_low_balance": "0",
|
||||
"alterable_fields": []any{},
|
||||
"stir": map[string]any{
|
||||
"allowed_attest": []any{utils.MetaAny},
|
||||
"default_attest": "A",
|
||||
@@ -273,27 +275,28 @@ func testConfigSv1GetJSONSectionWithoutTenant(t *testing.T) {
|
||||
if *encoding == utils.MetaGOB {
|
||||
var empty []string
|
||||
exp = map[string]any{
|
||||
"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,
|
||||
"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",
|
||||
"stale_chan_max_extra_usage": "0",
|
||||
"store_session_costs": false,
|
||||
"min_dur_low_balance": "0",
|
||||
"alterable_fields": empty,
|
||||
"stir": map[string]any{
|
||||
"allowed_attest": []string{utils.MetaAny},
|
||||
"default_attest": "A",
|
||||
|
||||
@@ -1695,6 +1695,13 @@ func testITTestIndexingThresholds(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(eMp, rcvMp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eMp, rcvMp)
|
||||
}
|
||||
if err := dataManager.RemoveIndexes(utils.CacheThresholdFilterIndexes, th.Tenant, utils.EmptyString); err != nil {
|
||||
t.Error(err)
|
||||
} else if _, err := dataManager.GetIndexes(
|
||||
utils.CacheThresholdFilterIndexes, th.Tenant,
|
||||
utils.EmptyString, false, false); err == nil || err != utils.ErrNotFound {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testITTestIndexingMetaNot(t *testing.T) {
|
||||
|
||||
@@ -75,6 +75,7 @@ var (
|
||||
testOnStorITAttributeProfile,
|
||||
testOnStorITFlush,
|
||||
testOnStorITIsDBEmpty,
|
||||
testOnStorITDispatcherHost,
|
||||
testOnStorITTestAttributeSubstituteIface,
|
||||
testOnStorITChargerProfile,
|
||||
testOnStorITDispatcherProfile,
|
||||
@@ -2029,6 +2030,40 @@ func testOnStorITAttributeProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITDispatcherHost(t *testing.T) {
|
||||
dpp := &DispatcherHost{
|
||||
Tenant: "cgrates.org",
|
||||
RemoteHost: &config.RemoteHost{
|
||||
ID: "ALL",
|
||||
Address: "127.0.0.1",
|
||||
Transport: utils.MetaJSON,
|
||||
},
|
||||
}
|
||||
if _, rcvErr := onStor.GetDispatcherHost("cgrates.org", "ALL2",
|
||||
true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrDSPHostNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
if err := onStor.SetDispatcherHost(dpp); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//get from database
|
||||
if rcv, err := onStor.GetDispatcherHost("cgrates.org", "ALL",
|
||||
false, false, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !(reflect.DeepEqual(dpp, rcv)) {
|
||||
t.Errorf("Expecting: %v, received: %v", dpp, rcv)
|
||||
}
|
||||
|
||||
if err := onStor.RemoveDispatcherHost(dpp.Tenant, dpp.ID); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//check database if removed
|
||||
if _, rcvErr := onStor.GetDispatcherHost("cgrates.org", "ALL",
|
||||
false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrDSPHostNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITTestAttributeSubstituteIface(t *testing.T) {
|
||||
attrProfile := &AttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"path"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -1635,6 +1636,15 @@ func testStorDBitCRUDTpResources(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].ThresholdIDs, rcv[0].ThresholdIDs, rcv[1].ThresholdIDs)
|
||||
}
|
||||
}
|
||||
|
||||
//tpIDs
|
||||
expIds := []string{"testTag1", "testTag2"}
|
||||
if tpIds, err := storDB.GetTpTableIds("testTPid", utils.TBLTPResources, utils.TPDistinctIds{utils.TenantCfg, utils.IDCfg}, nil, &utils.PaginatorWithSearch{}); err != nil {
|
||||
t.Error(err)
|
||||
} else if slices.Equal(tpIds, expIds) {
|
||||
t.Errorf("Expected %+v,Received %+v", expIds, tpIds)
|
||||
}
|
||||
|
||||
// REMOVE
|
||||
if err := storDB.RemTpData("", "testTPid", nil); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -547,7 +547,7 @@ func testSectConfigSReloadSessions(t *testing.T) {
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Expected OK received: %+v", reply)
|
||||
}
|
||||
cfgStr := "{\"sessions\":{\"alterable_fields\":[],\"attributes_conns\":[\"*internal\"],\"cdrs_conns\":[\"*internal\"],\"channel_sync_interval\":\"0\",\"chargers_conns\":[\"*internal\"],\"client_protocol\":1,\"debit_interval\":\"0\",\"default_usage\":{\"*any\":\"3h0m0s\",\"*data\":\"1048576\",\"*sms\":\"1\",\"*voice\":\"3h0m0s\"},\"enabled\":true,\"listen_bigob\":\"\",\"listen_bijson\":\"127.0.0.1:2014\",\"min_dur_low_balance\":\"0\",\"rals_conns\":[\"*internal\"],\"replication_conns\":[],\"resources_conns\":[\"*internal\"],\"routes_conns\":[\"*internal\"],\"scheduler_conns\":[],\"session_indexes\":[\"OriginID\"],\"session_ttl\":\"0\",\"stats_conns\":[],\"stir\":{\"allowed_attest\":[\"*any\"],\"default_attest\":\"A\",\"payload_maxduration\":\"-1\",\"privatekey_path\":\"\",\"publickey_path\":\"\"},\"store_session_costs\":false,\"terminate_attempts\":5,\"thresholds_conns\":[]}}"
|
||||
cfgStr := "{\"sessions\":{\"alterable_fields\":[],\"attributes_conns\":[\"*internal\"],\"cdrs_conns\":[\"*internal\"],\"channel_sync_interval\":\"0\",\"chargers_conns\":[\"*internal\"],\"client_protocol\":1,\"debit_interval\":\"0\",\"default_usage\":{\"*any\":\"3h0m0s\",\"*data\":\"1048576\",\"*sms\":\"1\",\"*voice\":\"3h0m0s\"},\"enabled\":true,\"listen_bigob\":\"\",\"listen_bijson\":\"127.0.0.1:2014\",\"min_dur_low_balance\":\"0\",\"rals_conns\":[\"*internal\"],\"replication_conns\":[],\"resources_conns\":[\"*internal\"],\"routes_conns\":[\"*internal\"],\"scheduler_conns\":[],\"session_indexes\":[\"OriginID\"],\"session_ttl\":\"0\",\"stale_chan_max_extra_usage\":\"0\",\"stats_conns\":[],\"stir\":{\"allowed_attest\":[\"*any\"],\"default_attest\":\"A\",\"payload_maxduration\":\"-1\",\"privatekey_path\":\"\",\"publickey_path\":\"\"},\"store_session_costs\":false,\"terminate_attempts\":5,\"thresholds_conns\":[]}}"
|
||||
var rpl string
|
||||
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
Reference in New Issue
Block a user