Skip to content

Commit 5df88b8

Browse files
p3rf Teamcopybara-github
authored andcommitted
Fix to rampup test to ensure correct metric collector runs
See #6272. While refactoring the Run() method, the KubernetesMetricCollector was omitted, causing HPA's KMC to be run during VPA's test. This caused the primary metrics of the test to not be collected. PiperOrigin-RevId: 844775997
1 parent 1ac23a3 commit 5df88b8

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

perfkitbenchmarker/linux_benchmarks/kubernetes_vpa_benchmark.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414
"""Runs a locust based vpa benchmark on a k8s cluster."""
1515

1616
import collections
17+
import threading
18+
import typing
1719
from typing import Any, Dict, List
1820

1921
from absl import flags
2022
import numpy as np
23+
from perfkitbenchmarker import background_tasks
2124
from perfkitbenchmarker import benchmark_spec as bm_spec
2225
from perfkitbenchmarker import configs
2326
from perfkitbenchmarker import container_service
2427
from perfkitbenchmarker.linux_benchmarks import kubernetes_hpa_benchmark as hpa
28+
from perfkitbenchmarker.linux_packages import locust
2529
from perfkitbenchmarker.sample import Sample
2630
from scipy import integrate
2731

@@ -83,8 +87,35 @@ def Prepare(benchmark_spec: bm_spec.BenchmarkSpec):
8387

8488
def Run(benchmark_spec: bm_spec.BenchmarkSpec) -> List[Sample]:
8589
"""Run a benchmark against the fibonacci server."""
90+
vm = benchmark_spec.vms[0]
91+
cluster: container_service.KubernetesCluster = typing.cast(
92+
container_service.KubernetesCluster, benchmark_spec.container_cluster
93+
)
94+
addr = cluster.DeployIngress('fib', 'fib', _PORT, _HEALTH_PATH)
95+
96+
# Confirm the server can be pinged.
97+
hpa.PollServer(vm, addr)
98+
99+
samples = []
100+
stop = threading.Event()
101+
102+
kmc = KubernetesMetricsCollector(samples, stop)
103+
104+
def RunLocust():
105+
for s in locust.Run(vm, addr):
106+
samples.append(s)
107+
stop.set()
108+
109+
background_tasks.RunThreaded(
110+
lambda f: f(),
111+
[
112+
lambda: kmc.ObserveCPUUsage(cluster, 'deploy/fib', 'fib'),
113+
lambda: kmc.ObserveCPURequests(cluster, 'deploy/fib', 'fib'),
114+
RunLocust,
115+
],
116+
max_concurrent_threads=3,
117+
)
86118

87-
samples = hpa.Run(benchmark_spec)
88119
samples.append(_ComputeOverUnderProvisioning(samples))
89120

90121
return samples

0 commit comments

Comments
 (0)