Commit Graph

5169 Commits

Author SHA1 Message Date
armirveliaj
9ba8feeb71 Add new unit tests on engine 2024-06-30 17:51:59 +02:00
armirveliaj
09ec973a92 Add new unit tests on engine 2024-06-30 17:51:59 +02:00
armirveliaj
6c7c54ab58 Add unit tests on engine 2024-06-30 17:51:59 +02:00
armirveliaj
a945fccad6 Add new unit tests on engine 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
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
arberkatellari
f46b37bdf8 Make minor improvements to 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
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
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
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
armirveliaj
f1d0be170d Revise and Add new unit tests on engine 2024-06-06 13:17:59 +02:00
armirveliaj
36c623599e Add new unit tests on engine 2024-06-06 13:17:59 +02:00
armirveliaj
044e56a6a4 Add unit tests on engine 2024-06-06 13:17:59 +02:00
armirveliaj
0e82785173 Add unit tests on engine 2024-06-06 13:17:59 +02:00
armirveliaj
39e3d04fe5 Add new unit tests in engine 2024-06-06 13:17:59 +02:00
armirveliaj
58dc0f0ae2 Revise unit tests in engine 2024-06-06 13:17:59 +02:00
armirveliaj
70f4f44421 Add Unit Tests for Engine 2024-06-06 13:17:59 +02:00
armirveliaj
cc98314426 Add unit tests for Dispatcher,Engine,Agents 2024-06-06 13:17:59 +02:00
gezimbll
a8b8c84dda updated check on cost details
changed the check of cdr usage to  be less or equal with usage in event cost
2024-05-16 17:40:10 +02:00
gezimbll
624aa2b3f2 update threshold to set snooze time after actions 2024-05-09 12:34:42 +02:00
DanB
5cf5032fe0 CDRs rals_conns will rate by default 2024-05-03 18:14:58 +02:00
ionutboangiu
5c1e65256c Don't trim single digit values when parsing cron
Fixes an issue where 0 values would become empty inside the cron
expressions.

Added unit tests for the edge cases and grouped them together with
the previous ones under the same table test.

When creating the StartTime field, assign time.Now() to a centralised
variable and reuse it instead of calling time.Now() repeatedly.
2024-04-20 12:21:57 +02:00
ionutboangiu
4964a462cf Add flaky constraint to random routes unit tests
Also increase margin of error for guardian tests 5ms->10ms.
2024-04-16 21:10:13 +02:00
ionutboangiu
73c54cdcf2 Add test & benchmarks for msgpack library update
Check test comment for complete steps.
2024-04-16 21:10:13 +02:00
ionutboangiu
1a1ba55b25 Switch to ugorji/go/codec
Should be equivalent to ugocodec if enabling TimeNotBuiltin.
2024-04-16 21:10:13 +02:00
gezimbll
cf720b0618 added postgres configuration option to choose the schema(#4318) 2024-04-16 12:23:38 +02:00
ionutboangiu
e025a0dc89 Revise tests
-ensure failure messages are useful
-optimize tests with needlessly large sleep times
-enforce a stricter margin for error
2024-04-12 13:13:17 +02:00
ionutboangiu
2c1a90c9c6 Optimize and fix unstable tests
Revise backup loop tests to not rely on time.Sleep anymore and remove
unused fields from them.

Removed 3ns TTL from tpreader test dataDB configuration that caused in-
consistent results.

Ensure connManager cache is reloaded in filter tests. Before they could
cause deadlocks.

Remove redundant inits, global vars and setup tests for debit and
accounts tests.

Optimize some analyzers tests.
2024-04-11 18:23:57 +02:00
ionutboangiu
a5d29d5d7b Stop sending BalanceUpdate events to thresholds/stats 2024-04-08 17:34:13 +02:00
ionutboangiu
d6c5ddf08e Remove unused debitUnits and debitMoney funcs
They seem to have been replaced by the more generic debit
2024-04-08 13:15:41 +02:00
ionutboangiu
31842bf3f5 Add possibility to set/overwrite balance Factors through API
Constructor looks inside the params' balance map for the Factors key.
It expects either a string representing a JSON serialized map or the
map itself.

BalanceFilter Clone function has been updated to set a deep copy of
the original Factors map instead of a shallow one.

BalanceFilter getter function for Factors now returns nil instead of
an empty map. It's slightly more memory efficient and assignment to
this map will not be attempted, so it's panic proof.

BalanceFilter.ModifyBalance now updates Factors only if the key is
found in the request params' Balance map. Setting Factors to null is also
possible as long as the Factors key exists and is set to null.

Note: only *set_balance can overwrite the Factors map, all the others
can only set it if the balance does exist prior to sending the request.

Update balance integration tests.
2024-04-08 13:15:41 +02:00
ionutboangiu
3062113a61 Make go vet pass
The rpcclient constructor could not see the centralized
Encoding flag because it didn't have the necessary build
constraints. Added the constraints in lib_test.go files
where it wasn't alone. In all the other cases, it was
moved to the first file where it was needed.
2024-04-08 13:14:02 +02:00
ionutboangiu
821b5d05cc Remove unnecessary dependency between tests
Deleted a helper function that was directly calling strings.Trim in
favor of using strings.Trim directly.
2024-04-08 13:14:02 +02:00
ionutboangiu
bbf441f83c Add flaky build constrait to unstable tests 2024-04-08 13:14:02 +02:00
ionutboangiu
16eb745f00 Centralize test flags in utils for shared use across tests 2024-04-08 13:14:02 +02:00
ionutboangiu
9c004b069d Ignore factors equal to 1 when creating EventCost 2024-04-01 20:48:57 +03:00
ionutboangiu
6db11e87bc Rename Factor to BalanceFactor inside Accounting 2024-04-01 20:48:57 +03:00
ionutboangiu
50d0103c7b Move BalanceFactor value from Increments to Accounting
Retrieve the Accounting BalanceCharge inside a new variable and reuse
that instead of repeatedly indexing the map. It is always assumed that
the BalanceCharge exists in the map and is non-nil. A comment was
added as a reminder.

TotalCost cannot be calculated anymore from ChargingIncrement alone.
The function is not used, so it will not be causing any issues for
now.

BalanceCharge clone function now handles the case where it is nil
to avoid any possible nil pointer dereference.
2024-04-01 20:48:57 +03:00
ionutboangiu
a7ca167039 Add BalanceFactor value to Increments
For both the Increment and ChargingIncrement types.
2024-04-01 20:48:57 +03:00
ionutboangiu
cc72aa92d9 Slightly optimize debit for balances with non-nil Factor
Factor will be computed only once at the start of the function, instead
of doing it on every Increments iteration.

'amount' variable will be updated and rounded only when the computed
balances factor is different from its default value (1).
2024-04-01 20:48:57 +03:00
ionutboangiu
bd4aa99458 Refactor balance's Factor field name with its plural form
Stored balances previous to this commit, that had a non-nil Factors map, will
now have Factors nil due to field name mismatch.
2024-04-01 19:58:04 +03:00
ionutboangiu
45066b2d2f Rename Factor field to Factors in BalanceSummaries 2024-04-01 19:58:04 +03:00
ionutboangiu
6d61fd479d Add Factor map and Weight to BalanceSummaries
Added additional tests + updated old ones.
2024-04-01 19:58:04 +03:00
ionutboangiu
e987139e9c Revert to supporting *asm for ThresholdS acc publish 2024-03-22 15:12:04 +01:00
ionutboangiu
843eee3b8d Pass clone of original acc for *cdrlog actions 2024-03-13 18:25:06 +01:00