27 Commits

Author SHA1 Message Date
ionutboangiu
8443af3a89 Relicense from GPLv3 to AGPLv3 2025-10-29 19:42:40 +01:00
ionutboangiu
4ec26a4996 Move test cgr-engine helpers to engine package 2024-10-16 12:24:54 +02:00
ionutboangiu
1ab7f80d50 Improve engine 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
- renamed TestEnvironment.Setup -> TestEngine.Run as it represents the
  setup for a single cgr-engine instance
- removed engineDelay parameter. Added helper to wait up to 200ms for
  the APIerSv1 service to be up and running to prevent 'can't find
  service' errors.
- replaced t.Log with t.Error for engine process kill error
- improved option comments
2024-10-05 20:35:22 +02:00
arberkatellari
932e86aa53 Revise balance blockers 2024-09-09 18:36:31 +02:00
ionutboangiu
61711e9573 disable automatic removal of expired balances in test
instead of setting the expiry time sometime in the future and then
waiting for it to expire, now the balances are set directly with
expired balances
2024-09-02 16:18:12 +02:00
arberkatellari
dd5e5b1147 Revise debitCreditBalance 2024-07-14 14:11:16 +02:00
arberkatellari
a0f94c6804 Add/Update unit and integration tests adjusting for sessions backup 2024-06-12 18:21:50 +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
a5d29d5d7b Stop sending BalanceUpdate events to thresholds/stats 2024-04-08 17:34:13 +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
16eb745f00 Centralize test flags in utils for shared use across tests 2024-04-08 13:14:02 +02:00
ionutboangiu
bdbcc1ce58 Use different rates based on ToR in balance tests
TestBalanceFactor will now test refunding to mixed balanced types.

A sleep of 10ms is called before initial acc retrieval to wait for
tps to finish loading.
2024-04-01 20:48:57 +03:00
ionutboangiu
22fb6236b1 Add test for refunding with factors 2024-04-01 20:48:57 +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
843eee3b8d Pass clone of original acc for *cdrlog actions 2024-03-13 18:25:06 +01:00
ionutboangiu
5ac08799e1 Update *remove actions to support multiple balance types at once 2024-03-12 18:11:34 +01:00
ionutboangiu
f1ad73b902 Add support for filtering to *remove_expired action 2024-03-04 09:49:15 +01:00
ionutboangiu
3269393141 Retrieve BalanceFactorID from Event
It will be added to CallDescriptor in ExtraFields.

Ensure CDR ExtraFields are passed to CallDescriptor before
sending it to RALs.

Ensure Clone function of CallDescriptor also clones the
ExtraFields map.
2024-03-04 09:49:15 +01:00
ionutboangiu
0aea8ac641 Revert "Move CGREvent from utils to engine"
This reverts commit 02195c47ed.
2024-03-04 09:49:15 +01:00
ionutboangiu
02195c47ed Move CGREvent from utils to engine 2024-02-27 17:16:57 +01:00
ionutboangiu
e50d71808a Optimize TransferBalanceAPI and test *cdrlog functionality 2024-02-20 11:11:39 +01:00
ionutboangiu
41976e5721 Update *cdrlog action to support *remove_expired actions
Will also be able to process more than one CDR per
action.
2024-02-19 11:28:52 +01:00
ionutboangiu
d182d6f601 Revise behaviour of balance factor
Now it multiplies instead of dividing.
2024-02-06 10:06:30 +01:00
ionutboangiu
f01ae9fb37 Add compatibility support between *remove_balance and *cdrlog actions 2024-01-30 18:46:48 +01:00
ionutboangiu
8c0bee1a1a Add error constant for INSUFFICIENT_CREDIT_BALANCE_BLOCKER 2024-01-29 09:57:49 +01:00
ionutboangiu
c4899cc01b Update blocker tests and add test for balance factor 2024-01-29 09:57:49 +01:00