BryanMLima opened a new pull request, #8581:
URL: https://github.com/apache/cloudstack/pull/8581

   ### Description
   
   This PR aims to improve the overall Quota balance calculation by breaking 
into separate methods and calculating based on the period dates rather than the 
Quota usage records for a better understanding of its flow. This PR also 
introduces smoke test for Quota balance and normalized the aggregation usage 
calculation when it is not daily or hourly.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [x] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] build/CI
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   ### How Has This Been Tested?
   
   1. Create a quota tariff with the usage type `6` (i.e. volume).
   2. Created an account.
   3. Added credits to the account.
   4. Created a volume assigned to the newly created account.
   5. Verified that the account balance was consistent with the tariff value.
   
   ```sql
   id   |account_id|domain_id|credit_balance|credits_id|updated_on         |
   -----+----------+---------+--------------+----------+-------------------+
   12876|        47|        1|  100.00000000|        26|2024-01-31 16:40:11|
   12879|        47|        1|    0.00000000|         0|2024-01-31 16:39:00|
   12880|        47|        1|   92.85277786|         0|2024-01-31 16:40:59|
   12883|        47|        1|   82.51944399|         0|2024-01-31 16:42:59|
   12886|        47|        1|   72.18611012|         0|2024-01-31 16:44:59|
   12889|        47|        1|   61.85277625|         0|2024-01-31 16:46:59|
   ```
   
   #### How did you try to break this feature and the system with this change?
   
   I also tried to invert the steps in the test above
   
   1. Create a quota tariff with the usage type `6` (i.e. volume).
   2. Created an account.
   3. Created a volume assigned to the newly created account.
   4. Added credits to the account.
   5. Verified that the account balance was consistent with the tariff value.
   
   ```sql
   id   |account_id|domain_id|credit_balance|credits_id|updated_on         |
   -----+----------+---------+--------------+----------+-------------------+
   12894|        48|        1|   50.00000000|        28|2024-01-31 16:51:34|
   12901|        48|        1|    0.00000000|         0|2024-01-31 16:51:00|
   12902|        48|        1|   44.83333306|         0|2024-01-31 16:52:59|
   12906|        48|        1|   34.49999919|         0|2024-01-31 16:54:59|
   12910|        48|        1|   24.16666532|         0|2024-01-31 16:56:59|
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to