Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tests/observability/metrics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
KUBEVIRT_VMI_MIGRATIONS_IN_RUNNING_PHASE,
KUBEVIRT_VMI_MIGRATIONS_IN_SCHEDULING_PHASE,
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_COUNT_SUCCEEDED,
Comment thread
albarker-rh marked this conversation as resolved.
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
KUBEVIRT_VMI_STATUS_ADDRESSES,
KUBEVIRT_VNC_ACTIVE_CONNECTIONS_BY_VMI,
SUM_KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_BUCKET_SUCCEEDED,
)
from tests.observability.metrics.utils import (
SINGLE_VM,
Expand Down Expand Up @@ -554,7 +557,7 @@ def initial_metric_value(request, prometheus):
return int(get_metrics_value(prometheus=prometheus, metrics_name=request.param))


@pytest.fixture()
@pytest.fixture(scope="class")
def deleted_vmi(running_metric_vm):
running_metric_vm.delete(wait=True)
Comment thread
albarker-rh marked this conversation as resolved.

Expand Down Expand Up @@ -663,6 +666,18 @@ def vm_created_pod_total_initial_metric_value(prometheus, namespace):
)


@pytest.fixture(scope="class")
def initial_vmi_deletion_metrics_values(prometheus):
return {
metric: int(get_metrics_value(prometheus=prometheus, metrics_name=metric))
for metric in [
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
SUM_KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_BUCKET_SUCCEEDED,
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_COUNT_SUCCEEDED,
]
}
Comment thread
albarker-rh marked this conversation as resolved.


@pytest.fixture(scope="class")
def expected_cpu_affinity_metric_value(vm_with_cpu_spec):
"""Calculate expected kubevirt_vmi_node_cpu_affinity metric value."""
Expand Down
6 changes: 6 additions & 0 deletions tests/observability/metrics/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED = (
"kubevirt_vmi_phase_transition_time_from_deletion_seconds_sum{phase='Succeeded'}"
)
SUM_KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_BUCKET_SUCCEEDED = (
"sum(kubevirt_vmi_phase_transition_time_from_deletion_seconds_bucket{phase='Succeeded'})"
)
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_COUNT_SUCCEEDED = (
Comment thread
albarker-rh marked this conversation as resolved.
"kubevirt_vmi_phase_transition_time_from_deletion_seconds_count{phase='Succeeded'}"
)
KUBEVIRT_VM_CREATED_BY_POD_TOTAL = "sum(kubevirt_vm_created_by_pod_total{{namespace='{namespace}'}})"
BINDING_NAME = "binding_name"
BINDING_TYPE = "binding_type"
Expand Down
35 changes: 18 additions & 17 deletions tests/observability/metrics/test_vms_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
KUBEVIRT_CONSOLE_ACTIVE_CONNECTIONS_BY_VMI,
KUBEVIRT_VM_CREATED_BY_POD_TOTAL,
KUBEVIRT_VM_DISK_ALLOCATED_SIZE_BYTES,
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_COUNT_SUCCEEDED,
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
KUBEVIRT_VNC_ACTIVE_CONNECTIONS_BY_VMI,
SUM_KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_BUCKET_SUCCEEDED,
)
from tests.observability.metrics.utils import (
compare_metric_file_system_values_with_vm_file_system_values,
Expand Down Expand Up @@ -475,24 +477,23 @@ def test_metric_kubevirt_vmi_vnic_info_windows(self, prometheus, windows_vm_for_


class TestVmiPhaseTransitionFromDeletion:
@pytest.mark.parametrize(
"initial_metric_value",
[
pytest.param(
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
marks=pytest.mark.polarion("CNV-12067"),
)
],
indirect=True,
)
def test_kubevirt_vmi_phase_transition_from_deletion_seconds_sum_linux(
self, prometheus, initial_metric_value, running_metric_vm, deleted_vmi
@pytest.mark.polarion("CNV-12990")
def test_kubevirt_vmi_phase_transition_from_deletion_seconds_linux(
self, prometheus, initial_vmi_deletion_metrics_values, running_metric_vm, deleted_vmi, subtests
):
validate_metric_value_greater_than_initial_value(
prometheus=prometheus,
metric_name=KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
initial_value=initial_metric_value,
)
metrics_to_check = [
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_SUM_SUCCEEDED,
SUM_KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_BUCKET_SUCCEEDED,
KUBEVIRT_VMI_PHASE_TRANSITION_TIME_FROM_DELETION_SECONDS_COUNT_SUCCEEDED,
]
Comment thread
albarker-rh marked this conversation as resolved.

for metric in metrics_to_check:
with subtests.test(msg=metric):
validate_metric_value_greater_than_initial_value(
prometheus=prometheus,
metric_name=metric,
initial_value=initial_vmi_deletion_metrics_values[metric],
)

@pytest.mark.parametrize(
"initial_metric_value",
Expand Down