Commit Graph

290 Commits

Author SHA1 Message Date
arberkatellari
2ab652ebdd Add tests for ActionProfile modifications 2025-07-21 13:40:22 +02:00
ionutboangiu
785236592b Port RADIUS DMR/CoA functionality
This commit ports the following changes from v0.11:

- 9991b29 - Implement DisconnectSession API for RADIUS Agent
- 02c8ed1 - Implement support for RADIUS CoA
- 7129d34 - Merge CoA into ReAuthorize logic
- d8ad760 - Update both ReAuthorize API signatures
- 5560608 - Dynamic templates for Radius CoA out of APIOpts
- f9d1c0f - Refactor ReAuthorize to AlterSessions
- 8388832 - Rename agents API object: SessionSv1 to AgentV1
- b580e09 - Add sanity checks for radius templates
- ca6a944 - Update client_da_addresses structure
- 98265a1 - Refactor function names and error msgs related to AlterSessions
- ee98dbe - Update AgentV1DisconnectSession api signature
- c9b6c1f - Add support for sending *dmr template via APIOpts
- 03eff44 - Cache RADIUS packets during accounting instead of auth
- 28e53ce - Add requests_cache_key field to radagent cfg
2025-07-08 08:18:30 +02:00
arberkatellari
d227dfba06 Allow cache to be created for operational data on internal dataDB 2025-06-25 19:11:44 +02:00
ionutboangiu
eb9f826ffd Rename IP to IPAllocations 2025-06-03 14:23:29 +02:00
ionutboangiu
130d516a16 Revise service toggle test
- ensure analyzers folder is cleaned up (could cause deadlocks)
- ensure timeout is not reset for every ping (never times out because pinging
  duration is much shorter than timeout)
2025-05-30 14:54:09 +02:00
ionutboangiu
eed6b8a51a add implementation for new ips module 2025-05-29 15:46:42 +02:00
ionutboangiu
2f7da3702a remove redundant dm init in test flush helper 2025-05-27 17:31:01 +02:00
ionutboangiu
d619246c84 close db connections in test flush helpers
Previously, database connections would stay alive until "go test"
would finish, sometimes leading to max conn errors.
2025-05-27 17:31:01 +02:00
arberkatellari
5847ceab00 Add and revise tests for offline internal DB 2025-05-13 17:07:17 +02:00
ionutboangiu
bd8c9d3b5e migrate guardian package to external dep 2025-04-22 19:35:11 +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
f89cad421e Revise service toggle test 2025-02-07 13:23:59 +01:00
armirveliaj
7db65ca62c Clean up DispatcherS 2025-01-17 17:29:46 +01:00
ionutboangiu
70f230788b Make test client constructor error clearer 2025-01-08 20:32:55 +01:00
gezimbll
bb0116c543 added it test && loaders templates for ranking and trend profiles 2024-11-22 20:29:27 +01:00
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