From 849567919e559cc897645943c5e60e3664bd2029 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 7 Oct 2020 16:32:34 +0300 Subject: [PATCH] Return error NOT_FOUND in case no exporter match the event --- ees/ees.go | 3 +++ ees/filecsv_it_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ees/ees.go b/ees/ees.go index 9c8f65ae0..e0a26bc24 100644 --- a/ees/ees.go +++ b/ees/ees.go @@ -262,6 +262,9 @@ func (eeS *EventExporterS) V1ProcessEvent(cgrEv *utils.CGREventWithIDs, rply *ma } metricMapLock.Unlock() + if len(*rply) == 0 { + return utils.ErrNotFound + } return } diff --git a/ees/filecsv_it_test.go b/ees/filecsv_it_test.go index 408b510c8..0cd8492ba 100644 --- a/ees/filecsv_it_test.go +++ b/ees/filecsv_it_test.go @@ -58,6 +58,7 @@ var ( testCsvVerifyMaskedDestination, testCsvExportEventWithInflateTemplate, testCsvVerifyExportsWithInflateTemplate, + testCsvExportNotFoundExporter, testStopCgrEngine, testCleanDirectory, } @@ -526,3 +527,42 @@ func testCsvVerifyExportsWithInflateTemplate(t *testing.T) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) } } + +func testCsvExportNotFoundExporter(t *testing.T) { + eventVoice := &utils.CGREventWithIDs{ + CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "voiceEvent", + Time: utils.TimePointer(time.Now()), + Event: map[string]interface{}{ + utils.CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), + utils.ToR: utils.VOICE, + utils.OriginID: "dsafdsaf", + utils.OriginHost: "192.168.1.1", + utils.RequestType: utils.META_RATED, + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.Account: "1001", + utils.Subject: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Unix(1383813745, 0).UTC(), + utils.AnswerTime: time.Unix(1383813746, 0).UTC(), + utils.Usage: time.Duration(10) * time.Second, + utils.RunID: utils.MetaDefault, + utils.Cost: 1.01, + "ExporterUsed": "ExporterNotFound", + "ExtraFields": map[string]string{"extra1": "val_extra1", + "extra2": "val_extra2", "extra3": "val_extra3"}, + }, + }, + }, + } + + var reply map[string]utils.MapStorage + if err := csvRpc.Call(utils.EventExporterSv1ProcessEvent, eventVoice, &reply); err == nil || + err.Error() != utils.ErrNotFound.Error() { + t.Error(err) + } + +}