Add simple test for throttle filter driver. Without previous "block/throttle-groups: use QEMU_CLOCK_REALTIME for qtest too" commit the test hangs forever, because previously used VIRTUAL clock just doesn't tick for iotests.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@openvz.org> --- tests/qemu-iotests/tests/throttle | 50 +++++++++++++++++++++++++++ tests/qemu-iotests/tests/throttle.out | 0 2 files changed, 50 insertions(+) create mode 100755 tests/qemu-iotests/tests/throttle create mode 100644 tests/qemu-iotests/tests/throttle.out diff --git a/tests/qemu-iotests/tests/throttle b/tests/qemu-iotests/tests/throttle new file mode 100755 index 0000000000..63b802cee7 --- /dev/null +++ b/tests/qemu-iotests/tests/throttle @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# group: auto +# +# Simple test for throttle filter driver. +# +# Copyright (c) 2022 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import iotests + +with iotests.VM() as vm: + vm.launch() + + result = vm.qmp('object-add', { + 'qom-type': 'throttle-group', + 'id': 'group0', + 'limits': {'bps-write': 512 * 1024} + }) + assert result == {'return': {}} + + result = vm.qmp('blockdev-add', { + 'node-name': 'throt', + 'driver': 'throttle', + 'throttle-group': 'group0', + 'file': { + 'driver': 'null-co', + 'size': 1024 * 1024 + } + }) + assert result == {'return': {}} + + result = vm.hmp_qemu_io('throt', 'write 0 512K') + assert result == {'return': ''} + + # We need second write to trigger throttling + result = vm.hmp_qemu_io('throt', 'write 512K 512K') + assert result == {'return': ''} diff --git a/tests/qemu-iotests/tests/throttle.out b/tests/qemu-iotests/tests/throttle.out new file mode 100644 index 0000000000..e69de29bb2 -- 2.35.1