Commit Graph

13252 Commits

Author SHA1 Message Date
armirveliaj
eb11b51c5e Add unit tests on ees 2024-06-30 17:51:59 +02:00
armirveliaj
6df400cc7e Revise and add new unit tests on agents 2024-06-30 17:51:59 +02:00
armirveliaj
37161e8ea4 Add new unit tests on agents 2024-06-30 17:51:59 +02:00
armirveliaj
a945fccad6 Add new unit tests on engine 2024-06-30 17:51:59 +02:00
armirveliaj
d02df49f53 Add new unit tests on agents 2024-06-30 17:51:59 +02:00
gezimbll
777d4f0a28 added caching for sagprofile 2024-06-30 17:45:06 +02:00
gezimbll
dd7e1f9a0c tests for loading sagprofiles from csvreader 2024-06-30 17:45:06 +02:00
gezimbll
0012477d52 added stat aggregator profile,models,tps and apis 2024-06-30 17:45:06 +02:00
ionutboangiu
22cbaa58c7 Optimize Kafka SSL integration test
- 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-06-30 16:28:52 +02:00
ionutboangiu
11b96de00a Add kafkaBatchSize configuration field
Avoids the default 1 second delay when the batch doesn't
reach 100 messages within that time.

Useful when the Kafka exporter is not cached, as it would
otherwise encounter that delay. Setting BatchSize to 1
prevents this.
2024-06-30 16:28:52 +02:00
ionutboangiu
9c94fbfe58 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-06-30 16:28:52 +02:00
ionutboangiu
02ae2cce79 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-06-30 16:28:52 +02:00
ionutboangiu
36598294a2 Revise Kafka SSL test
- Updated to use the test suite
- Deleted kafka_ssl sample configuration (moved to test file)
- Replaced 'logger' section with 'general' in configuration
- Revised Kafka server SSL setup comment
- Ensured exporters are synchronous to avoid missing errors
- Implemented helper function to create and clean up kafka topics
2024-06-30 16:28:52 +02:00
ionutboangiu
4d8a2d7bdd Format kafka ansible role files 2024-06-30 16:28:52 +02:00
armirveliaj
8f8ff30ff8 Add new unit tests on config 2024-06-18 21:10:00 +02:00
armirveliaj
2d6912657d Add and revise new unit tests on agents 2024-06-18 21:10:00 +02:00
ionutboangiu
d3975b4d2f Update ActionTrigger integration test scenario
Instead of using 2 balances and maintaining them using
*transfer_balance, use only 1 balance.
2024-06-18 16:29:01 +02:00
ionutboangiu
c3524735aa Ensure config path stands out when using print_config flag
Done by using the %q fmt verb instead of %s, which wraps the path
within quotes.
2024-06-17 20:15:29 +02:00
armirveliaj
d4abea91a5 Formatting fsevent_test.go 2024-06-14 18:20:05 +02:00
armirveliaj
00efea25b5 Fixing merge issues 2024-06-14 18:20:05 +02:00
armirveliaj
0688659c54 Add new unit tests on agents 2024-06-14 18:20:05 +02:00
armirveliaj
5dfb49db71 Revise and add new unit tests on agents 2024-06-14 12:16:05 +02:00
ionutboangiu
49f6c5982e Add reference value functionality to *transfer_balance action
The *transfer_balance action can now use a reference value to ensure
the destination balance reaches a specified amount. If the destination
balance exceeds the reference value, the excess is transferred back
to the source balance. If the destination balance is below the
reference value, the required amount is transferred from the source
balance to the destination balance to reach the specified reference
value. An error is returned if the transfer cannot achieve the
specified reference value.

Used by specifying DestinationReferenceValue inside ExtraParameters.

Other *transfer_balance changes:
- used json tags when unmarshaling ExtraParameters in order to be
able to shorten the names of the fields
- lock the destination account only if it's different from the
source account. It is still passed to the Guard function but
without a lock key and with 0 timeout.
- if the transfer happens within the same account, update the
account and execute its ActionTriggers only once.
- moved transfer units validation after retrieving/creating the
destination balance

*cdrlog action has been updated to create cdrs for reference
*transfer_balance actions, although improvements are needed and
the functionality is not completely tested.

APIerSv1.TransferBalance has been updated to take into account the
ReferenceValue parameter.

Added new *transfer_balance action unit tests to account for the
new changes.

Added integration tests (incomplete for now, but functionality
has been tested manually).
2024-06-13 13:56:40 +02:00
armirveliaj
1fd77cafa5 Add new unit tests on agents 2024-06-13 10:45:14 +02:00
arberkatellari
f46b37bdf8 Make minor improvements to sessions backup 2024-06-12 18:21:50 +02:00
arberkatellari
b061770e68 Add asterisk and FS agents session restoration support 2024-06-12 18:21:50 +02:00
arberkatellari
a0f94c6804 Add/Update unit and integration tests adjusting for sessions backup 2024-06-12 18:21:50 +02:00
arberkatellari
f356695f6f Add active sessions backup functionalitiy 2024-06-12 18:21:50 +02:00
gezimbll
7e3b1b7052 increased time.sleep for cache to remove on ttl 2024-06-12 14:53:30 +02:00
gezimbll
1c1d211c7c added config,service for sags 2024-06-12 14:53:30 +02:00
armirveliaj
f707236a37 Add unit test on utils 2024-06-11 18:49:39 +02:00
armirveliaj
bc531f8b5a Add unit test on migrator 2024-06-11 18:49:39 +02:00
armirveliaj
62a20d1ce8 Add new unit tests on services 2024-06-11 18:49:39 +02:00
ionutboangiu
d31b4d0984 Add engine flag to print the config object in JSON format
Removed the redundant check_config engine flag. Config sanity was
checked by the NewCGRConfigFromPath function.
2024-06-11 18:34:02 +02:00
gezimbll
8103cd4c9f renamed sarS api&&register the sarS service to servmanager 2024-06-11 10:21:51 +02:00
gezimbll
86df598920 Implemented service,config and api for Sars 2024-06-11 10:21:51 +02:00
armirveliaj
ed9ac8965f Add unit tests on engine 2024-06-10 18:52:59 +02:00
gezimbll
7a32176f09 update rals flag to false when using refund 2024-06-10 13:00:02 +02:00
Bas Couwenberg
261374be0e Don't recursively change ownership of package directories. 2024-06-10 12:00:48 +02:00
armirveliaj
a4edc5dfca Revise and add new test case on engine 2024-06-07 17:17:54 +02:00
armirveliaj
336b85e5dc Add new unit tests on engine 2024-06-07 17:17:54 +02:00
gezimbll
8bf51a6112 added URLEncoder data converter 2024-06-07 16:40:54 +02:00
gezimbll
2293f7f66d added urldecode data converter 2024-06-07 16:40:54 +02:00
ionutboangiu
2980775e67 Revise test for ReplayFailedPosts API
- shortened the failed post cache ttl to 1ms to simulate with more
than one events file
- use the default FailedPath (which is the same as SourcePath) to check
whether writing events that failed to be replayed to the same path
would cause an infinite loop.
2024-06-07 16:32:49 +02:00
ionutboangiu
b7dacfe8a6 Revise APIerSv1.ReplayFailedPosts API + tests
- renamed parameter type: ArgsReplyFailedPosts -> ReplayFailedPostsParams
- renamed param fields:
  - FailedRequestsInDir -> SourcePath
  - FailedRequestsOutDir -> FailedPath
- 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-06-06 13:30:14 +02:00
ionutboangiu
89f97d45e1 Bump version in nats ansible role + formatting 2024-06-06 13:30:14 +02:00
ionutboangiu
5ca6898cb4 Update integration test setup helpers
- Pass the testing.T variable to all the helpers.
- Fail directly using t.Fatal instead of returning errors and
  checking them in the parent function.
- Use t.Cleanup to ensure engine is closed after the test instead
  of returning a shutdown function and using it with defer.
- Use t.TempDir to create temporary directories for configuration
  and tariffplans
- Add t.Helper() method call to all helper functions.
2024-06-06 13:30:14 +02:00
ionutboangiu
1485e77d55 Add workflow step to set up debug session (commented) 2024-06-06 13:30:14 +02:00
ionutboangiu
448eea3918 Format some ansible roles 2024-06-06 13:30:14 +02:00
ionutboangiu
c32de12cee Reduce client connection attempts to test engine status (tests)
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-06-06 13:30:14 +02:00