Updated caps birpc server

This commit is contained in:
Trial97
2021-07-14 14:11:49 +03:00
committed by Dan Christian Bogos
parent 4fe51d4d05
commit 8ed0a145f9
9 changed files with 65 additions and 15 deletions

View File

@@ -146,6 +146,9 @@ func newCapsBiRPCJSONCodec(conn conn, caps *engine.Caps, anz *analyzers.Analyzer
}
func newCapsBiRPCCodec(sc rpc2.Codec, caps *engine.Caps) rpc2.Codec {
if !caps.IsLimited() {
return sc
}
return &capsBiRPCCodec{
sc: sc,
caps: caps,

View File

@@ -10,7 +10,7 @@
"listen": {
"rpc_json": ":6012",
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080",
},
@@ -31,6 +31,10 @@
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}],
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
}
},

View File

@@ -414,7 +414,7 @@
]
},
{
"id": "HTTPJsonMapExporter",
"id": "NatsJsonMapExporter",
"type": "*nats_json_map",
"export_path": "nats://localhost:4222",
"attempts": 1,

View File

@@ -245,7 +245,7 @@ func testDspAttrGetAttrFailover(t *testing.T) {
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1002_SIMPLEAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1002_SIMPLEAUTH"},
AlteredFields: []string{"*req.Password"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -445,7 +445,7 @@ func testDspAttrTestAuthKey2(t *testing.T) {
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1001_SIMPLEAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1001_SIMPLEAUTH"},
AlteredFields: []string{"*req.Password"},
CGREvent: &utils.CGREvent{
@@ -529,7 +529,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) {
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1002_SIMPLEAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1002_SIMPLEAUTH"},
AlteredFields: []string{"*req.Password"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -601,7 +601,7 @@ func testDspAttrGetAttrInternal(t *testing.T) {
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1003_SIMPLEAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1003_SIMPLEAUTH"},
AlteredFields: []string{"*req.Password"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -382,7 +382,7 @@ func testDspSessionUpdate(t *testing.T) {
t.Error(err)
}
eAttrs := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_ACNT_1001"},
MatchedProfiles: []string{"cgrates.org:ATTR_ACNT_1001"},
AlteredFields: []string{"*req.OfficeGroup"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -453,7 +453,7 @@ func testDspSessionUpdate2(t *testing.T) {
t.Fatal(err)
}
eAttrs := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1001_SESSIONAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1001_SESSIONAUTH"},
AlteredFields: []string{"*req.LCRProfile", "*req.Password", "*req.RequestType", "*req.PaypalAccount"},
CGREvent: &utils.CGREvent{
@@ -608,7 +608,7 @@ func testDspSessionProcessEvent(t *testing.T) {
t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
}
eAttrs := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_ACNT_1001"},
MatchedProfiles: []string{"cgrates.org:ATTR_ACNT_1001"},
AlteredFields: []string{"*req.OfficeGroup"},
CGREvent: &utils.CGREvent{
@@ -687,7 +687,7 @@ func testDspSessionProcessEvent2(t *testing.T) {
t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
}
eAttrs := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1001_SIMPLEAUTH"},
MatchedProfiles: []string{"cgrates.org:ATTR_1001_SIMPLEAUTH"},
AlteredFields: []string{"*req.EventName", "*req.Password"},
CGREvent: &utils.CGREvent{

View File

@@ -43,7 +43,13 @@ func TestNatsEE(t *testing.T) {
if err != nil {
t.Fatal(err)
}
evExp, err := NewEventExporter(cfg, 5, new(engine.FilterS))
var idx int
for idx = range cfg.EEsCfg().Exporters {
if cfg.EEsCfg().Exporters[idx].ID == "NatsJsonMapExporter" {
break
}
}
evExp, err := NewEventExporter(cfg, idx, new(engine.FilterS))
if err != nil {
t.Fatal(err)
}

View File

@@ -386,10 +386,26 @@ func (sq *StatQueue) UnmarshalJSON(data []byte) (err error) {
return fmt.Errorf("unsupported metric type <%s>", metricSplit[0])
}
if err = json.Unmarshal([]byte(val), metric); err != nil {
fmt.Println(1)
return
}
sq.SQMetrics[metricID] = metric
}
return
}
// UnmarshalJSON here only to fully support json for StatQueue
func (ssq *StatQueueWithAPIOpts) UnmarshalJSON(data []byte) (err error) {
sq := new(StatQueue)
if err = json.Unmarshal(data, &sq); err != nil {
return
}
i := struct {
APIOpts map[string]interface{}
}{}
if err = json.Unmarshal(data, &i); err != nil {
return
}
ssq.StatQueue = sq
ssq.APIOpts = i.APIOpts
return
}

View File

@@ -1227,7 +1227,7 @@ func TestLibstatsaddStatEventNoPass(t *testing.T) {
}
func TestStatQueueJSONMarshall(t *testing.T) {
rply := new(StatQueue)
var rply *StatQueue
exp, err := NewStatQueue("cgrates.org", "STS", []*MetricWithFilters{
{MetricID: utils.MetaASR},
{MetricID: utils.MetaTCD},
@@ -1235,10 +1235,31 @@ func TestStatQueueJSONMarshall(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if err = json.Unmarshal([]byte(utils.ToJSON(exp)), rply); err != nil {
if err = json.Unmarshal([]byte(utils.ToJSON(exp)), &rply); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(rply, exp) {
t.Errorf("Expected: %s , received: %s", utils.ToJSON(exp), utils.ToJSON(rply))
}
}
func TestStatQueueWithAPIOptsJSONMarshall(t *testing.T) {
rply := &StatQueueWithAPIOpts{ /*StatQueue: &StatQueue{}*/ }
exp, err := NewStatQueue("cgrates.org", "STS", []*MetricWithFilters{
{MetricID: utils.MetaASR},
{MetricID: utils.MetaTCD},
}, 1)
exp2 := &StatQueueWithAPIOpts{
StatQueue: exp,
APIOpts: map[string]interface{}{"a": "a"},
}
if err != nil {
t.Fatal(err)
}
if err = json.Unmarshal([]byte(utils.ToJSON(exp2)), rply); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(rply, exp2) {
t.Errorf("Expected: %s , received: %s", utils.ToJSON(exp2), utils.ToJSON(rply))
}
}

View File

@@ -1030,7 +1030,7 @@ func testV1FltrAttributesPrefix(t *testing.T) {
processedEv := &engine.AttrSProcessEventReply{
AlteredFields: []string{"*req.CustomField"},
MatchedProfiles: []string{"cgrates.org:ATTR_1001"},
MatchedProfiles: []string{"cgrates.new:ATTR_1001"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.new",