Skip to content

[WIP]Test for kubevirt_rest_client_requests_total #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions tests/observability/metrics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
BINDING_TYPE,
CNV_VMI_STATUS_RUNNING_COUNT,
KUBEVIRT_API_REQUEST_DEPRECATED_TOTAL_WITH_VERSION_VERB_AND_RESOURCE,
KUBEVIRT_CDI_IMPORT_PODS_HIGH_RESTART,
KUBEVIRT_CONSOLE_ACTIVE_CONNECTIONS_BY_VMI,
KUBEVIRT_VM_CREATED_TOTAL_STR,
KUBEVIRT_VMI_MIGRATIONS_IN_RUNNING_PHASE,
Expand Down Expand Up @@ -1164,5 +1163,5 @@ def created_fake_data_volume_resource(namespace, admin_client):


@pytest.fixture()
def metric_cdi_import_pods_high_restart_initial_value(prometheus):
return int(get_metrics_value(prometheus=prometheus, metrics_name=KUBEVIRT_CDI_IMPORT_PODS_HIGH_RESTART))
def metric_initial_value(request, prometheus):
return int(get_metrics_value(prometheus=prometheus, metrics_name=request.param))
3 changes: 3 additions & 0 deletions tests/observability/metrics/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@
BINDING_NAME = "binding_name"
BINDING_TYPE = "binding_type"
RSS_MEMORY_COMMAND = shlex.split("bash -c \"cat /sys/fs/cgroup/memory.stat | grep '^anon ' | awk '{print $2}'\"")
KUBEVIRT_REST_CLIENT_REQUESTS_TOTAL_WITH_VERB_AND_RESOURCE = (
"kubevirt_rest_client_requests_total{verb='DELETE', resource='virtualmachineinstances'}"
)
12 changes: 7 additions & 5 deletions tests/observability/metrics/test_cdi_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ def test_kubevirt_cdi_operator_up(
)


@pytest.mark.polarion("CNV-10019")
def test_kubevirt_cdi_import_pods_high_restart(
prometheus, metric_cdi_import_pods_high_restart_initial_value, created_fake_data_volume_resource
):
@pytest.mark.parametrize(
"metric_initial_value",
[pytest.param(KUBEVIRT_CDI_IMPORT_PODS_HIGH_RESTART, marks=pytest.mark.polarion("CNV-10019"))],
indirect=True,
)
def test_kubevirt_cdi_import_pods_high_restart(prometheus, metric_initial_value, created_fake_data_volume_resource):
validate_metrics_value(
prometheus=prometheus,
metric_name=KUBEVIRT_CDI_IMPORT_PODS_HIGH_RESTART,
expected_value=str(metric_cdi_import_pods_high_restart_initial_value + 1),
expected_value=str(metric_initial_value + 1),
)
20 changes: 20 additions & 0 deletions tests/observability/metrics/test_vms_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from tests.observability.metrics.constants import (
KUBEVIRT_CONSOLE_ACTIVE_CONNECTIONS_BY_VMI,
KUBEVIRT_REST_CLIENT_REQUESTS_TOTAL_WITH_VERB_AND_RESOURCE,
KUBEVIRT_VM_DISK_ALLOCATED_SIZE_BYTES,
KUBEVIRT_VMI_MEMORY_AVAILABLE_BYTES,
KUBEVIRT_VMSNAPSHOT_PERSISTENTVOLUMECLAIM_LABELS,
Expand Down Expand Up @@ -594,3 +595,22 @@ def test_metric_kubevirt_vm_vnic_info(self, prometheus, running_metric_vm, vnic_
vnic_info_to_compare=vnic_info_from_vm_or_vmi,
metric_name=query.format(vm_name=running_metric_vm.name),
)


class TestRestClientRequestsTotal:
@pytest.mark.parametrize(
"metric_initial_value",
[
pytest.param(
KUBEVIRT_REST_CLIENT_REQUESTS_TOTAL_WITH_VERB_AND_RESOURCE, marks=pytest.mark.polarion("CNV-12012")
)
],
indirect=True,
)
def test_kubevirt_rest_client_requests_total(self, prometheus, metric_initial_value, running_metric_vm):
running_metric_vm.delete(wait=True)
validate_metrics_value(
prometheus=prometheus,
metric_name=KUBEVIRT_REST_CLIENT_REQUESTS_TOTAL_WITH_VERB_AND_RESOURCE,
expected_value=str(metric_initial_value + 1),
)