Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] Chargeback resource allocation fixes #10183

Merged
merged 1 commit into from
Jun 19, 2020
Merged

[1LP][RFR] Chargeback resource allocation fixes #10183

merged 1 commit into from
Jun 19, 2020

Conversation

tpapaioa
Copy link
Contributor

@tpapaioa tpapaioa commented Jun 9, 2020

This PR makes several changes to the resource allocation chargeback tests. Important changes of note:

  • Replace the GitHub blocker with the downstream BZ blocker now that it has been created.
  • Create new chargeback_vm fixture to return the name of the chargeback VM from the provider data, instead of looking it up each time in the various fixtures / tests.
  • Replace deprecated pytest.yield_fixture decorators with pytest.fixture.
  • Move db query transactions into the transaction context. Previously, subqueries were defined within the context, but the actual queries were not executed within the context.
  • Also delete rows from the vim_performance_states table before capturing metrics data. Failure to do so could result in metrics data with the wrong provider id (if the provider previously existed on the appliance with one id then was deleted and re-created prior to these tests running).
  • If any metric values retrieved from the db are None (i.e., no value exists for that column), then change it to zero before calling float(), to avoid TypeError exceptions.
  • Remove 'custom' from fixture names. Eventually they will be parametrized to use either default or custom chargeback rates, and moved to cfme/fixtures/ so that they can be shared with other chargeback test modules.
  • Add logic to determine the number of hours that should be used when calculating expected chargeback costs. Only a single hourly rollup is created, and normally num_hours = 1. But if the VM already existed in the db and has a 'State Changed On' field earlier than that hourly rollup's timestamp, then num_hours should be the number of hours since that time. If 'State Changed On' is earlier than the report time period (i.e., the beginning of the day), then the number of hours since midnight should instead be used.

{{ pytest: -vv --use-provider complete --long-running cfme/tests/intelligence/chargeback/test_resource_allocation.py }}

@dajoRH
Copy link
Contributor

dajoRH commented Jun 11, 2020

I detected some fixture changes in commit 1d9874e

Show fixtures

The local fixture chargeback_vm is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • vm_owner
    • verify_records_rollups_table
    • verify_records_metrics_table
    • resource_alloc
    • chargeback_costs

The local fixture vm_owner is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • resource_alloc
    • chargeback_report

The local fixture enable_candu is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • vm_owner

The local fixture assign_chargeback_rate is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • chargeback_report

The local fixture resource_alloc is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • chargeback_costs
    • generic_test_resource_alloc
    • test_verify_alloc_memory
    • test_verify_alloc_cpu
    • test_verify_alloc_storage

The local fixture chargeback_costs is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • generic_test_chargeback_cost
    • test_validate_alloc_memory_cost
    • test_validate_alloc_vcpu_cost
    • test_validate_alloc_storage_cost

The local fixture chargeback_report is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • generic_test_chargeback_cost
    • generic_test_resource_alloc
    • test_verify_alloc_memory
    • test_verify_alloc_cpu
    • test_verify_alloc_storage
    • test_validate_alloc_memory_cost
    • test_validate_alloc_vcpu_cost
    • test_validate_alloc_storage_cost

The local fixture chargeback_rate is used in the following files:

  • cfme/tests/intelligence/chargeback/test_resource_allocation.py
    • assign_chargeback_rate
    • chargeback_costs

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

@tpapaioa tpapaioa changed the title [WIPTEST] Chargeback resource allocation fixes. [RFR] Chargeback resource allocation fixes Jun 11, 2020
@john-dupuy john-dupuy added the test-cleanup Test removal, collection changes, re-organization label Jun 16, 2020
Copy link
Contributor

@john-dupuy john-dupuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this PR @tpapaioa

@john-dupuy john-dupuy changed the title [RFR] Chargeback resource allocation fixes [1LP][RFR] Chargeback resource allocation fixes Jun 17, 2020
@jawatts jawatts merged commit 46f4262 into ManageIQ:master Jun 19, 2020
@tpapaioa tpapaioa deleted the fix_chargeback_allocation branch June 19, 2020 18:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix-test test-cleanup Test removal, collection changes, re-organization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants