Commit Graph

301 Commits

Author SHA1 Message Date
ionutboangiu
a0adddb11f add error handling for cron AddFunc 2025-11-20 11:35:29 +01:00
ionutboangiu
f2a4427d2c rename *dc DataProvider to *em (from EventMetrics) 2025-11-20 11:35:29 +01:00
ionutboangiu
36633ec11a use Set method to update ExportPath for csv/fwv ee
prevents manual locking
2025-11-20 11:35:29 +01:00
ionutboangiu
83bc694b92 ees: add test for metrics reset feature
to serve only as an example for now (takes too long)
2025-11-20 11:35:29 +01:00
ionutboangiu
d3adff3827 ees: implement api to reset exporter metrics 2025-11-20 11:35:29 +01:00
ionutboangiu
3122589e48 ees: add cron-based/manual reset to ExporterMetrics 2025-11-20 11:35:29 +01:00
ionutboangiu
f2e1eb0321 simplify TimeNow parsing for ee metrics 2025-11-20 11:35:29 +01:00
arberkatellari
89653a9c80 Add *redis DBType case to it_tests 2025-11-05 17:52:03 +01:00
arberkatellari
a3f25d1ec5 Adjust tests and sample json files 2025-10-19 13:15:57 +02:00
arberkatellari
119481b3d1 Update ERs SQL functionalities 2025-10-13 09:58:45 +02:00
ionutboangiu
e05be683ae change license from GPLv3 to AGPLv3 2025-10-13 09:57:41 +02:00
arberkatellari
5847ceab00 Add and revise tests for offline internal DB 2025-05-13 17:07:17 +02:00
arberkatellari
5b66678313 Add offline internal DB functionality for dataDB,storDB & configDB 2025-05-13 17:07:17 +02:00
ionutboangiu
16d131b058 move attributes to dedicated package 2025-04-22 19:33:12 +02:00
ionutboangiu
9a42adc716 Retrieve routes default ratio from global var
to prevent cyclic import (utils > config > utils)
2025-04-22 19:33:12 +02:00
ionutboangiu
24d886c8e0 Pass CGRConfig to DataManager
instead of just CacheCfg. Prevents the need of global config var in
engine/datamanager.go
2025-03-10 13:49:34 +01:00
ionutboangiu
caebee4eab Fix failing elastic exporter test
does not expect OriginID field to be present anymore if exporting without
defining any templates. Not defining them means only the Event will be
exported as is, while OriginID is part of APIOpts.
2025-03-09 17:27:31 +01:00
ionutboangiu
b1a5874215 Move config/rsrparser.go to utils package 2025-02-24 13:36:32 +01:00
ionutboangiu
9bc51e7e64 Revise elasticsearch exporter integration test 2025-01-29 10:52:24 +01:00
ionutboangiu
2eebc7a236 Add config sanity checks for elasticsearch ee 2025-01-29 10:52:24 +01:00
ionutboangiu
92658d854e Add elsCAPath opt and improve opt comments 2025-01-29 10:52:24 +01:00
ionutboangiu
c1331531a7 Remove unusable elasticsearch opts 2025-01-29 10:52:24 +01:00
ionutboangiu
035bac3688 elasticsearch: switch to fully-typed API
- index request options are now used directly during ExportEvent. They are
  passed to the request as options only if they were configured in the first
  place.
- implement PrepareMap and PrepareOrderMap methods for the elastic exporter.
  bytePreparing methods are not needed anymore as the Event map can be exported
  directly.
- elasticsearch.Client -> elasticsearch.TypedClient
- rename prepareOpts -> parseClientOpts
2025-01-29 10:52:24 +01:00
ionutboangiu
3a0579a8ea Slightly refactor elastic exporter
now returns error in case of invalid logger type. Could be removed
in the future in favor of handling it in configsanity.go.
2025-01-29 10:52:24 +01:00
ionutboangiu
39ef7df677 Add context to ee constructor errors 2025-01-29 10:52:24 +01:00
ionutboangiu
e3b5c9ef84 Implement getter method for EventExporterCfg (by ID)
Removed redundant getter method for default EventExporterCfg.
2025-01-29 10:52:24 +01:00
ionutboangiu
5bd439020c Prevent deadlock inside *els Connect 2025-01-29 10:52:24 +01:00
ionutboangiu
f11efbad51 Add precache support for exporters
Additional changes:
- removed unnecessary locking when initializing the exporter
  cache map, as the service itself is responsible for locking.
- separated setupCache method into ClearExporterCache and
  SetupExporterCache methods.
- removed idle ListenAndServe function that was only waiting for the
  stopChan to close. The reload case was unreachable due to the reload
  channel being created in Start instead of being passed down.
- removed Shutdown method on EventExporterS and replaced it with the
  exported ClearExporterCache method as it provided the same
  functionality.
2024-10-29 18:54:51 +01:00
ionutboangiu
3e98e37db3 Revise NewRPCClient helper function 2024-10-23 21:11:25 +02:00
ionutboangiu
bd1b076f52 Handle logical race condition when caching exporters
- added lock to ensure only one exporter instance is cached.
- marked duplicate instances to be closed after export.
2024-10-23 21:11:25 +02:00
ionutboangiu
bca760021c Revise kafka exporter implementation
- added extra error return parameter to constructor
- failing to parse PEM certificates returns an error (previously nil
return)
- moved Connect logic inside the constructor*
- removed unnecessary fields from poster structure. Use the
configuration fields directly instead.
- removed mutex from poster structure (kafka writer is thread-safe)
- removed nil writer check. Message is exported directly.
- shortened receiver name
(https://google.github.io/styleguide/go/decisions#receiver-names)

*The Kafka Transport is not a connection but a configuration for the
connection created during the first export. The connection and its
related goroutines stay running until manually closed.
2024-10-23 21:11:25 +02:00
ionutboangiu
9b8ac3199b Revise EfSv1.ReplayEvents API + tests
- renamed parameter type: ArgsReplyFailedPosts -> ReplayEventsParams
- renamed param fields:
  - FailedRequestsInDir -> SourcePath
  - FailedRequestsOutDir -> FailedPath
  - TypeProvider -> Provider
- changed param fields types from *string to string
- used the SourcePath and FailedPath params directly instead of creating separate variables
- used filepath.WalkDir instead of reading the directory and looping over the entries
- used slices.ContainsFunc to check if the file belongs to any module (if 1+ is specified)
- used filepath.Join instead of path.Join
- used the path provided by WalkFunc instead of building the file paths ourselves
- made error returns more descriptive
- added logs for directories/files that are skipped
- paths that cannot be accessed are skipped after logging the error
2024-09-25 20:58:51 +02:00
ionutboangiu
d27e7aae20 Improve nats integration test
- made use of the test setup helpers.
- used t.Cleanup instead of defer.
- instead of waiting 50ms for the nats-server to start, used a helper
hook to attempt connections in fibonacci intervals. On success it
keeps a reference to the connection for later usage.
- handle error for stream delete function executed during cleanup.
- shorten time.Sleep durations when waiting for exports to finish.
- extract the cache itemID checking logic into a separate func
- retry failed requests in fibonacci intervals for up to 500ms
2024-09-23 20:28:26 +02:00
ionutboangiu
bd3e18754b Clone header before creating exporter HTTP request
Behind http.Header is just a map and it's not safe for concurrent use.
Before this change, a panic might have occurred when doing asynchronous
HTTP exports (applies to both *http_post and *http_json_map exporters).
Cloning the header before adding it to the HTTP request has fixed this
issue.

Slightly improved the test that found this data race.
2024-09-05 20:46:40 +02:00
ionutboangiu
2f387b5a0e chore: remove unnecessary parentheses
gofmt -r '(a) -> a' -w **/*.go
2024-09-05 20:46:40 +02:00
ionutboangiu
1b24a504dc add flaky build constraint to unstable tests 2024-08-21 20:59:10 +02:00
ionutboangiu
0f70af84e9 centralize test flags for shared use across tests 2024-08-15 18:17:33 +02:00
ionutboangiu
0dfb3b860d Centralize RPCClient constructor 2024-08-15 18:17:33 +02:00
arberkatellari
91630f39a5 Add exporter id within the *vars in EEs for templates 2024-08-14 14:06:03 +02:00
gezimbll
c51122fd20 Moving apis into each subsystem packages 2023-12-13 20:33:09 +01:00
ionutboangiu
d29f84169c Move cdrs to its own package
Moved engine/cdr.go to utils/cdr.go.
Moved engine/cdrs.go and engine/cdrs_test.go to cdrs package.
Moved api functions from cdrs/cdrs.go to cdrs/apis.go. Same for the
tests.
Deleted CDRsV1 type and its methods.
2023-12-12 10:09:18 +01:00
gezimbll
cc07c5366a Revise integration tests 2023-11-29 16:25:18 +01:00
ionutboangiu
1ef2afaa97 Update/remove dependencies
Remove cenkalti/rpc2 dependency and update client constructor.
Commented tests that only start and stop engine.

Fixed compilation errors caused by Azure/go-amqp update.

Remove cgrates/ugocodec dependency since we have everything
we need in ugoriji/go/codec and add tests for it.
2023-11-15 14:03:21 +01:00
ionutboangiu
46e39770a1 Replace deprecated Publish method with PublishWithContext 2023-10-27 18:52:05 +02:00
ionutboangiu
7fd7167aa5 Update expected value in kafka it test 2023-10-26 16:26:27 +02:00
ionutboangiu
d0a435aa6d Migrate to new jetstream API
Upgraded go.mod nats version due to an issue caused by version mismatch
between driver and server (uncertain).

Renamed function from getProcessOptions to getProcessedOptions.

## *NatsER.Serve

- Replaced ChanQueueSubscribe with QueueSubscribe for Core NATS consumer
to handle the message processing directly.

- Since QueueSubscribe is now used regardless of jetstream status, the
message handler has been assigned to a separate variable that can be
reused.

-  The message handler is now dealing with the message processing
directly, therefore the select case listening for the channel which is
feeding NATS messages can be removed together with the channel itself
and the select. Currently, the goroutine within Serve only has to block
until the rdrExit chan is closed.

- Moved the resource check inside the handler right before starting the
message processing goroutine.

## *NatsEE.parseOpts

- Renamed function from parseOpt to parseOpts.

- Handled the error coming from GetNatsOpts function.

## *NatsEE.Connect

- Updated function to return early in case of non-nil nats.Conn value
to reduce nesting.

## *NatsEE.ExportEvent

- Use defer to release resources and RUnlock.

## *NatsEE.Close

- Use defer to Unlock.

- Update function to return early in case of nil nats.Conn value to
reduce nesting.

## ees.GetNatsOpts

- Chose switch over if else when parsing client certificate and keys
opts.

- Updated function to return the errors directly instead of assigning
them to a separate variable right before returning.

## ers.GetNatsOpts

- Chose switch over if else when parsing client certificate and keys
opts.

- Updated function to return the errors directly instead of assigning
them to a separate variable right before returning.

Removed tab from commented natsJetStreamMaxWaitProcessed option
value in config_defaults.go under ers section.

Added integration test for ERs NATS.

Updated ees/ers implementation to use the jetstream package which
separates the jetstream context from Core NATS.

Removed the jsOpts fields from the NatsEE struct. We are now using the
jetStreamMaxWait option directly through a timeout context.

Added streamName option for NATS reader since it is now required to be
specified when creating a consumer (it is not inferred based on subject
anymore).

Updated nats ers integration tests.

Updated tests to also use the new jetstream package.

Updated tests to start the nats-server using their official driver
instead of using the std go exec package. time.Sleeps are now not
required anymore to wait for the server.

In test configurations for nats readers, made sure that natsStreamName
option is populated. It is now required for consumers to know where to
subscribe.
2023-09-28 20:48:39 +02:00
gezimbll
990feb0f26 fixing tests for ees 2023-08-02 16:49:33 +02:00
gezimbll
fcc9fc109b Updated go-elasticsearch client 2023-07-04 13:18:54 +02:00
ionutboangiu
113e2a2bdf Replace interface{} with any 2023-05-31 10:22:28 +02:00
ionutboangiu
3e22cef9cb Revise integration tests after StorDB addition 2023-05-03 10:05:28 +02:00