Skip to content

Commit ff076f9

Browse files
authored
Remove cpu recording rule (RedHatQE#2424)
##### Short description: remove cpu recording rule that rely on kubernetes metric. ##### More details: ##### What this PR does / why we need it: ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: https://issues.redhat.com/browse/CNV-71592 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Removed obsolete fixtures for VM CPU metric scenarios. * Deleted the CPU metric test suite that validated VM CPU-core reporting across VM states. * Removed deprecated test utilities and constants used for Prometheus CPU metric queries. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent bd541c8 commit ff076f9

File tree

3 files changed

+0
-131
lines changed

3 files changed

+0
-131
lines changed

tests/observability/metrics/conftest.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ocp_resources.pod import Pod
99
from ocp_resources.resource import ResourceEditor
1010
from ocp_resources.storage_class import StorageClass
11-
from ocp_resources.virtual_machine import VirtualMachine
1211
from ocp_resources.virtual_machine_instance_migration import VirtualMachineInstanceMigration
1312
from pytest_testconfig import py_config
1413
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
@@ -22,7 +21,6 @@
2221
)
2322
from tests.observability.metrics.utils import (
2423
SINGLE_VM,
25-
ZERO_CPU_CORES,
2624
create_windows11_wsl2_vm,
2725
disk_file_system_info,
2826
enable_swap_fedora_vm,
@@ -31,7 +29,6 @@
3129
get_vmi_guest_os_kernel_release_info_metric_from_vm,
3230
metric_result_output_dict_by_mountpoint,
3331
vnic_info_from_vm_or_vmi,
34-
wait_for_metric_vmi_request_cpu_cores_output,
3532
)
3633
from tests.observability.utils import validate_metrics_value
3734
from tests.utils import create_vms
@@ -108,44 +105,6 @@ def unique_namespace(admin_client, unprivileged_client):
108105
yield from create_ns(admin_client=admin_client, unprivileged_client=unprivileged_client, name=namespace_name)
109106

110107

111-
@pytest.fixture()
112-
def stopped_metrics_vm(running_metric_vm):
113-
running_metric_vm.stop(wait=True)
114-
yield
115-
116-
117-
@pytest.fixture()
118-
def starting_metrics_vm(running_metric_vm):
119-
running_metric_vm.start(wait=True)
120-
yield
121-
122-
123-
@pytest.fixture()
124-
def paused_metrics_vm(running_metric_vm):
125-
running_metric_vm.privileged_vmi.pause(wait=True)
126-
yield
127-
128-
129-
@pytest.fixture(scope="module")
130-
def initial_metric_cpu_value_zero(prometheus):
131-
wait_for_metric_vmi_request_cpu_cores_output(prometheus=prometheus, expected_cpu=ZERO_CPU_CORES)
132-
133-
134-
@pytest.fixture(scope="class")
135-
def error_state_vm(unique_namespace, unprivileged_client):
136-
vm_name = "vm-in-error-state"
137-
with VirtualMachineForTests(
138-
name=vm_name,
139-
namespace=unique_namespace.name,
140-
body=fedora_vm_body(name=vm_name),
141-
client=unprivileged_client,
142-
node_selector=get_node_selector_dict(node_selector="non-existent-node"),
143-
) as vm:
144-
vm.start()
145-
vm.wait_for_specific_status(status=VirtualMachine.Status.ERROR_UNSCHEDULABLE)
146-
yield
147-
148-
149108
@pytest.fixture(scope="module")
150109
def vm_list(unique_namespace):
151110
"""

tests/observability/metrics/test_metrics_cpu.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/observability/metrics/utils.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,59 +56,11 @@
5656
from utilities.virt import VirtualMachineForTests, running_vm
5757

5858
LOGGER = logging.getLogger(__name__)
59-
KUBEVIRT_CR_ALERT_NAME = "KubeVirtCRModified"
6059
CURL_QUERY = "curl -k https://localhost:8443/metrics"
6160
SINGLE_VM = 1
62-
ONE_CPU_CORES = 1
63-
ZERO_CPU_CORES = 0
64-
COUNT_TWO = 2
6561
COUNT_THREE = 3
6662

6763

68-
def wait_for_metric_vmi_request_cpu_cores_output(prometheus: Prometheus, expected_cpu: int) -> None:
69-
"""
70-
This function will wait for the expected metrics core cpu to show up in Prometheus query output
71-
and return if results equal to the expected total requested cpu for all total vm's
72-
Args:
73-
prometheus (Prometheus): Prometheus object
74-
expected_cpu (int): expected core cpu
75-
Raise:
76-
TimeoutExpiredError: if the expected results does not show up in prometheus query output
77-
"""
78-
sampler = TimeoutSampler(
79-
wait_timeout=TIMEOUT_5MIN,
80-
sleep=TIMEOUT_30SEC,
81-
func=get_prometheus_vmi_request_cpu_sum_query_value,
82-
prometheus=prometheus,
83-
)
84-
sample = None
85-
try:
86-
for sample in sampler:
87-
if round(sample * 10) == expected_cpu:
88-
return
89-
except TimeoutExpiredError:
90-
LOGGER.error(
91-
f"timeout exception waiting for prometheus output, expected results: {expected_cpu}\n"
92-
f"actual results: {sample}"
93-
)
94-
raise
95-
96-
97-
def get_prometheus_vmi_request_cpu_sum_query_value(prometheus: Prometheus) -> float:
98-
"""
99-
This function will perform Prometheus query cluster:vmi_request_cpu_cores:sum and return query cpu output result
100-
101-
Args:
102-
prometheus (Prometheus): Prometheus object.
103-
104-
Returns:
105-
float: prometheus query value output, return 0.0 if case no results found
106-
107-
"""
108-
metric_results = prometheus.query(query="cluster:vmi_request_cpu_cores:sum")["data"]["result"]
109-
return float(metric_results[0]["value"][1]) if metric_results else 0.0
110-
111-
11264
def get_vm_metrics(prometheus: Prometheus, query: str, vm_name: str, timeout: int = TIMEOUT_5MIN) -> list[dict] | None:
11365
"""
11466
Performs Prometheus query, waits for the expected vm related metrics to show up in results,

0 commit comments

Comments
 (0)