Replace all instances of rpcclient.ClientConnector with birpc.ClientConnector.
Pass context, maxReconnectInterval, delayFunc and birpcClient to rpcclient
constructors.
Remove redundant time.Duration conversions (e.g. time.Duration(1*time.Second)
now becomes time.Second.
Add context where needed (context.Background() for tests, context.TODO()
for places where it should be passed from somewhere else).
Implement that functionality of the SessionSv1.Sleep call, in sessions/sessions
instead of apier/v1.
Make changes in utils/server.go (replacing the old rpc2 library with github.com/cgrates/birpc).
Change the way we register birpc methods for sessions in services, using a helper function
defined in engine/libengine.go.
The (*CDRServer).processEvent function is now called processEvents and can
be passed an array of CGREvents instead of only one. This was done because
when calling the RateCDRs API we want to first refund all CDRs before
starting to debit again.
The rerate parameter is now no longer hardcoded to true for the RateCDRs API.If
required, the "*rerate" flag must be provided by the caller.
Now, the refundEventCost function returns an additional boolean, that signals
whether the refund occured or didn't.
If the reRate parameter is set to true, also set refund to true.
In case CostDetails is not populated, retrieve it from StorDB if possible
and add it to the CGREvent before converting to CDRs. Set CostDetails back
to nil once the refund goes through.
Remove the refund logic from within the store block.
Now that the refund happens before the debit, revise the expected values for
the "testV1CDRsProcessEventWithRefund" subtest within the
apier/v1/cdrs_it_test.go file.
Add an integration test for the following scenario:
-create one account with one balance of 1 free minute and rating for the rest.
-send one CDR of two minutes with ProcessEvent. This should consume 60s out of
the free balance and charge 60s. The SetupTime in the CDR should be 1 hour after
the second CDR.
-send the second CDR with an usage of 2m. This should be charged entirely.
-send a RateCDR API call with OrderBy: "SetupTime". This should rerate the two
CDRs from above and change their order of rating.
The time it takes to register RPC methods is quite long and sometimes it is causing errors when methods that are not yet registered are being called. Therefore, the 'waitRater' default value has been increased from 100ms to 500ms.
For 'cdrs_onlexp_it_test.go':
- 2 functions have been added that create and delete the kafka topic relevant to the test. This ensures that the topic exists before export and also that it is deleted to avoid the data from within to influence subsequent tests;
- the maximum duration that we are waiting for the amqp messages to be consumed has been increased. Since it usually takes anywhere between 300ms and 1.9s to read a message, it has been increased to 2 seconds;
- amqp queues are now deleted once we are done verifying the exports.
For 'cdrs_post_failover_it_test.go', we now make sure that the failed posts directories exist and are empty before starting the engine.
For 'cdrs_processevent_it_test.go':
- some of the stat queue items were expiring too quickly, causing the test for fail sometimes. In order to solve the issue, I had to modify increase the TTL, but since the 'testit' tariff plan is also used by other tests, I decided to create the .csv files within the test, taking from 'testit' only the relevant information;
- same issue as in the previous test was occuring here. Was fixed in the same way;
- removed some useless calls.