Commit Graph

13309 Commits

Author SHA1 Message Date
gezimblliku
59b61f2354 added janusagent documentation 2024-08-04 21:12:01 +02:00
gezimblliku
22b96ca1e3 added tests for filter statmetric 2024-08-04 21:10:50 +02:00
armirveliaj
3d9a94c5c5 Add new unit tests 2024-08-04 21:04:41 +02:00
arberkatellari
8ed6d8352f Allow CORS on httpagent 2024-08-02 10:25:03 +02:00
armirveliaj
96e940cab3 Add new unit tests on janusagent 2024-08-02 09:36:54 +02:00
armirveliaj
29524f9be4 Add new unit tests on migrator 2024-08-02 09:36:54 +02:00
armirveliaj
f6f49f47a2 Add new unit tests on engine 2024-08-02 09:36:54 +02:00
armirveliaj
35af82ef18 Add new unit tests on agents 2024-08-02 09:36:54 +02:00
ionutboangiu
63129feb4c prevent memprof file overwrites for small intervals
Previously, the timestamp was accurate only down to seconds. For smaller intervals,
this would truncate the previous file(s). Now, for small intervals, the number of
microseconds is appended to the file name.

Added the possibility to disable timestamps in the memory profile file names and use
increments of 1 instead.

Updated the memory profiling integration tests.
2024-08-02 09:35:36 +02:00
ionutboangiu
218ad92635 Ensure reference fileCPU is not overwritten
Would previously happen if memory profiling was already started.
Now using os.File.Stat beforehand to check if a handler of the file
is already active and confirm the status of profiling. This required
changing the type of the reference fileCPU from io.Closer to *os.File.
Asserting the type would have worked as well.
2024-08-02 09:35:36 +02:00
ionutboangiu
1c490a9020 Revise memory profiling implementation
- 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
2024-08-02 09:35:36 +02:00
ionutboangiu
9d4561f79c Revise CPU Profiling implementation
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 io.Closer (as opposed to an io.WriteCloser)
- 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

- improved comments and error messages
2024-08-02 09:35:36 +02:00
ionutboangiu
6f4d2144a6 Add test & constant for set_versions flag
Also added set_versions help entry to cgr-engine doc.
2024-08-02 09:35:36 +02:00
ionutboangiu
958aa267cf Refactor HTTP profiling and flag handling
- hardcode the base path for profiling endpoints to '/debug/pprof/'
- change profiling flag 'httprof_path' to boolean 'http_pprof'
  (because of the above)
- remove redundant profiling endpoint registrations (handled by pprof.Index)
- move profiling registration log after actual registration
- make profiling registration log more descriptive
- use utils.Logger instead of log.Print for the log mentioned above
- refactor flags test into a table test (adding also verification for default
  flag values)
- change 'scheduledShutdown' flag type from string to time.Duration (to avoid
  unnecessary time parsing)
- revise flags usage descriptions
- rename flag 'singlecpu' to 'singleCPU'
- switch to 'ExitOnError' for flag parsing to simplify error handling and
  automatically handle 'ErrHelp' by exiting with status 0 when help is
  requested and status 2 for other parsing errors. Before the following error
  log would have been received:
  '<InitS> error received: <flag: help requested>, exiting!'
- update cgr-engine documentation
2024-08-02 09:35:36 +02:00
arberkatellari
9eeee38824 Improve kamailio serivice test 2024-07-22 15:31:02 +02:00
arberkatellari
7fa3249d54 Add Kamailio agent session restoration support 2024-07-22 15:31:02 +02:00
arberkatellari
5ccb77c5dc Add mongo support for sessions backup 2024-07-22 15:31:02 +02:00
gezimblliku
692279ef8b handle errors from exportrequest fields in ees 2024-07-21 19:05:53 +02:00
ionutboangiu
4cba4a699d Implement SharedActionsData for action groups
- holds common relevant data between actions.
- currently supports only *cdrlog, making the process more reliable
and less repetitive. It also provides access to more information about
actions when creating CDRs.
- easier to scale.
- removes the need for cloning accounts before executing a group of
actions.
- added Actions method to check if specific action types exist inside.
2024-07-21 19:04:53 +02:00
arberkatellari
dd5e5b1147 Revise debitCreditBalance 2024-07-14 14:11:16 +02:00
gezimblliku
3034c2882e added tests for disconnecting janus external sessions 2024-07-14 14:09:44 +02:00
gezimblliku
122c1c152c implemented V1DisconnectSession method for janusagent 2024-07-14 14:09:44 +02:00
ionutboangiu
747bfd9967 Remove global CGRConfig used by tests 2024-07-14 14:08:49 +02:00
ionutboangiu
962000656b Remove global err used by tests
Removed many leftover error checks for NewDefaultCGRConfig,
which does not return an error anymore.
2024-07-14 14:08:49 +02:00
armirveliaj
69fda516a6 Add new unit tests on loaders 2024-07-14 14:07:21 +02:00
armirveliaj
54a90fe543 Add new unit test on engine 2024-07-14 14:07:21 +02:00
armirveliaj
b0c64286e8 Add new unit tests on config 2024-07-14 14:07:21 +02:00
armirveliaj
a26c9bb29a Add new unit tests on agents 2024-07-14 14:07:21 +02:00
armirveliaj
05f7981cae Add new unit tests on agents 2024-07-14 14:07:21 +02:00
armirveliaj
9c5ae52389 Add new unit tests on agents 2024-07-14 14:07:21 +02:00
armirveliaj
fb04c28dab Add new unit tests on engine 2024-07-14 14:07:21 +02:00
armirveliaj
49657db953 Add new unit tests on agents 2024-07-14 14:07:21 +02:00
gezimbll
85bd7a50e7 updated sags service name to ranking 2024-07-14 13:39:20 +02:00
gezimbll
4d4392d196 revised comments && renamed sars to trends 2024-07-14 13:39:20 +02:00
gezimbll
6c2fbbec28 added sars model,tp,api 2024-07-14 13:39:20 +02:00
ionutboangiu
9d7fcdc0c6 Ensure refund flag is not ignored when rerate is true
By default setting rerate to true also sets refund to true, but
flags should take precedence over defaults.

If rerate is true and refund is false, remove any previous
CostDetails from event to force rerate.

Centralize the configuration of processing args.
2024-07-14 13:28:18 +02:00
ionutboangiu
435e4f59b5 Add set_versions flag to cgr-engine
If set to true, it sets/overwrites all versions to the
current ones.
2024-07-14 13:27:09 +02:00
ionutboangiu
eb3bd5cc1d Add redisPoolPipelineLimit configuration field for datadb
Sets the maximum number of commands that can be pipelined before flushing.
0 means no limit and pipelines will only be limited by the time window.
2024-07-05 11:21:16 +02:00
ionutboangiu
8ed26c769e Replace ansible include with include/import_tasks
Deprecated and not available in versions 2.16+
2024-07-05 11:20:09 +02:00
ionutboangiu
da4bf0d783 Sync (and update) go version
go.mod had a later version than the one used inside the
role, which caused the deb packaging to fail.

Updated all of them to latest.
2024-07-05 11:20:09 +02:00
ionutboangiu
520451be7e 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-07-05 11:19:36 +02:00
armirveliaj
4260852918 Add new unit tests on agents 2024-07-02 20:01:01 +02:00
ionutboangiu
ed3fa0d294 Add redisPoolPipelineWindow configuration field for datadb
Sets the duration after which internal pipelines are flushed.
0 disabled implicit pipelining.
2024-07-02 19:58:03 +02:00
armirveliaj
8447bbb084 Add new unit tests on engine 2024-07-01 20:37:09 +02:00
armirveliaj
fedacded6e Add new unit tests on agents 2024-07-01 20:37:09 +02:00
arberkatellari
23ae4632fe Add print_config flags to cgr-loader and cgr-migrator 2024-07-01 14:33:24 +02:00
arberkatellari
b88602cdf3 Update rpcclient revising error handling 2024-06-30 17:55:09 +02:00
arberkatellari
dddd34f0db Update general test 2024-06-30 17:55:09 +02:00
ionutboangiu
4d3868aad0 Add support for Git 2.45+ iso-strict date format
Git 2.45+ introduced a backward incompatible change in the iso-strict
date format, showing time in the Zulu timezone with Z suffix instead
of +00:00. This commit adds parsing for the new date format before
falling back to the old format.

Ignore errors for old git versions where %cI is not defined.

Revise GetCGRVersion error messages.
Revise GetCGRVersion unit test.
2024-06-30 17:53:38 +02:00
ionutboangiu
13a0e86a0e Update TestATExportAndTopup integration test
Changed initial *topup action to *topup_reset and increase its weight
to ensure it runs first.
Changed ExpiryTime (inside the *topup_reset action definition) from
*unlimited to +150ms.
Added an extra action trigger to the account to execute ACT_TOPUP_INITIAL
when the balance expires.
Added the following test cases:
  - Execute triggers before balance expiry and verify nothing happens.
  - Wait for the balance to expire (helper now returns balance expiry
  time).
  - Execute triggers again and verify if ACT_TOPUP_INITIAL was executed.
Updated connections from *localhost to *internal.
2024-06-30 17:53:05 +02:00