Skip to content

Commit b267124

Browse files
committed
Add debugging steps to disposable performance test
For: QubesOS/qubes-issues#1512 For: #708
1 parent 8de4cd0 commit b267124

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

qubes/tests/integ/dispvm_perf.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ def tearDown(self: qubes.tests.SystemTestCase):
7373
self.vm2.shutdown(),
7474
)
7575
)
76-
if not os.getenv("QUBES_TEST_SKIP_TEARDOWN_SLEEP"):
77-
# Avoid previous test load interfering with new test.
78-
if self._testMethodName.startswith("vm"):
79-
delay = 5
80-
else:
81-
delay = 15
82-
time.sleep(delay)
8376

8477
def run_test(self, name):
8578
dvm = self.dvm.name

tests/dispvm_perf.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,17 @@ class TestConfig:
170170
preload_max=MAX_CONCURRENCY,
171171
),
172172
TestConfig("dispvm-api", admin_api=True),
173-
TestConfig("dispvm-concurrent-api", concurrent=True, admin_api=True),
173+
TestConfig(
174+
"dispvm-concurrent-api",
175+
concurrent=True,
176+
admin_api=True,
177+
),
174178
TestConfig("dispvm-gui-api", gui=True, admin_api=True),
175179
TestConfig(
176-
"dispvm-gui-concurrent-api", gui=True, concurrent=True, admin_api=True
180+
"dispvm-gui-concurrent-api",
181+
gui=True,
182+
concurrent=True,
183+
admin_api=True,
177184
),
178185
TestConfig(
179186
"dispvm-preload-more-api",
@@ -189,7 +196,7 @@ class TestConfig:
189196
TestConfig(
190197
"dispvm-preload-concurrent-api",
191198
concurrent=True,
192-
preload_max=MAX_PRELOAD,
199+
preload_max=MAX_CONCURRENCY,
193200
admin_api=True,
194201
),
195202
TestConfig(
@@ -202,12 +209,18 @@ class TestConfig:
202209
"dispvm-preload-gui-concurrent-api",
203210
gui=True,
204211
concurrent=True,
205-
preload_max=MAX_PRELOAD,
212+
preload_max=MAX_CONCURRENCY,
206213
admin_api=True,
207214
),
208215
]
209216

210217

218+
def get_load() -> str:
219+
with open("/proc/loadavg", "r", encoding="ascii") as file:
220+
load = file.read()
221+
return load.rstrip()
222+
223+
211224
def get_time():
212225
return time.clock_gettime(time.CLOCK_MONOTONIC)
213226

@@ -327,8 +340,12 @@ def run_latency_calls(self, test):
327340
f" {e.stdout},"
328341
f" {e.stderr}"
329342
)
330-
except subprocess.TimeoutExpired:
331-
raise Exception(f"service '{cmd}' failed: timeout expired")
343+
except subprocess.TimeoutExpired as e:
344+
raise Exception(
345+
f"service '{cmd}' failed: timeout expired:"
346+
f" {e.stdout},"
347+
f" {e.stderr}"
348+
)
332349
end_time = get_time()
333350
return round(end_time - start_time, ROUND_PRECISION)
334351

@@ -342,17 +359,22 @@ def call_api(self, test, service, qube):
342359
target_qube = self.vm1
343360
else:
344361
target_qube = qubesadmin.vm.DispVM.from_appvm(app, appvm)
362+
name = target_qube.name
345363
target_time = get_time()
346364
try:
347365
target_qube.run_service_for_stdio(service, timeout=60)
348366
except subprocess.CalledProcessError as e:
349367
raise Exception(
350-
f"service '{service}' failed ({e.returncode}):"
368+
f"'{name}': service '{service}' failed ({e.returncode}):"
369+
f" {e.stdout},"
370+
f" {e.stderr}"
371+
)
372+
except subprocess.TimeoutExpired as e:
373+
raise Exception(
374+
f"'{name}': service '{service}' failed: timeout expired:"
351375
f" {e.stdout},"
352376
f" {e.stderr}"
353377
)
354-
except subprocess.TimeoutExpired:
355-
raise Exception(f"service '{service}' failed: timeout expired")
356378
run_service_time = get_time()
357379
if not test.non_dispvm:
358380
target_qube.cleanup()
@@ -514,6 +536,7 @@ def run_test(self, test: TestConfig):
514536
preload_max = test.preload_max
515537
self.dvm.features["preload-dispvm-max"] = str(preload_max)
516538
asyncio.run(self.wait_preload(preload_max))
539+
print(f"Load before test: '{get_load()}'")
517540
if test.admin_api:
518541
result = self.run_latency_api_calls(test)
519542
else:
@@ -534,6 +557,18 @@ def run_test(self, test: TestConfig):
534557
if orig_preload_max != 0:
535558
asyncio.run(self.wait_preload(orig_preload_max))
536559
os.unlink(POLICY_FILE)
560+
if not os.getenv("QUBES_TEST_SKIP_TEARDOWN_SLEEP"):
561+
print(f"Load before sleep: '{get_load()}'")
562+
delay = 5
563+
if not test.non_dispvm:
564+
delay += 10
565+
if test.gui:
566+
delay += 2
567+
if test.concurrent:
568+
delay += 8
569+
print(f"Sleeping for '{delay}' seconds")
570+
time.sleep(delay)
571+
print(f"Load after sleep: '{get_load()}'")
537572

538573

539574
def main():
@@ -567,7 +602,7 @@ def main():
567602
if args.iterations:
568603
run.iterations = args.iterations
569604

570-
for index, test in enumerate(tests):
605+
for test in tests:
571606
run.run_test(test)
572607

573608

0 commit comments

Comments
 (0)