Skip to content

Commit f85d018

Browse files
committed
consolidated fixtures, modified vm_test scope
1 parent aa5a6a7 commit f85d018

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

tests/observability/metrics/conftest.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def error_state_vm(unique_namespace, unprivileged_client):
146146
yield
147147

148148

149-
@pytest.fixture(scope="module")
149+
@pytest.fixture()
150150
def vm_list(unique_namespace):
151151
"""
152152
Creates n vms, waits for them all to go to running state and cleans them up at the end
@@ -580,11 +580,6 @@ def initial_metric_value(request, prometheus):
580580
return int(get_metrics_value(prometheus=prometheus, metrics_name=request.param))
581581

582582

583-
@pytest.fixture(scope="module")
584-
def initial_metric_value_scope_module(request, prometheus):
585-
return int(get_metrics_value(prometheus=prometheus, metrics_name=request.param))
586-
587-
588583
@pytest.fixture()
589584
def deleted_vmi(running_metric_vm):
590585
running_metric_vm.delete(wait=True)

tests/observability/metrics/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED = (
2727
"kubevirt_vmi_phase_transition_time_from_deletion_seconds_sum{phase='Succeeded'}"
2828
)
29-
KUBEVIRT_VM_CREATED_BY_POD_TOTAL = "kubevirt_vm_created_by_pod_total"
29+
SUM_KUBEVIRT_VM_CREATED_BY_POD_TOTAL = "sum(kubevirt_vm_created_by_pod_total)"
3030
BINDING_NAME = "binding_name"
3131
BINDING_TYPE = "binding_type"

tests/observability/metrics/test_vms_metrics.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
from tests.observability.metrics.constants import (
1616
KUBEVIRT_CONSOLE_ACTIVE_CONNECTIONS_BY_VMI,
17-
KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
1817
KUBEVIRT_VM_DISK_ALLOCATED_SIZE_BYTES,
1918
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
2019
KUBEVIRT_VNC_ACTIVE_CONNECTIONS_BY_VMI,
20+
SUM_KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
2121
)
2222
from tests.observability.metrics.utils import (
2323
compare_metric_file_system_values_with_vm_file_system_values,
@@ -515,18 +515,18 @@ def test_kubevirt_vmi_phase_transition_from_deletion_seconds_sum_windows(
515515

516516
class TestVmCreatedByPodTotal:
517517
@pytest.mark.parametrize(
518-
"initial_metric_value_scope_module",
518+
"initial_metric_value",
519519
[
520520
pytest.param(
521-
f"sum({KUBEVIRT_VM_CREATED_BY_POD_TOTAL})",
521+
SUM_KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
522522
marks=pytest.mark.polarion("CNV-12361"),
523523
)
524524
],
525525
indirect=True,
526526
)
527-
def test_kubevirt_vm_created_by_pod_total(self, prometheus, initial_metric_value_scope_module, vm_list):
527+
def test_kubevirt_vm_created_by_pod_total(self, prometheus, initial_metric_value, vm_list):
528528
validate_metrics_value(
529529
prometheus=prometheus,
530-
metric_name=f"sum({KUBEVIRT_VM_CREATED_BY_POD_TOTAL})",
531-
expected_value=str(initial_metric_value_scope_module + NUM_TEST_VMS),
530+
metric_name=SUM_KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
531+
expected_value=str(initial_metric_value + NUM_TEST_VMS),
532532
)

0 commit comments

Comments
 (0)