Commit Graph

275 Commits

Author SHA1 Message Date
ionutboangiu
4c8cf69f70 Auto-configure loader in test suite if needed 2024-11-07 15:38:37 +01:00
ionutboangiu
709d70a031 Add DBCfg var for postgres 2024-11-04 21:22:58 +01:00
ionutboangiu
113f1ccf31 Implement cgr-loader test helper 2024-11-04 21:22:58 +01:00
ionutboangiu
c498af5211 Allow benchmarks to use the testing suite 2024-11-04 21:22:58 +01:00
gezimbll
132a2b3bf9 rankings,trends: added implementation,services and tests 2024-11-04 19:03:21 +01:00
ionutboangiu
c7dbcaea03 Revise CPU/Memory profiling
CPU profiling changes:

cgr-engine.go:
- use filepath.Join instead of path.Join
- handle *CoreService.StopCPUProfiling error inside deferred function
- same with the error from *os.File.Close()

cores/core.go:
- StartCPUProfile now returns an *os.File (as opposed to an io.WriteCloser),
  because os.File.Stat is used beforehand to check if a handler of the file is
  already active and confirm the status of profiling.  Asserting the type would
  have worked as well.
- handle pprof.StartCPUProfile error and ensure file is closed before returning
- log file close error as a warning if it occurs
- return missing mandatory error with correct path field name ('DirPath')
- no need to check if fileCPU is nil for profiling status
  - pprof.StartCPUProfiling will return an error if profiling is already started
  - os.File.Close() will return ErrClosed if profiling is already stopped
- differentiate between calling StopCPUProfiling when profiling hasn't started
and when it was already stopped by returning appropriate errors

Memory profiling changes:

- merge StopChanMemProf with StopMemoryProfiling
- remove fileMEM and stopMemProf from struct and constructors
- add separate mutex for memory profiling, ensure thread safety
- handle all significant errors
- log error if StopMemoryProfiling fails during CoreS Shutdown
- ignore errors if profiling inactive in Shutdown and deferred Stop
- move validations inside V1 functions
- return error if StartMemoryProfiling already started
- return error if StopMemoryProfiling already stopped or never started
- close profiling loop on error, not the cgr-engine
- StopMemoryProfiling closes channel and profiling loop writes final profile
- rename Path to DirPath for mandatory field error
- rename memprof_nrfiles flag to memprof_maxfiles
- increase default memprof_interval
- consider MaxFiles <= 0 as unlimited
- move memory profiling logic after starting services
- use CoreService Start/StopMemoryProfiling in main
- remove final memory profile block (created by deferred Stop)
- convert MemProfiling to method on CoreService and rename to profileMemory
- use Ticker for recurrent actions instead of Timer
- compute mem_final.prof full path in StartMemoryProfiling
- suffix profile files with current time instead of numbers
- update dispatcher methods after changes
- move MemoryPrf from utils to cores, rename to MemoryProfilingParams
- add logs for starting/stopping profiling
- added the possibility to disable timestamps in the memory profile file names
  and use increments of 1 instead.

Other changes:

- improved integration tests for flags (now table tests)
- improved profiling integration tests
2024-11-01 15:59:39 +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
682f52e3dd Revise kafka SSL test
- Updated to use the test suite
- Deleted kafka_ssl sample configuration (moved to test file)
- Revised Kafka server SSL setup comment
- Ensured exporters are synchronous to avoid missing errors
- Implemented helper function to create and clean up kafka topics
- ERs sometimes took too long to receive a message.
  Setting kafkaGroupID to "" prevents this.
- Kafka reader took 10s to close (default MaxWait).
  Set MaxWait to 1ms.
- Exporters took 1s each to export due to BatchSize
  not being hit. Set BatchSize to 1 to prevent it.
2024-10-23 21:11:25 +02:00
ionutboangiu
f26a0c2d0b Reduce client connection attempts to test engine status
200 -> 16

Previously, considering the fibonacci back off strategy, if engine failed to
start it would have tried to attempt connections for 2.862799e+33 years.

Now, the amount of attempts is 16, equivalent to around 2 and a half seconds.
Should be more than enough, considering that usually 6-7 attempts are enough.
2024-09-25 20:58:51 +02:00
ionutboangiu
e228dda013 Improve test setup helpers
- added hook support (executed after parsing config but before
starting engine)
- made db resets configurable
- merged config parsing helper with the main Setup function
- removed engineDelay parameter
- replaced t.Log with t.Error for engine process kill error
- improved option comments
2024-09-23 20:28:26 +02:00
gezimblliku
0f81b78321 updated trend profile && trends service implementation 2024-09-23 11:48:04 +02:00
ionutboangiu
169b5500d3 Revise err handling for CSV storage constructor
NewFileCSVStorage() now returns an error besides the storage struct itself, which is
logged and returned instead of calling log.Fatal() which was causing the engine to
crash.

Fixed compilation errors by creating the CSVStorage separately and passing it as an
argument to the TpReader constructor.

Fixes #3962
2024-09-05 20:46:40 +02:00
ionutboangiu
8426892ac6 revise integration tests script 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
9d59e88552 Add the test suite
Similar to the one from v0.11. Has different csv loading logic and passes
context.
2024-08-15 18:17:33 +02:00
ionutboangiu
0dfb3b860d Centralize RPCClient constructor 2024-08-15 18:17:33 +02:00
ionutboangiu
7c5d56c1de Combine csv loader tests
- ensures the tpreader is not eating memory even when tests are
not being run (before it was being constructed in an init())
2024-08-15 18:17:33 +02:00
gezimblliku
73a7590f1c added profiles,configs and services for trend && ranking 2024-08-02 09:37:52 +02:00
gezimbll
3ff0e6e5a1 revising integration tests 2024-06-07 17:18:23 +02:00
gezimbll
32ed816de7 Replacing IsSliceMember ,CloneStringSlice and SliceStringEqual with slices package functions 2023-11-01 21:38:27 +01:00
gezimbll
5b5a159706 Added sentrypeer filter type 2023-08-02 16:49:33 +02:00
ionutboangiu
df1dc5e838 Add StorDB service
Add StorDB to config and services.

Put back the store_cdrs option under cdrs and update the CDRs
service to depend on StorDB.

Define the StorDB interface and add a constructor for it.

Add a constructor for postgres storage.

Add a config sanity check to validate SSL modes for postgres.

Update cgr-engine to consider StorDB on startup.
2023-05-03 10:05:28 +02:00
ionutboangiu
dd7bab666f Repair failing unit tests after adding max_reconnect_interval option 2022-07-03 13:08:52 +02:00
ionutboangiu
70ea038f08 Update FibDuration function 2022-07-03 13:08:52 +02:00
ionutboangiu
7299b09107 Add max_reconnect_interval for dispatcherhost csv models 2022-07-03 13:08:52 +02:00
ionutboangiu
ebee8c1233 Remove actionblockers 2022-05-06 20:49:11 +02:00
porosnicuadrian
cea929269a Blockers for account/balance + tp/cfgs and tests 2022-05-06 17:00:30 +02:00
porosnicuadrian
3c4aa8876d Added blockers for accounts 2022-05-06 17:00:30 +02:00
porosnicuadrian
5537e8993d Improved stats + tests 2022-05-06 17:00:30 +02:00
ionutboangiu
887b6db5b8 Add blockers field to chargers + tests 2022-04-29 20:33:51 +02:00
ionutboangiu
52c79ca8db Change RouteBlockers type from bool to DynamicBlockers 2022-04-29 20:33:51 +02:00
ionutboangiu
065ffcfbdf Change blocker type from bool to DynamicBlockers for APActions 2022-04-29 20:33:51 +02:00
porosnicuadrian
9197a10f42 Moved AttributeBlockers next to filterIDs 2022-04-29 14:43:18 +02:00
porosnicuadrian
eddfe1776b Organized stats fields + route blockers + improved tests 2022-04-28 17:14:05 +03:00
ionutboangiu
aca1dc2cff Change blockers field's position within RouteProfile 2022-04-28 08:52:03 +02:00
ionutboangiu
39c2d97333 Add Blockers field to ActionProfile + tests 2022-04-28 08:52:03 +02:00
ionutboangiu
147cc8f8f0 Add Blockers field for RouteProfiles 2022-04-28 08:52:03 +02:00
porosnicuadrian
41a7ee8add DynamicBlocker for stats + unit test 2022-04-27 17:49:14 +02:00
porosnicuadrian
6561d4d110 New AttributeBlocker 2022-04-27 17:49:14 +02:00
porosnicuadrian
85ba81c71f Moved blocker next to weights + it tests fixes 2022-04-27 13:03:59 +02:00
porosnicuadrian
bc5f1b5e10 Updated configs for Blockers and unused configs 2022-04-21 15:27:27 +02:00
porosnicuadrian
b16b44732e Modified blocker into Blockers for attributes 2022-04-21 15:27:27 +02:00
andronache98
ecdf5e54ea Changed headers 2022-03-09 14:14:30 +01:00
andronache98
9ec56f5155 Changed headers 2022-03-09 14:14:30 +01:00
andronache98
03793c0082 Removed storDB from config 2022-03-09 14:14:30 +01:00
porosnicuadrian
4a2b8ff6e1 Fixed loaders cfg and weights 2022-03-07 10:58:21 +02:00
andronache98
fad736e5a6 Changed Weights from float64 to DynamicWeights for Resources and Chargers 2022-02-13 15:09:53 +02:00
andronache98
ffb41e083b Fixed tests 2022-02-10 10:48:29 +02:00
andronache98
3432bbd853 Repaired tests 2022-02-08 19:08:45 +01:00