application = <iqe.base.application.Application object at 0x7fed72153f80>
product_id = 'rhel-for-x86-els-payg', new_value = 34
@pytest.mark.post_stage_deploy
@pytest.mark.parametrize(
"product_id",
get_random_choices_or_leading_elements(["ansible-aap-managed", "rhel-for-x86-els-payg"]),
)
@pytest.mark.parametrize(
"new_value",
[
get_random_number_from_range_or_minimum(21, 40),
(get_random_number_from_range_or_minimum(21, 40) * -1),
],
)
def test_validate_values_re_tally_sync(application, product_id, new_value):
"""Validate PAYG tally numbers are correct after retally and new metric is updated
metadata:
assignee: aunayak
negative: false
importance: critical
requirements: payg_tally
test_steps:
1. Create and send mock event
3. Re-tally
4. Create and send mock event add to existing data
5. Check new counts
expected_results:
1. After the second tally, usage data should be correct
2. Amendments should be correct and updated
3. Negative events should not be considered
"""
metrics = config_parser.get_swatch_metric_id_from_tag_metrics(product_id=product_id)
for metric in metrics:
log.info(f"For {metric} in product {product_id}")
node = ""
value = get_random_number_from_range_or_minimum(5, 20)
data = {
metric.lower(): value,
}
log.info(f"Metric values for the mock cluster are {data}")
if product_id == "ansible-aap-managed":
control_node, managed_nodes = application.rhsm_subscriptions.create_mock_payg_cluster(
product_id=product_id, hours=1, **data
)
if metric == "Instance-hours":
host_instance = managed_nodes[0]["instance_id"]
node = managed_nodes[0]
else:
host_instance = control_node["instance_id"]
node = control_node
else:
host_instance = application.rhsm_subscriptions.create_mock_payg_cluster(
product_id=product_id, hours=1, **data
)
initial_tally = application.rhsm_subscriptions.get_today_tally_report(
product_id=product_id, metric_id=metric
)
application.rhsm_subscriptions.sync_tally_hourly(
product_id=product_id,
metric_id=metric,
perform_metering=False,
timeout_tries=2,
)
first_tally = application.rhsm_subscriptions.get_today_tally_report(
product_id=product_id, metric_id=metric
)
host = application.rhsm_subscriptions.search_system_table(
product_id=product_id, display_name_contains=host_instance
)
> assert host, f"host {host_instance} not found"
E AssertionError: host e82b32ac-c52c-4795-83a3-74f42eee4e7e not found
E assert []
/iqe_venv/lib/python3.12/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_tally/test_tally_retally.py:269: AssertionError