Updated IT tests

This commit is contained in:
adragusin
2020-01-17 17:55:00 +02:00
committed by Trial97
parent c17dc6cd46
commit 5465d8c565
44 changed files with 2577 additions and 121 deletions

View File

@@ -18,10 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package agents
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"os/exec"
"path"
"strings"
@@ -38,11 +36,8 @@ import (
)
var (
waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
interations = flag.Int("iterations", 1, "Number of iterations to do for dry run simulation")
replyTimeout = flag.String("reply_timeout", "1s", "Maximum duration to wait for a reply")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication")
daCfgPath, diamConfigDIR string
daCfg *config.CGRConfig
@@ -70,17 +65,6 @@ var (
}
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
// Test start here
func TestDiamItTcp(t *testing.T) {
engine.KillEngine(0)

View File

@@ -34,36 +34,53 @@ import (
var (
dnsCfgPath string
dnsCfgDIR string
dnsCfg *config.CGRConfig
dnsRPC *rpc.Client
dnsClnt *dns.Conn // so we can cache the connection
sTestsDNS = []func(t *testing.T){
testDNSitInitCfg,
testDNSitResetDB,
testDNSitStartEngine,
testDNSitApierRpcConn,
testDNSitTPFromFolder,
testDNSitClntConn,
testDNSitClntNAPTRDryRun,
testDNSitClntNAPTRAttributes,
testDNSitClntNAPTRSuppliers,
testDNSitStopEngine,
}
)
var sTestsDNS = []func(t *testing.T){
testDNSitResetDB,
testDNSitStartEngine,
testDNSitApierRpcConn,
testDNSitTPFromFolder,
testDNSitClntConn,
testDNSitClntNAPTRDryRun,
testDNSitClntNAPTRAttributes,
testDNSitClntNAPTRSuppliers,
testDNSitStopEngine,
func TestDNSitSimple(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
dnsCfgDIR = "dnsagent_internal"
case utils.MetaSQL:
dnsCfgDIR = "dnsagent_mysql"
case utils.MetaMongo:
dnsCfgDIR = "dnsagent_mongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
for _, stest := range sTestsDNS {
t.Run(dnsCfgDIR, stest)
}
}
func TestDNSitSimple(t *testing.T) {
dnsCfgPath = path.Join(*dataDir, "conf", "samples", "dnsagent")
// Init config first
// Init config
func testDNSitInitCfg(t *testing.T) {
var err error
dnsCfgPath = path.Join(*dataDir, "conf", "samples", dnsCfgDIR)
dnsCfg, err = config.NewCGRConfigFromPath(dnsCfgPath)
if err != nil {
t.Error(err)
}
dnsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(dnsCfg)
for _, stest := range sTestsDNS {
t.Run("dnsAgent", stest)
}
}
// Remove data in both rating and accounting db

View File

@@ -40,6 +40,7 @@ import (
var (
haCfgPath string
haCfgDIR string
haCfg *config.CGRConfig
haRPC *rpc.Client
httpC *http.Client // so we can cache the connection
@@ -48,6 +49,8 @@ var (
)
var sTestsHA = []func(t *testing.T){
testHAitInitCfg,
testHAitHttp,
testHAitResetDB,
testHAitStartEngine,
testHAitApierRpcConn,
@@ -60,64 +63,82 @@ var sTestsHA = []func(t *testing.T){
testHAitStopEngine,
}
func TestHAitSimple(t *testing.T) {
haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagent")
func TestHAit(t *testing.T) {
var configDir, configDirTls string
switch *dbType {
case utils.MetaInternal:
configDir = "httpagent_internal"
configDirTls = "httpagenttls_internal"
case utils.MetaSQL:
configDir = "httpagent_mysql"
configDirTls = "httpagenttls_mysql"
case utils.MetaMongo:
configDir = "httpagent_mongo"
configDirTls = "httpagenttls_mongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
if *encoding == utils.MetaGOB {
haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagent_gob")
configDir += "_gob"
configDirTls += "_gob"
}
// Init config first
var err error
haCfg, err = config.NewCGRConfigFromPath(haCfgPath)
if err != nil {
t.Error(err)
}
haCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(haCfg)
httpC = new(http.Client)
//Run the tests without Tls
isTls = false
haCfgDIR = configDir
for _, stest := range sTestsHA {
t.Run("httpagent", stest)
t.Run(haCfgDIR, stest)
}
//Run the tests with Tls
isTls = true
haCfgDIR = configDirTls
for _, stest := range sTestsHA {
t.Run(haCfgDIR, stest)
}
}
func TestHA2itWithTls(t *testing.T) {
haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagenttls")
if *encoding == utils.MetaGOB {
haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagenttls_gob")
}
// Init config first
// Init config first
func testHAitInitCfg(t *testing.T) {
var err error
haCfgPath = path.Join(*dataDir, "conf", "samples", haCfgDIR)
haCfg, err = config.NewCGRConfigFromPath(haCfgPath)
if err != nil {
t.Error(err)
}
haCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(haCfg)
//make http client with tls
cert, err := tls.LoadX509KeyPair(haCfg.TlsCfg().ClientCerificate, haCfg.TlsCfg().ClientKey)
if err != nil {
t.Error(err)
}
}
// Load CA cert
caCert, err := ioutil.ReadFile(haCfg.TlsCfg().CaCertificate)
if err != nil {
t.Error(err)
}
rootCAs, _ := x509.SystemCertPool()
if ok := rootCAs.AppendCertsFromPEM(caCert); !ok {
t.Error("Cannot append CA")
}
func testHAitHttp(t *testing.T) {
if isTls {
// With Tls
//make http client with tls
cert, err := tls.LoadX509KeyPair(haCfg.TlsCfg().ClientCerificate, haCfg.TlsCfg().ClientKey)
if err != nil {
t.Error(err)
}
// Load CA cert
caCert, err := ioutil.ReadFile(haCfg.TlsCfg().CaCertificate)
if err != nil {
t.Error(err)
}
rootCAs, _ := x509.SystemCertPool()
if ok := rootCAs.AppendCertsFromPEM(caCert); !ok {
t.Error("Cannot append CA")
}
// Setup HTTPS client
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: rootCAs,
}
transport := &http.Transport{TLSClientConfig: tlsConfig}
httpC = &http.Client{Transport: transport}
isTls = true
for _, stest := range sTestsHA {
t.Run("httpagenttls", stest)
// Setup HTTPS client
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: rootCAs,
}
transport := &http.Transport{TLSClientConfig: tlsConfig}
httpC = &http.Client{Transport: transport}
} else {
// Without Tls
httpC = new(http.Client)
}
}

47
agents/lib_test.go Normal file
View File

@@ -0,0 +1,47 @@
/*
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 agents
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
var (
waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}

View File

@@ -55,7 +55,7 @@ var (
singlecpu = cgrEngineFlags.Bool("singlecpu", false, "Run on single CPU core")
syslogger = cgrEngineFlags.String("logger", "", "logger <*syslog|*stdout>")
nodeID = cgrEngineFlags.String("node_id", "", "The node ID of the engine")
logLevel = cgrEngineFlags.Int("log_level", 6, "Log level (0-emergency to 7-debug)")
logLevel = cgrEngineFlags.Int("log_level", -1, "Log level (0-emergency to 7-debug)")
cfg *config.CGRConfig
)

View File

@@ -0,0 +1,76 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
//
// This file contains the default configuration hardcoded into CGRateS.
// This is what you get when you load CGRateS with an empty configuration file.
"general": {
"log_level": 7, // control the level of messages logged (0-emerg to 7-debug)
},
"data_db": {
"db_type": "*internal",
},
"stor_db": {
"db_type": "*internal",
},
"schedulers": {
"enabled": true,
"cdrs_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"suppliers_conns": ["*localhost"],
},
"rals": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"rals_conns": ["*internal"],
},
"chargers": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"suppliers": {
"enabled": true,
},
"dns_agent": {
"enabled": true,
"listen": ":2053",
"sessions_conns": ["*localhost"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,31 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRAttributes",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174964"],
"flags": ["*auth", "*attributes"],
"request_fields":[
{"tag": "E164Address", "field_id": "E164Address",
"type": "*constant", "value": "4986517174964"},
{"tag": "NAPTRAddress", "field_id": "NAPTRAddress",
"type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order",
"type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegex", "field_id": "Regexp",
"type": "*variable", "value": "~*cgrep.Attributes.NAPTRAddress"},
],
},
],
},
}

View File

@@ -0,0 +1,81 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
//
// This file contains the default configuration hardcoded into CGRateS.
// This is what you get when you load CGRateS with an empty configuration file.
"general": {
"log_level": 7, // control the level of messages logged (0-emerg to 7-debug)
},
"data_db": {
"db_type": "mongo",
"db_name": "10",
"db_port": 27017,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"schedulers": {
"enabled": true,
"cdrs_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"suppliers_conns": ["*localhost"],
},
"rals": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"rals_conns": ["*internal"],
},
"chargers": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"suppliers": {
"enabled": true,
},
"dns_agent": {
"enabled": true,
"listen": ":2053",
"sessions_conns": ["*localhost"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,24 @@
{
"dns_agent": {
"request_processors": [
{
"id": "DryRunNAPTR",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174963"],
"flags": ["*dryrun"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
],
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order", "type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference", "type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags", "type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service", "type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"},
{"tag": "NAPTRReplacement", "field_id": "Replacement", "type": "*constant", "value": "."},
],
},
],
},
}

View File

@@ -0,0 +1,66 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRSuppliersQuery",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965"],
"flags": ["*message", "*suppliers"],
"request_fields":[
{"tag": "TOR", "field_id": "Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile
],
"reply_fields":[
{"tag": "DispatchReply", "type": "*none",
"blocker": true}, // enforces continue_on_success so we can check answer with filters
],
"continue": true,
},
{
"id": "NAPTRSuppliersOneSupplier",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965",
"*gte:~*cgrep.Suppliers.Count:1"],
"flags": ["*none"], // do not send request to CGRateS
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order",
"type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
"value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"},
{"tag": "NAPTRReplacement", "field_id": "Replacement",
"type": "*constant", "value": "."},
],
"continue": true,
},
{
"id": "NAPTRSuppliersTwoSuppliers",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965",
"*gte:~*cgrep.Suppliers.Count:2"],
"flags": ["*none"],
"reply_fields":[
{"tag": "NAPTROrder", "type": "*constant", "new_branch": true,
"field_id": "Order", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
"value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"},
{"tag": "NAPTRReplacement", "field_id": "Replacement",
"type": "*constant", "value": "."},
],
"continue": true,
},
],
},
}

View File

@@ -0,0 +1,31 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRAttributes",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174964"],
"flags": ["*auth", "*attributes"],
"request_fields":[
{"tag": "E164Address", "field_id": "E164Address",
"type": "*constant", "value": "4986517174964"},
{"tag": "NAPTRAddress", "field_id": "NAPTRAddress",
"type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order",
"type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegex", "field_id": "Regexp",
"type": "*variable", "value": "~*cgrep.Attributes.NAPTRAddress"},
],
},
],
},
}

View File

@@ -0,0 +1,24 @@
{
"dns_agent": {
"request_processors": [
{
"id": "DryRunNAPTR",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174963"],
"flags": ["*dryrun"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
],
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order", "type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference", "type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags", "type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service", "type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"},
{"tag": "NAPTRReplacement", "field_id": "Replacement", "type": "*constant", "value": "."},
],
},
],
},
}

View File

@@ -0,0 +1,66 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRSuppliersQuery",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965"],
"flags": ["*message", "*suppliers"],
"request_fields":[
{"tag": "TOR", "field_id": "Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile
],
"reply_fields":[
{"tag": "DispatchReply", "type": "*none",
"blocker": true}, // enforces continue_on_success so we can check answer with filters
],
"continue": true,
},
{
"id": "NAPTRSuppliersOneSupplier",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965",
"*gte:~*cgrep.Suppliers.Count:1"],
"flags": ["*none"], // do not send request to CGRateS
"reply_fields":[
{"tag": "NAPTROrder", "field_id": "Order",
"type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
"value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"},
{"tag": "NAPTRReplacement", "field_id": "Replacement",
"type": "*constant", "value": "."},
],
"continue": true,
},
{
"id": "NAPTRSuppliersTwoSuppliers",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.E164Address:4986517174965",
"*gte:~*cgrep.Suppliers.Count:2"],
"flags": ["*none"],
"reply_fields":[
{"tag": "NAPTROrder", "type": "*constant", "new_branch": true,
"field_id": "Order", "value": "100"},
{"tag": "NAPTRPreference", "field_id": "Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "field_id": "Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "field_id": "Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
"value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"},
{"tag": "NAPTRReplacement", "field_id": "Replacement",
"type": "*constant", "value": "."},
],
"continue": true,
},
],
},
}

View File

@@ -0,0 +1,64 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,71 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
},
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["conn1"],
"cdrs_conns": ["conn1"],
"rals_conns": ["conn1"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,67 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,168 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["*localhost"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,73 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
},
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["conn1"],
"cdrs_conns": ["conn1"],
"rals_conns": ["conn1"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,168 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["conn1"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,168 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["*localhost"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,168 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["conn1"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,75 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
"rpc_json_tls":":2022",
"rpc_gob_tls":":2023",
"http_tls": "localhost:2280",
},
"tls": {
"server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt)
"server_key":"/usr/share/cgrates/tls/server.key", // path to server key
"client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt)
"client_key":"/usr/share/cgrates/tls/client.key", // path to client key
"ca_certificate":"/usr/share/cgrates/tls/ca.crt",
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,84 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
"rpc_json_tls":":2022",
"rpc_gob_tls":":2023",
"http_tls": "localhost:2280",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
},
},
"tls": {
"server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt)
"server_key":"/usr/share/cgrates/tls/server.key", // path to server key
"client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt)
"client_key":"/usr/share/cgrates/tls/client.key", // path to client key
"ca_certificate":"/usr/share/cgrates/tls/ca.crt",
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["conn1"],
"cdrs_conns": ["conn1"],
"rals_conns": ["conn1"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,77 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
"rpc_json_tls":":2022",
"rpc_gob_tls":":2023",
"http_tls": "localhost:2280",
},
"tls": {
"server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt)
"server_key":"/usr/share/cgrates/tls/server.key", // path to server key
"client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt)
"client_key":"/usr/share/cgrates/tls/client.key", // path to client key
"ca_certificate":"/usr/share/cgrates/tls/ca.crt",
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,169 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["*localhost"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,85 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
"rpc_json_tls":":2022",
"rpc_gob_tls":":2023",
"http_tls": "localhost:2280",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
},
},
"tls": {
"server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt)
"server_key":"/usr/share/cgrates/tls/server.key", // path to server key
"client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt)
"client_key":"/usr/share/cgrates/tls/client.key", // path to client key
"ca_certificate":"/usr/share/cgrates/tls/ca.crt",
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
"max_increments":3000000,
},
"schedulers": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*internal"],
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"attributes_conns": ["conn1"],
"cdrs_conns": ["conn1"],
"rals_conns": ["conn1"],
"chargers_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,169 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["conn1"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,169 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["*localhost"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["*localhost"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -0,0 +1,169 @@
{
"http_agent": [
{
"id": "conecto1",
"url": "/conecto",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*xml",
"request_processors": [
{
"id": "OutboundAUTHDryRun",
"filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed",
"value": "~*req.MCC;/", "mandatory": true},
{"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed",
"value": "Val1"},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant",
"value": "1200", "blocker": true},
{"tag": "Unused", "field_id": "response.Unused", "type": "*constant",
"value": "0"},
],
},
{
"id": "OutboundAUTH",
"filters": ["*string:~*req.request_type:OutboundAUTH"],
"tenant": "cgrates.org",
"flags": [ "*auth", "*accounts", "*attributes"],
"request_fields":[
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CallID", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.Msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.Destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant",
"value": "*now", "mandatory": true},
],
"reply_fields":[
{"tag": "Allow", "field_id": "response.Allow", "type": "*constant",
"value": "1", "mandatory": true},
{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed",
"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
],
},
{
"id": "mtcall_cdr",
"filters": ["*string:~*req.request_type:MTCALL_CDR"],
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host",
"mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.msisdn", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.destination", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.leg_duration;s", "mandatory": true},
],
"reply_fields":[
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
"field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true},
{"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed",
"value": "~*req.CDR_ID", "mandatory": true},
{"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant",
"value": "1", "mandatory": true},
],
}
],
},
{
"id": "conecto_xml",
"url": "/conecto_xml",
"sessions_conns": ["conn1"],
"request_payload": "*xml",
"reply_payload": "*xml",
"request_processors": [
{
"id": "cdr_from_xml",
"tenant": "cgrates.org",
"flags": ["*cdrs"],
"request_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant",
"value": "*data", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
"value": "*pseudoprepaid", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
"value": "~*req.complete-datasession-notification.customerid", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed",
"value": "~*req.complete-datasession-notification.username", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed",
"value": "~*req.complete-datasession-notification.userid", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed",
"value": "~*req.complete-datasession-notification.createtime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed",
"value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true},
],
"reply_fields":[],
}
],
},
{
"id": "textplain",
"url": "/textplain",
"sessions_conns": ["conn1"],
"request_payload": "*url",
"reply_payload": "*text_plain",
"request_processors": [
{
"id": "TextPlainDryRun",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Variable1", "type": "*variable",
"value": "Hola1", "mandatory": true},
{"tag": "Field2", "field_id": "Variable2", "type": "*variable",
"value": "Hola2", "mandatory": true},
{"tag": "Field3", "field_id": "ComposedVar", "type": "*composed",
"value": "Test", "mandatory": true},
{"tag": "Field4", "field_id": "ComposedVar", "type": "*composed",
"value": "Composed", "mandatory": true},
{"tag": "Field5", "field_id": "Item1.1", "type": "*variable",
"value": "Val1", "mandatory": true},
],
"continue": true,
},
{
"id": "TextPlainDryRun2",
"filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"],
"tenant": "cgrates.org",
"flags": ["*dryrun"],
"request_fields":[
],
"reply_fields":[
{"tag": "Field1", "field_id": "Item1.1", "type": "*variable",
"value": "Val2", "mandatory": true},
],
},
],
},
],
}

View File

@@ -17,6 +17,9 @@ echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal
ers_internal=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal
lds_internal=$?
# SQL
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql
@@ -30,7 +33,9 @@ en_sql=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql
ers_sql=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*sql
lds_sql=$?
# Mongo
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo
@@ -44,7 +49,9 @@ en_mongo=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo
ers_mongo=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo
lds_mongo=$?
# Postgres
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres
@@ -58,6 +65,9 @@ en_postgres=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres
ers_postgres=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres
lds_postgres=$?
echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration'
go test github.com/cgrates/cgrates/cdrc -tags=integration
@@ -82,9 +92,6 @@ mgr=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration'
go test github.com/cgrates/cgrates/dispatchers -tags=integration
dis=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration'
go test github.com/cgrates/cgrates/loaders -tags=integration
lds=$?
echo 'go test github.com/cgrates/cgrates/services -tags=integration'
go test github.com/cgrates/cgrates/services -tags=integration
srv=$?

47
loaders/lib_test.go Normal file
View File

@@ -0,0 +1,47 @@
/*
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 loaders
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
var (
waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}

View File

@@ -20,11 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package loaders
import (
"errors"
"flag"
"io/ioutil"
"net/rpc"
"net/rpc/jsonrpc"
"os"
"path"
"reflect"
@@ -39,61 +36,54 @@ import (
var (
loaderCfgPath string
loaderCfgDIR string //run tests for specific configuration
loaderCfg *config.CGRConfig
loaderRPC *rpc.Client
loaderDataDir = "/usr/share/cgrates"
loaderConfigDIR string //run tests for specific configuration
loaderPathIn, loaderPathOut string
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
sTestsLoader = []func(t *testing.T){
testLoaderMakeFolders,
testLoaderInitCfg,
testLoaderResetDataDB,
testLoaderStartEngine,
testLoaderRPCConn,
testLoaderPopulateData,
testLoaderLoadAttributes,
testLoaderVerifyOutDir,
testLoaderCheckAttributes,
testLoaderKillEngine,
}
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
var sTestsLoader = []func(t *testing.T){
testLoaderMakeFolders,
testLoaderInitCfg,
testLoaderResetDataDB,
testLoaderStartEngine,
testLoaderRPCConn,
testLoaderPopulateData,
testLoaderLoadAttributes,
testLoaderVerifyOutDir,
testLoaderCheckAttributes,
testLoaderKillEngine,
}
//Test start here
func TestLoaderITMySql(t *testing.T) {
loaderConfigDIR = "tutmysql"
for _, stest := range sTestsLoader {
t.Run(loaderConfigDIR, stest)
func TestLoaderIT(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
loaderCfgDIR = "tutinternal"
case utils.MetaSQL:
loaderCfgDIR = "tutmysql"
case utils.MetaMongo:
loaderCfgDIR = "tutmongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
}
func TestLoaderITMongo(t *testing.T) {
loaderConfigDIR = "tutmongo"
loaderCfgDIR = "tutmysql"
for _, stest := range sTestsLoader {
t.Run(loaderConfigDIR, stest)
t.Run(loaderCfgDIR, stest)
}
}
func testLoaderInitCfg(t *testing.T) {
var err error
loaderCfgPath = path.Join(loaderDataDir, "conf", "samples", "loaders", loaderConfigDIR)
loaderCfgPath = path.Join(*dataDir, "conf", "samples", "loaders", loaderCfgDIR)
loaderCfg, err = config.NewCGRConfigFromPath(loaderCfgPath)
if err != nil {
t.Fatal(err)
}
loaderCfg.DataFolderPath = loaderDataDir // Share DataFolderPath through config towards StoreDb for Flush()
loaderCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(loaderCfg)
}