Revise postgres tp tables creation & fix tests

This commit is contained in:
arberkatellari
2025-07-02 16:55:20 +02:00
committed by Dan Christian Bogos
parent 7872d2f33b
commit 1d8e84892a
15 changed files with 849 additions and 9 deletions

View File

@@ -83,7 +83,7 @@ func TestDNSitSimple(t *testing.T) {
case utils.MetaMongo:
dnsCfgDIR = "dnsagent_mongo"
case utils.MetaPostgres:
t.SkipNow()
dnsCfgDIR = "dnsagent_postgres"
default:
t.Fatal("Unknown Database type")
}

View File

@@ -88,7 +88,7 @@ func TestAccSIT(t *testing.T) {
case utils.MetaMySQL:
accPrfConfigDIR = "tutmysql"
case utils.MetaPostgres:
t.SkipNow()
accPrfConfigDIR = "tutpostgres"
default:
t.Fatal("Unknown Database type")
}

View File

@@ -107,7 +107,7 @@ func TestActionsIT(t *testing.T) {
case utils.MetaMySQL:
actConfigDIR = "apis_actions_mysql"
case utils.MetaPostgres:
t.SkipNow()
actConfigDIR = "apis_actions_postgres"
default:
t.Fatal("Unknown Database type")
}

View File

@@ -74,7 +74,7 @@ func TestCacheSv1IT(t *testing.T) {
case utils.MetaMongo:
cacheConfigDIR = "tutmongo"
case utils.MetaPostgres:
t.SkipNow()
cacheConfigDIR = "tutpostgres"
default:
t.Fatal("Unknown Database type")
}

View File

@@ -76,13 +76,13 @@ var (
func TestCfgSIT(t *testing.T) {
switch *utils.DBType {
case utils.MetaInternal:
t.SkipNow()
cfgDIR = "apis_config_internal"
case utils.MetaMongo:
cfgDIR = "apis_config_mongo"
case utils.MetaMySQL:
cfgDIR = "apis_config_mysql"
case utils.MetaPostgres:
t.SkipNow()
cfgDIR = "apis_config_postgres"
default:
t.Fatal("Unknown Database type")
}

View File

@@ -0,0 +1,46 @@
{
"logger": {
"level": 7
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "10"
},
"stor_db": {
"db_type": "postgres",
"db_port": 5432,
"db_password": "CGRateS.org"
},
"actions": {
"enabled": true,
"thresholds_conns": ["*internal"],
"stats_conns": ["*internal"],
"accounts_conns": ["*internal"]
},
"accounts": {
"enabled": true
},
"stats": {
"enabled": true,
"store_interval": "-1",
"thresholds_conns": ["*internal"]
},
"thresholds": {
"enabled": true,
"store_interval": "-1",
"actions_conns": ["*internal"]
},
"admins": {
"enabled": true
}
}

View File

@@ -0,0 +1,139 @@
{
// CGRateS Configuration file
//
"general": {
"reply_timeout": "50s",
"caching_delay": "1s",
},
"logger": {
"level": 7
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "*internal",
},
"stor_db": {
"db_type": "*internal",
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
},
"attributes": {
"enabled": true,
"stats_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"accounts_conns": ["*localhost"]
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": ["*internal"]
},
"stats": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
"store_interval": "1s",
},
"routes": {
"enabled": true,
"prefix_indexed_fields":["*req.Destination"],
"stats_conns": ["*internal"],
"resources_conns": ["*internal"],
"rates_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rates_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
},
"migrator":{
"users_filters":["Account"],
},
"admins": {
"enabled": true,
},
"rates": {
"enabled": false
},
"actions": {
"enabled": true,
"accounts_conns": ["*localhost"]
},
"accounts": {
"enabled": true
},
"filters": {
"stats_conns": ["*internal"],
"resources_conns": ["*internal"],
"accounts_conns": ["*internal"],
},
"config_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "12"
},
"loaders": [
{
"id": "*default",
"enabled": true,
"tenant": "cgrates.org",
"lockfile_path": ".cgr.lck",
"tp_in_dir": "/usr/share/cgrates/tariffplans/testit",
"tp_out_dir": ""
}
]
}

View File

@@ -0,0 +1,143 @@
{
// CGRateS Configuration file
//
"general": {
"reply_timeout": "50s",
"caching_delay": "1s",
},
"logger": {
"level": 7
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "10", // data_db database name to connect to
},
"stor_db": {
"db_type": "postgres",
"db_port": 5432,
"db_password": "CGRateS.org"
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
},
"attributes": {
"enabled": true,
"stats_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"accounts_conns": ["*localhost"]
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": ["*internal"]
},
"stats": {
"enabled": true,
"store_interval": "1s",
"thresholds_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
"store_interval": "1s",
},
"routes": {
"enabled": true,
"prefix_indexed_fields":["*req.Destination"],
"stats_conns": ["*internal"],
"resources_conns": ["*internal"],
"rates_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rates_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
},
"migrator":{
"users_filters":["Account"],
},
"admins": {
"enabled": true,
},
"rates": {
"enabled": false
},
"actions": {
"enabled": true,
"accounts_conns": ["*localhost"]
},
"accounts": {
"enabled": true
},
"filters": {
"stats_conns": ["*internal"],
"resources_conns": ["*internal"],
"accounts_conns": ["*internal"],
},
"config_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "12"
},
"loaders": [
{
"id": "*default",
"enabled": true,
"tenant": "cgrates.org",
"lockfile_path": ".cgr.lck",
"tp_in_dir": "/usr/share/cgrates/tariffplans/testit",
"tp_out_dir": ""
}
]
}

View File

@@ -0,0 +1,72 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRAttributes",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.QueryName{*e164}:4986517174964"],
"flags": ["*authorize", "*attributes","*log"],
"request_fields":[
{"tag": "E164Address", "path": "*cgreq.E164Address",
"type": "*constant", "value": "4986517174964"},
{"tag": "NAPTRAddress", "path": "*cgreq.NAPTRAddress",
"type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "NAPTROrder", "path": "*rep.Answer.Order",
"type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference",
"type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags",
"type": "*constant", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service",
"type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegex", "path": "*rep.Answer.Regexp",
"type": "*variable", "value": "~*cgrep.Attributes.NAPTRAddress"}
]
},
{
"id": "AAttributes",
"filters": ["*string:~*vars.QueryType:A", "*string:~*vars.QueryName:dns.google."],
"flags": ["*authorize","*attributes","*log"],
"request_fields":[
{"tag": "Domain", "path": "*cgreq.Domain",
"type": "*constant", "value": "dns.google."},
{"tag": "ADomain0", "path": "*cgreq.Aip0",
"type": "*constant", "value": "*attributes"},
{"tag": "ADomain1", "path": "*cgreq.Aip1",
"type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "dns.google."},
{"tag": "Attl", "path": "*rep.Answer.Hdr.Ttl", "type": "*constant", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer.Hdr.Class", "type": "*constant", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer.Hdr.Rrtype", "type": "*constant", "value": "1"},
{"tag": "Aip0", "path": "*rep.Answer.A", "type": "*variable", "value": "~*cgrep.Attributes.Aip0"},
{"tag": "Aname1", "path": "*rep.Answer[1].Hdr.Name", "type": "*constant", "value": "dns.google."},
{"tag": "Attl1", "path": "*rep.Answer[1].Hdr.Ttl", "type": "*constant", "value": "300"},
{"tag": "Aclass1", "path": "*rep.Answer[1].Hdr.Class", "type": "*constant", "value": "1"},
{"tag": "Arrtype1", "path": "*rep.Answer[1].Hdr.Rrtype", "type": "*constant", "value": "1"},
{"tag": "Aip1", "path": "*rep.Answer[1].A", "type": "*variable", "value": "~*cgrep.Attributes.Aip1"}
]
},
{
"id": "SRVAttributes",
"filters": ["*string:~*vars.QueryType:SRV", "*string:~*vars.QueryName:_ldap._tcp.google.com."],
"flags": ["*authorize", "*attributes","*log"],
"request_fields":[
{"tag": "SRVAddress", "path": "*cgreq.SRVAddress",
"type": "*constant", "value": "_ldap._tcp.google.com."},
{"tag": "SRVName", "path": "*cgreq.SRVName",
"type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "_ldap._tcp.google.com."},
{"tag": "SRVPriority", "path": "*rep.Answer.Priority", "type": "*constant", "value": "5"},
{"tag": "SRVWeight", "path": "*rep.Answer.Weight", "type": "*constant", "value": "0"},
{"tag": "SRVPort", "path": "*rep.Answer.Port", "type": "*constant", "value": "389"},
{"tag": "SRVTarget", "path": "*rep.Answer.Target", "type": "*variable", "value": "~*cgrep.Attributes.SRVName"}
]
}
]
}
}

View File

@@ -0,0 +1,122 @@
{
// 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.
"logger": {
"level": 7
},
"stor_db": {
"db_type": "postgres",
"db_port": 5432,
"db_password": "CGRateS.org"
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"rates_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"routes_conns": ["*localhost"],
"opts": {
"*attributes": [
{
"Tenant": "*any",
"FilterIDs": [],
"Value": "true",
},
],
"*routes": [
{
"Tenant": "*any",
"FilterIDs": ["*string:~*req.Account:1001"],
"Value": "true",
},
{
"Tenant": "*any",
"FilterIDs": ["*string:~*req.Account:1002"],
"Value": "true",
},
{
"Tenant": "*any",
"FilterIDs": ["*string:~*req.Account:1003"],
"Value": "true",
},
],
}
},
"rates": {
"enabled": true,
},
"loaders": [
{
"enabled":true,
"id": "*default",
"tp_in_dir": "/usr/share/cgrates/tariffplans/dnsagent",
"tp_out_dir": "",
"lockfile_path": ".cgr.lck",
},
],
"cdrs": {
"enabled": true,
"rates_conns": ["*internal"],
},
"chargers": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"routes": {
"enabled": true,
},
"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",
},
"dns_agent": {
"enabled": true,
"listeners":[
{
"address":":2053",
"network":"udp"
},
{
"address":":2053",
"network":"tcp"
},
{
"address":":2054",
"network":"tcp-tls"
}
],
"sessions_conns": ["*localhost"],
},
"admins": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,52 @@
{
"dns_agent": {
"request_processors": [
{
"id": "DryRunNAPTR",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.QueryName{*e164}:4986517174963"],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "NAPTROrder", "path": "*rep.Answer.Order", "type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference", "type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags", "type": "*constant", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service", "type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "path": "*rep.Answer.Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"},
{"tag": "NAPTRReplacement", "path": "*rep.Answer.Replacement", "type": "*constant", "value": "."}
]
},
{
"id": "DryRunA",
"filters": ["*string:~*vars.QueryType:A", "*string:~*vars.QueryName:cgrates.org."],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "cgrates.org."},
{"tag": "Attl", "path": "*rep.Answer.Hdr.Ttl", "type": "*constant", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer.Hdr.Class", "type": "*constant", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer.Hdr.Rrtype", "type": "*constant", "value": "1"},
{"tag": "Aip", "path": "*rep.Answer.A", "type": "*constant", "value": "51.38.77.188"}
]
},
{
"id": "DryRunSRV",
"filters": ["*string:~*vars.QueryType:SRV", "*string:~*vars.QueryName:_sip._tcp.opensips.org."],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "_sip._tcp.opensips.org."},
{"tag": "SRVPort", "path": "*rep.Answer.Port", "type": "*constant", "value": "5060"},
{"tag": "SRVPriority", "path": "*rep.Answer.Priority", "type": "*constant", "value": "0"},
{"tag": "SRVWeight", "path": "*rep.Answer.Weight", "type": "*constant", "value": "50"},
{"tag": "SRVTarget", "path": "*rep.Answer.Target", "type": "*constant", "value": "opensips.org."}
]
}
]
}
}

View File

@@ -0,0 +1,117 @@
{
"dns_agent": {
"request_processors": [
{
"id": "OptsNAPTR",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.QueryName{*e164}:5986517174965", "*string:~*req.Option[0].Uri:sip:cgrates@cgrates.org"],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "NAPTROrder", "path": "*rep.Answer.Order", "type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference", "type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags", "type": "*constant", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service", "type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "path": "*rep.Answer.Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"},
{"tag": "NAPTRReplacement", "path": "*rep.Answer.Replacement", "type": "*constant", "value": "."},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*constant", "value": "sip:cgrates@cgrates.co"},
{"tag": "Opts2", "path": "*rep.Option.Uri", "type": "*group", "value": "sip:cgrates@cgrates.net", "new_branch":true},
{"tag": "Opts3", "path": "*rep.Option[0].Uri", "type": "*constant", "value": "sip:cgrates@cgrates.com"}
]
},
{
"id": "OptsWithAttributes",
"filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.QueryName{*e164}:5986517174967"],
"flags": ["*event","*attributes"],
"request_fields":[
{"tag": "Origin", "path": "*cgreq.Origin", "type": "*variable", "value": "~*req.Option[0].Uri{*sipuri_user}"},
{"tag": "Domanin", "path": "*cgreq.Domanin", "type": "*variable", "value": "~*vars.QueryName{*e164Domain}"},
{"tag": "NewSipURI", "path": "*cgreq.SipURI", "type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "NAPTROrder", "path": "*rep.Answer.Order", "type": "*constant", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference", "type": "*constant", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags", "type": "*constant", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service", "type": "*constant", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "path": "*rep.Answer.Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"},
{"tag": "NAPTRReplacement", "path": "*rep.Answer.Replacement", "type": "*constant", "value": "."},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*variable", "value": "~*cgrep.Attributes[*raw].SipURI", "mandatory": true}
]
},
{
"id": "OptsA",
"filters": ["*string:~*vars.QueryType:A", "*string:~*vars.QueryName:example.com.", "*string:~*req.Option[0].Uri:sip:cgrates@cgrates.org"],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "example.com."},
{"tag": "Attl", "path": "*rep.Answer.Hdr.Ttl", "type": "*constant", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer.Hdr.Class", "type": "*constant", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer.Hdr.Rrtype", "type": "*constant", "value": "1"},
{"tag": "Aip", "path": "*rep.Answer.A", "type": "*constant", "value": "93.184.216.34"},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*constant", "value": "sip:cgrates@cgrates.co"},
{"tag": "Opts2", "path": "*rep.Option.Uri", "type": "*group", "value": "sip:cgrates@cgrates.net", "new_branch":true},
{"tag": "Opts3", "path": "*rep.Option[0].Uri", "type": "*constant", "value": "sip:cgrates@cgrates.com"}
]
},
{
"id": "AOptsWithAttributes",
"filters": ["*string:~*vars.QueryType:A", "*string:~*vars.QueryName:opendns.com."],
"flags": ["*event","*attributes"],
"request_fields":[
{"tag": "Origin", "path": "*cgreq.AOrigin", "type": "*variable", "value": "~*req.Option[0].Uri{*sipuri_user}"},
{"tag": "Domain", "path": "*cgreq.ASIPDomain", "type": "*variable", "value": "~*vars.QueryName"},
{"tag": "NewSipURI", "path": "*cgreq.SipURI", "type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "example.com."},
{"tag": "Attl", "path": "*rep.Answer.Hdr.Ttl", "type": "*constant", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer.Hdr.Class", "type": "*constant", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer.Hdr.Rrtype", "type": "*constant", "value": "1"},
{"tag": "Aip", "path": "*rep.Answer.A", "type": "*constant", "value": "146.112.62.105"},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*variable", "value": "~*cgrep.Attributes[*raw].SipURI", "mandatory": true}
]
},
{
"id": "OptsSRV",
"filters": ["*string:~*vars.QueryType:SRV", "*string:~*vars.QueryName:_matrix._tcp.matrix.org.", "*string:~*req.Option[0].Uri:sip:cgrates@cgrates.org"],
"flags": ["*dryRun","*log"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}
],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "_xmpp-client._tcp.xmpp.org."},
{"tag": "SRVPriority", "path": "*rep.Answer.Priority", "type": "*constant", "value": "10"},
{"tag": "SRVWeight", "path": "*rep.Answer.Weight", "type": "*constant", "value": "5"},
{"tag": "SRVPort", "path": "*rep.Answer.Port", "type": "*constant", "value": "8443"},
{"tag": "SRVTarget", "path": "*rep.Answer.Target", "type": "*constant", "value": "matrix-federation.matrix.org.cdn.cloudflare.net."},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*constant", "value": "sip:cgrates@cgrates.co"},
{"tag": "Opts2", "path": "*rep.Option.Uri", "type": "*group", "value": "sip:cgrates@cgrates.net", "new_branch":true},
{"tag": "Opts3", "path": "*rep.Option[0].Uri", "type": "*constant", "value": "sip:cgrates@cgrates.com"}
]
},
{
"id": "SRVOptsWithAttributes",
"filters": ["*string:~*vars.QueryType:SRV", "*string:~*vars.QueryName:_sip._udp.opensips.org."],
"flags": ["*event","*attributes"],
"request_fields":[
{"tag": "Origin", "path": "*cgreq.SRVOrigin", "type": "*variable", "value": "~*req.Option[0].Uri{*sipuri_user}"},
{"tag": "Domain", "path": "*cgreq.SRVDomain", "type": "*variable", "value": "~*vars.QueryName"},
{"tag": "NewSipURI", "path": "*cgreq.SipURI", "type": "*constant", "value": "*attributes"}
],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer.Hdr.Name", "type": "*constant", "value": "_sip._udp.opensips.org."},
{"tag": "SRVPriority", "path": "*rep.Answer.Priority", "type": "*constant", "value": "0"},
{"tag": "SRVWeight", "path": "*rep.Answer.Weight", "type": "*constant", "value": "50"},
{"tag": "SRVPort", "path": "*rep.Answer.Port", "type": "*constant", "value": "5060"},
{"tag": "SRVTarget", "path": "*rep.Answer.Target", "type": "*constant", "value": "opensips.org."},
{"tag": "Opts", "path": "*rep.Option.Uri", "type": "*variable", "value": "~*cgrep.Attributes[*raw].SipURI", "mandatory": true}
]
}
]
}
}

View File

@@ -0,0 +1,150 @@
{
"dns_agent": {
"request_processors": [
{
"id": "NAPTRRoutesQuery",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.QueryName{*e164}:4986517174965"],
"flags": ["*message", "*routes","*continue"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.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
],
},
{
"id": "NAPTRSuppliersOneSupplier",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.QueryName{*e164}:4986517174965",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:1"],
"flags": ["*none","*continue"], // do not send request to CGRateS
"reply_fields":[
{"tag": "NAPTROrder", "path": "*rep.Answer.Order",
"type": "*group", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference",
"type": "*group", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags",
"type": "*group", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service",
"type": "*group", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "path": "*rep.Answer.Regexp", "type": "*group",
"value": "~*cgrep.RouteProfiles[0].Routes[0].RouteParameters"},
{"tag": "NAPTRReplacement", "path": "*rep.Answer.Replacement",
"type": "*group", "value": "."},
],
},
{
"id": "NAPTRSuppliersTwoSuppliers",
"filters": ["*string:~*vars.QueryType:NAPTR",
"*string:~*vars.QueryName{*e164}:4986517174965",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:2"],
"flags": ["*none","*continue"],
"reply_fields":[
{"tag": "NAPTROrder", "type": "*group", "new_branch": true,
"path": "*rep.Answer.Order", "value": "100"},
{"tag": "NAPTRPreference", "path": "*rep.Answer.Preference",
"type": "*group", "value": "10"},
{"tag": "NAPTRFlags", "path": "*rep.Answer.Flags",
"type": "*group", "value": "U"},
{"tag": "NAPTRService", "path": "*rep.Answer.Service",
"type": "*group", "value": "E2U+SIP"},
{"tag": "NAPTRRegexp", "path": "*rep.Answer.Regexp", "type": "*group",
"value": "~*cgrep.RouteProfiles[0].Routes[1].RouteParameters"},
{"tag": "NAPTRReplacement", "path": "*rep.Answer.Replacement",
"type": "*group", "value": "."},
],
},
{
"id": "ARoutesQuery",
"filters": ["*string:~*vars.QueryType:A",
"*string:~*vars.QueryName:go.dev."],
"flags": ["*message", "*routes","*continue"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1002"}
],
"reply_fields":[
{"tag": "DispatchReply", "type": "*none",
"blocker": true}
]
},
{
"id": "ASuppliersOneSupplier",
"filters": ["*string:~*vars.QueryType:A",
"*string:~*vars.QueryName:go.dev.",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:2"],
"flags": ["*none","*continue"],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer.Hdr.Name", "type": "*group", "value": "go.dev."},
{"tag": "Attl", "path": "*rep.Answer.Hdr.Ttl", "type": "*group", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer.Hdr.Class", "type": "*group", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer.Hdr.Rrtype", "type": "*group", "value": "1"},
{"tag": "Aip", "path": "*rep.Answer.A", "type": "*group", "value": "~*cgrep.RouteProfiles[0].Routes[0].RouteParameters"}
]
},
{
"id": "ASuppliersTwoSuppliers",
"filters": ["*string:~*vars.QueryType:A",
"*string:~*vars.QueryName:go.dev.",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:2"],
"flags": ["*none","*continue"],
"reply_fields":[
{"tag": "Aname", "path": "*rep.Answer[1].Hdr.Name", "type": "*group", "value": "go.dev."},
{"tag": "Attl", "path": "*rep.Answer[1].Hdr.Ttl", "type": "*group", "value": "300"},
{"tag": "Aclass", "path": "*rep.Answer[1].Hdr.Class", "type": "*group", "value": "1"},
{"tag": "Arrtype", "path": "*rep.Answer[1].Hdr.Rrtype", "type": "*group", "value": "1"},
{"tag": "Aip", "path": "*rep.Answer[1].A", "type": "*group", "value": "~*cgrep.RouteProfiles[0].Routes[1].RouteParameters"}
]
},
{
"id": "SRVRoutesQuery",
"filters": ["*string:~*vars.QueryType:SRV",
"*string:~*vars.QueryName:_xmpp-client._tcp.xmpp.org."],
"flags": ["*message", "*routes","*continue"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1003"}
],
"reply_fields":[
{"tag": "DispatchReply", "type": "*none",
"blocker": true}
]
},
{
"id": "SRVSuppliersOneSupplier",
"filters": ["*string:~*vars.QueryType:SRV",
"*string:~*vars.QueryName:_xmpp-client._tcp.xmpp.org.",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:1"],
"flags": ["*none","*continue"],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer.Hdr.Name", "type": "*group", "value": "_xmpp-client._tcp.xmpp.org."},
{"tag": "SRVPriority", "path": "*rep.Answer.Priority", "type": "*group", "value": "1"},
{"tag": "SRVWeight", "path": "*rep.Answer.Weight", "type": "*group", "value": "1"},
{"tag": "SRVPort", "path": "*rep.Answer.Port", "type": "*group", "value": "9222"},
{"tag": "SRVTarget", "path": "*rep.Answer.Target", "type": "*group", "value": "~*cgrep.RouteProfiles[0].Routes[0].RouteParameters"}
]
},
{
"id": "SRVSuppliersTwoSuppliers",
"filters": ["*string:~*vars.QueryType:SRV",
"*string:~*vars.QueryName:_xmpp-client._tcp.xmpp.org.",
"*gte:~*cgrep.RouteProfiles.Length:1",
"*gte:~*cgrep.RouteProfiles[0].Routes.Length:2"],
"flags": ["*none","*continue"],
"reply_fields":[
{"tag": "SRVHdr", "path": "*rep.Answer[1].Hdr.Name", "type": "*group", "value": "_xmpp-client._tcp.xmpp.org."},
{"tag": "SRVPriority", "path": "*rep.Answer[1].Priority", "type": "*group", "value": "1"},
{"tag": "SRVWeight", "path": "*rep.Answer[1].Weight", "type": "*group", "value": "1"},
{"tag": "SRVPort", "path": "*rep.Answer[1].Port", "type": "*group", "value": "9222"},
{"tag": "SRVTarget", "path": "*rep.Answer[1].Target", "type": "*group", "value": "~*cgrep.RouteProfiles[0].Routes[1].RouteParameters"}
]
}
],
},
}

View File

@@ -156,7 +156,7 @@ CREATE TABLE tp_routes (
"id" varchar(64) NOT NULL,
"filter_ids" varchar(64) NOT NULL,
"weights" varchar(64) NOT NULL,
`blockers` varchar(64) NOT NULL,
"blockers" varchar(64) NOT NULL,
"sorting" varchar(32) NOT NULL,
"sorting_parameters" varchar(64) NOT NULL,
"route_id" varchar(32) NOT NULL,

View File

@@ -36,10 +36,9 @@ func TestSessionBasics(t *testing.T) {
dbcfg = engine.InternalDBCfg
case utils.MetaMySQL:
case utils.MetaMongo:
t.SkipNow() // unfinished look into errors
t.SkipNow() // unfinished look into errors with decimals in CDRs
dbcfg = engine.MongoDBCfg
case utils.MetaPostgres:
t.SkipNow() // unfinished look into postgres flush
dbcfg = engine.PostgresDBCfg
default:
t.Fatal("unsupported dbtype value")