cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Quota tariff order

Open JoaoJandre opened this issue 1 year ago • 14 comments

Description

Quota tariffs have been extended to make it possible to define the order of their execution. To achieve this, the position parameter was added to the quotaTariffCreate and quotaTariffUpdate APIs. This parameter is used to define the tariff execution sequence of tariffs with the same usage type. This order is ascending, that is, a tariff with position equal to 1 will be executed before a tariff with position equal to 2. If two tariffs of the same usage type have equal positions, the most recent one will be executed first.

During the processing of Quota tariffs, ACS will execute them in the defined order and inject the values ​​into subsequent rates. To enable tariff injection, the preset variable lastTariffs was created. It will have a list of objects containing the id and value attributes of the tariffs executed before it. Below is an example of the variable value when executing 3 tariffs (A, B and C) of the same usage type:

  • When executing tariff A, the value of lastTariffs will be:
[ ]
  • When executing rule B, lastTariffs will have the value:
[
  {
    "id": <A_uuid>,
    "value": <A_result>
  }
]
  • When executing rule C, lastTariffs will have the values:
[
  {
    "id": <A_uuid>,
    "value": <A_result>
  },
  {
    "id": <B_uuid>,
    "value": <B_result>
  }
]

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)
  • [X] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [X] Minor

How Has This Been Tested?

About the quotaTariffCreate and quotaTariffUpdate APIs

Num Test Result Expected result?
1 Create a tariff informing the position Tariff was created with the position informed Y
2 Create a tariff without informing the position Tariff was created with default position 1 Y
3 Edit a tariff by entering a new position Tariff was edited with the position given Y
4 Edit a tariff without entering a new position Tariff was edited maintaining the previous position Y

About the lastTariffs preset variable: I created three tariffs with activation rules:

  • the first with position 1 and always returning 10
  • the second with position 2 and the rule: lastTariffs[0].value + 7
  • the third with position 3 and the rule: lastTariffs[0].value + lastTariffs[1].value.

When running quotaUpdate, I looked in the logs for which values were calculated according to the tariffs, the first returned 10, the second 17 and the third 27.

JoaoJandre avatar Dec 12 '23 11:12 JoaoJandre

Codecov Report

Attention: Patch coverage is 65.71429% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 31.04%. Comparing base (0e32380) to head (38b1f00). Report is 1 commits behind head on main.

Files Patch % Lines
...e/cloudstack/api/command/QuotaTariffCreateCmd.java 0.00% 3 Missing :warning:
...e/cloudstack/api/command/QuotaTariffUpdateCmd.java 0.00% 3 Missing :warning:
...udstack/api/response/QuotaResponseBuilderImpl.java 62.50% 3 Missing :warning:
...k/quota/activationrule/presetvariables/Tariff.java 80.00% 1 Missing :warning:
.../org/apache/cloudstack/quota/vo/QuotaTariffVO.java 75.00% 1 Missing :warning:
...e/cloudstack/api/response/QuotaTariffResponse.java 66.66% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##              main    #8347       +/-   ##
============================================
+ Coverage     4.34%   31.04%   +26.70%     
- Complexity       0    33910    +33910     
============================================
  Files          361     5405     +5044     
  Lines        29004   380315   +351311     
  Branches      5092    55505    +50413     
============================================
+ Hits          1260   118079   +116819     
- Misses       27604   246497   +218893     
- Partials       140    15739    +15599     
Flag Coverage Δ
simulator-marvin-tests 24.61% <0.00%> (?)
uitests 4.34% <ø> (ø)
unit-tests 16.88% <65.71%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 12 '23 11:12 codecov[bot]

clgtm and well covered by tests, however as this is user facinng functionality, doe sit make sense to add an integration test @JoaoJandre ?

Sure, I'll try to add some integration tests

JoaoJandre avatar Dec 13 '23 11:12 JoaoJandre

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Dec 18 '23 08:12 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jan 09 '24 11:01 github-actions[bot]

@DaanHoogland I've created the integration test. However, while testing it, I found out that the test only works alongside #8581, thus, this PR now depends on #8581.

JoaoJandre avatar Feb 05 '24 16:02 JoaoJandre

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Feb 08 '24 13:02 github-actions[bot]

@blueorangutan package

JoaoJandre avatar Feb 14 '24 16:02 JoaoJandre

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Feb 14 '24 16:02 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8651

blueorangutan avatar Feb 14 '24 17:02 blueorangutan

@blueorangutan test alma9 kvm-alma9

DaanHoogland avatar Feb 15 '24 08:02 DaanHoogland

@DaanHoogland a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests

blueorangutan avatar Feb 15 '24 08:02 blueorangutan

[SF] Trillian test result (tid-9227) Environment: kvm-alma9 (x2), Advanced Networking with Mgmt server a9 Total time taken: 55776 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8347-t9227-kvm-alma9.zip Smoke tests completed. 124 look OK, 5 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_create_template Error 14.60 test_templates.py
test_CreateTemplateWithDuplicateName Error 21.91 test_templates.py
test_02_create_template_with_checksum_sha1 Error 65.66 test_templates.py
test_03_create_template_with_checksum_sha256 Error 65.65 test_templates.py
test_04_create_template_with_checksum_md5 Error 65.63 test_templates.py
test_05_create_template_with_no_checksum Error 121.06 test_templates.py
test_03_delete_template Error 1.09 test_templates.py
test_04_extract_template Error 1.09 test_templates.py
ContextSuite context=TestISOUsage>:setup Error 0.00 test_usage.py
test_01_volume_usage Error 192.84 test_usage.py
ContextSuite context=TestVPCRedundancy>:setup Error 0.00 test_vpc_redundant.py
ContextSuite context=TestVPCNics>:setup Error 0.00 test_vpc_router_nics.py
ContextSuite context=TestRVPCSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py

blueorangutan avatar Feb 16 '24 00:02 blueorangutan

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Feb 19 '24 09:02 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Feb 26 '24 14:02 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Mar 08 '24 10:03 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Mar 13 '24 13:03 github-actions[bot]

@blueorangutan package

JoaoJandre avatar Mar 14 '24 12:03 JoaoJandre

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Mar 14 '24 12:03 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8938

blueorangutan avatar Mar 14 '24 14:03 blueorangutan

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Mar 15 '24 04:03 github-actions[bot]

@blueorangutan package

JoaoJandre avatar Apr 10 '24 18:04 JoaoJandre

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Apr 10 '24 18:04 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9221

blueorangutan avatar Apr 10 '24 19:04 blueorangutan

Codecov Report

Attention: Patch coverage is 58.49057% with 22 lines in your changes missing coverage. Please review.

Project coverage is 15.53%. Comparing base (c6d3f6e) to head (9d31172).

Files Patch % Lines
...e/cloudstack/api/command/QuotaTariffCreateCmd.java 0.00% 6 Missing :warning:
...e/cloudstack/api/command/QuotaTariffUpdateCmd.java 0.00% 6 Missing :warning:
...k/quota/activationrule/presetvariables/Tariff.java 62.50% 3 Missing :warning:
...udstack/api/response/QuotaResponseBuilderImpl.java 70.00% 3 Missing :warning:
...e/cloudstack/api/response/QuotaTariffResponse.java 50.00% 3 Missing :warning:
.../org/apache/cloudstack/quota/vo/QuotaTariffVO.java 85.71% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##               main    #8347     +/-   ##
===========================================
  Coverage     15.53%   15.53%             
- Complexity    11967    11974      +7     
===========================================
  Files          5492     5493      +1     
  Lines        480929   480978     +49     
  Branches      59409    60881   +1472     
===========================================
+ Hits          74711    74741     +30     
- Misses       397957   397976     +19     
  Partials       8261     8261             
Flag Coverage Δ
uitests 4.17% <ø> (ø)
unittests 16.30% <58.49%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 16 '24 17:04 codecov-commenter

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar May 28 '24 06:05 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar May 30 '24 14:05 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jun 03 '24 06:06 github-actions[bot]

@blueorangutan package

JoaoJandre avatar Jun 11 '24 11:06 JoaoJandre

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Jun 11 '24 11:06 blueorangutan

Packaging result [SF]: ✖️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9864

blueorangutan avatar Jun 11 '24 12:06 blueorangutan