-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple connection latency, and throughput tests. Run them with different type of services (scripts, socket, via fork-server or not). They print a test run time for comparison - the lower the better. The tests can be also started outside of the full test run by calling /usr/lib/qubes/tests/qrexec_perf.py. It requires giving names of two existing and running VMs. QubesOS/qubes-issues#5740
- Loading branch information
Showing
5 changed files
with
375 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# | ||
# The Qubes OS Project, https://www.qubes-os.org/ | ||
# | ||
# Copyright (C) 2025 Marek Marczykowski-Górecki | ||
# <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation; either version 2.1 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License along | ||
# with this program; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
import asyncio | ||
import os | ||
import subprocess | ||
import sys | ||
import time | ||
|
||
import qubes.tests | ||
|
||
|
||
class TC_00_QrexecPerfMixin: | ||
def setUp(self: qubes.tests.SystemTestCase): | ||
super().setUp() | ||
self.vm1 = self.app.add_new_vm( | ||
"AppVM", | ||
name=self.make_vm_name("vm1"), | ||
label="red", | ||
) | ||
self.vm2 = self.app.add_new_vm( | ||
"AppVM", | ||
name=self.make_vm_name("vm2"), | ||
label="red", | ||
) | ||
self.loop.run_until_complete( | ||
asyncio.gather( | ||
self.vm1.create_on_disk(), | ||
self.vm2.create_on_disk(), | ||
) | ||
) | ||
self.loop.run_until_complete( | ||
asyncio.gather( | ||
self.vm1.start(), | ||
self.vm2.start(), | ||
) | ||
) | ||
|
||
def run_test(self, name): | ||
cmd = [ | ||
"/usr/lib/qubes/tests/qrexec_perf.py", | ||
f"--vm1={self.vm1.name}", | ||
f"--vm2={self.vm2.name}", | ||
name, | ||
] | ||
p = self.loop.run_until_complete(asyncio.create_subprocess_exec(*cmd)) | ||
self.loop.run_until_complete(p.wait()) | ||
if p.returncode: | ||
self.fail(f"'{' '.join(cmd)}' failed: {p.returncode}") | ||
|
||
def test_000_simple(self): | ||
"""Measure simple exec-based vm-vm calls latency""" | ||
self.loop.run_until_complete(self.wait_for_session(self.vm2)) | ||
self.run_test("exec") | ||
|
||
def test_010_simple_root(self): | ||
"""Measure simple exec-based vm-vm calls latency, use root to | ||
bypass qrexec-fork-server""" | ||
self.run_test("exec-root") | ||
|
||
def test_020_socket(self): | ||
"""Measure simple socket-based vm-vm calls latency""" | ||
self.run_test("socket") | ||
|
||
def test_030_socket_root(self): | ||
"""Measure simple socket-based vm-vm calls latency, use root to | ||
bypass qrexec-fork-server""" | ||
self.run_test("socket-root") | ||
|
||
def test_100_simple_data_simplex(self): | ||
"""Measure simple exec-based vm-vm calls throughput""" | ||
self.run_test("exec-data-simplex") | ||
|
||
def test_110_simple_data_duplex(self): | ||
"""Measure simple exec-based vm-vm calls throughput""" | ||
self.run_test("exec-data-duplex") | ||
|
||
def test_120_simple_data_duplex_root(self): | ||
"""Measure simple exec-based vm-vm calls throughput""" | ||
self.run_test("exec-data-duplex-root") | ||
|
||
def test_130_socket_data_duplex(self): | ||
"""Measure simple socket-based vm-vm calls throughput""" | ||
self.run_test("socket-data-duplex") | ||
|
||
|
||
def create_testcases_for_templates(): | ||
return qubes.tests.create_testcases_for_templates( | ||
"TC_00_QrexecPerf", | ||
TC_00_QrexecPerfMixin, | ||
qubes.tests.SystemTestCase, | ||
module=sys.modules[__name__], | ||
) | ||
|
||
|
||
def load_tests(loader, tests, pattern): | ||
tests.addTests(loader.loadTestsFromNames(create_testcases_for_templates())) | ||
return tests | ||
|
||
|
||
qubes.tests.maybe_create_testcases_on_import(create_testcases_for_templates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -526,6 +526,7 @@ done | |
%{python3_sitelib}/qubes/tests/integ/grub.py | ||
%{python3_sitelib}/qubes/tests/integ/salt.py | ||
%{python3_sitelib}/qubes/tests/integ/qrexec.py | ||
%{python3_sitelib}/qubes/tests/integ/qrexec_perf.py | ||
%{python3_sitelib}/qubes/tests/integ/storage.py | ||
%{python3_sitelib}/qubes/tests/integ/vm_qrexec_gui.py | ||
|
||
|
@@ -547,6 +548,7 @@ done | |
/usr/lib/qubes/cleanup-dispvms | ||
/usr/lib/qubes/fix-dir-perms.sh | ||
/usr/lib/qubes/startup-misc.sh | ||
/usr/lib/qubes/tests/qrexec_perf.py | ||
%{_unitdir}/[email protected]/30_qubes.conf | ||
%{_unitdir}/qubes-core.service | ||
%{_unitdir}/qubes-qmemman.service | ||
|
Oops, something went wrong.