362 Commits

Author SHA1 Message Date
ionutboangiu
910f49fa6c Rename event type ProcessTime to EventPerformanceReport 2025-11-20 11:35:29 +01:00
ionutboangiu
63e4856aff agents: add processor/reader id to stats/th events 2025-11-20 11:35:29 +01:00
ionutboangiu
344b14709a agents: create dedicated events for stats processing 2025-11-20 11:35:29 +01:00
ionutboangiu
daf91dc3fa Add ReplyState field to track successful/failed requests 2025-11-20 11:35:29 +01:00
ionutboangiu
8037076ded ers: remove redundant concurrency channel init 2025-11-20 11:35:29 +01:00
ionutboangiu
fd08eed5d4 Add WaitGroup to ensure safe file processing in ERs
For cases when run_delay > 0.
2025-11-20 11:35:29 +01:00
gezimbll
917ecb62ab disabling offline internal in integration tests 2025-11-12 12:54:46 +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
ionutboangiu
37acdd1723 sessions: port session APIs and flag handling 2025-08-30 14:02:48 +02:00
ionutboangiu
28edf30543 send agent events to stats/thresholds w/ ProcessTime
applies only to template-based agents
2025-06-24 18:18:12 +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
0b26559d1f move chargers to dedicated package 2025-03-16 16:28:30 +01: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
4ad5bee6ab move failing tests to flaky 2025-02-24 13:36:32 +01:00
ionutboangiu
b1a5874215 Move config/rsrparser.go to utils package 2025-02-24 13:36:32 +01:00
ionutboangiu
36a7d174ab Remove RSRSep opt from general section
- allows RSRParser to be split gracefully from config (was depending on
  RSRSep, which was retrieved from the global config variable)
- default separator (;) was the only one used except for splitting
  inline attribute values (where ANDSep is used)
2025-02-24 13:36:32 +01:00
gezimbll
3ebf3007a5 added startdelay config option for ers readers 2025-01-29 14:44:28 +01:00
ionutboangiu
c498af5211 Allow benchmarks to use the testing suite 2024-11-04 21:22:58 +01:00
ionutboangiu
d8acee74e2 Add *fileLineNumber var for file readers 2024-11-03 13:19:45 +01:00
ionutboangiu
099f6023ee Improve engine setup helpers
- added hook support (executed after parsing config but before starting
  engine)
- renamed TestEnvironment.Setup -> TestEngine.Run as it represents the
  setup for a single cgr-engine instance
- replaced t.Log with t.Error for engine process kill error
- improved option comments

- added support for dynamic configuration for dbs
- ConfigJSON field can now be used to partially overwrite an existing
configuration
- extra cgr-engine flags can now be passed to the Run method
- added default db configs for mongo/internal
- implemented helper to load using cgr-loader
2024-10-23 21:11:25 +02:00
ionutboangiu
3e98e37db3 Revise NewRPCClient helper function 2024-10-23 21:11:25 +02:00
ionutboangiu
63c1358c3f Update behaviour of file readers using inotify
Ensure that files already existing in the source path are processed
before the reader starts listening for filesystem change events.
2024-09-23 20:28:26 +02:00
ionutboangiu
65e8128303 Implement ErSv1.RunReader api 2024-09-23 20:28:26 +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
e1adb674b8 Remove redundant dir parameter from processFile methods
Applies to both file readers and loader (for loader, the blank statement
was used anyway).

It's redundant because for file readers, the rdr.sourceDir value was
always passed as the parameter when it was already part of the method's
object.

Parameter had to also be removed from the WatchDir function and the
functions it depends on.
2024-09-23 20:28:26 +02:00
ionutboangiu
7998ed6a0f Extract common dir processing logic to a func
It will be reused for all file readers.
Rename rdrDir field to sourceDir.
2024-09-23 20:28:26 +02:00
ionutboangiu
edfe2b5ef7 Revise nats reader integration tests
They were failing after the ERs structure changes.

Added a commented helper program at the end of the test to
help generate credentials for testing nats JWT functionality
2024-09-20 11:24:37 +02:00
ionutboangiu
81b97bb9af add reconnect logic to AMQP reader (#4160)
Implemented functionality that handles reconnecting to the amqp server
and reinitializing the amqp channel in case of errors and timeouts. This
is handled by a goroutine created in the client constructor (it also
handles the initial connect/init).

Reconnects and reinits will use a fibonacci backoff strategy, and the
attempt amount and max waiting interval can be adjusted by the
'reconnects' and 'max_reconnect_interval' config options.

Messages that fail processing are now dropped instead of being requeued,
preventing infinite processing loops. However, this means that the
messages are lost. Handling failed messages will need to be addressed
separately.

'concurrent_requests' will now set the prefetch count. Setting the
prefetch count using the Qos function was able to replace our old
approach that was using channels. Default value is 1024 which,
according to the rabbitmq docs, 'runs into the law of diminishing
returns'. The recommended value is between 100-300. Source:
https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput
2024-09-05 20:46:40 +02:00
ionutboangiu
1c73e42307 Revise ERs event exporting
Make use of the previously added ees_success_ids and ees_failed_ids
configuration fields.

Remove Processed opts and everything related to them since they should
not be used anymore.

Fixed test compilation errors caused by the change.
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
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
c7221f0d1e Add reader id within the *vars in ERs 2024-08-12 18:34:50 +02:00
gezimbll
009895f92a revising integration tests 2024-06-07 17:18:23 +02:00
gezimbll
18fa884ea1 revise integration tests 2024-06-07 17:18:23 +02:00
gezimbll
cc07c5366a Revise integration tests 2023-11-29 16:25:18 +01:00
gezimbll
ac32b7ce60 Added function to cast custom map types 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
gezimbll
32ed816de7 Replacing IsSliceMember ,CloneStringSlice and SliceStringEqual with slices package functions 2023-11-01 21:38:27 +01:00
ionutboangiu
46e39770a1 Replace deprecated Publish method with PublishWithContext 2023-10-27 18:52:05 +02:00
ionutboangiu
4c34d321de Add sanity check to prevent xml reader panic
HierarchyPath parser now returns nil when
the path is empty (instead of a string slice with one
EmptyString element).

If isAbsolute is set to true, when calling the AsString
method on a nil HierarchyPath, only the separator will
be returned. Alternatively, if isAbsolute is false, it
will just return . to signal that the path currently
being processed is the one required.This avoids a nil
expr error coming from the xmlquery library.

Use the Query and QueryAll functions from the xmlquery
package to be able to handle the errors ourselves and
avoid panics.

Remove config default value for xmlRootPath. The field
will remain commented in config_defaults for reference.

Add tests for HierarchyPath.AsString function.

Add comments for XmlProvider and xmlRootPath opt.

Update XmlProvider String() func based on the comment
which specifies that it should display the already
parsed values out of cache.
2023-10-19 17:19:30 +02:00
ionutboangiu
2869728de0 Handle kafka topic creation/deletion within test 2023-10-17 17:39:14 +02:00
ionutboangiu
2867942ebe Update AMQP message processing loop
Previously, msg.Ack(true) was used, which is mostly used for batch
processing. It mistakenly acknowledged all previously unacknowledged
messages, causing errors from the AMQP server. Now, messages are
acknowledged individually after each one is processed.

Messages that ERs failed to process are now rejected and requeued
for future processing attempts.

The reader is now closed immediately if the message delivery
channel closes. Therefore, it prevents an endless loop by avoiding
continuous consumption from empty or closed channels.

Addresses: #4146
2023-10-16 18:57:16 +03: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
ionutboangiu
113e2a2bdf Replace interface{} with any 2023-05-31 10:22:28 +02:00