On 18.03.26 17:54, Fiona Ebner wrote:
Mostly in preparation for commit "iotests/041: add test for duplicate
job-complete with throttled target".

Use a second VM instance for providing the NBD export rather than
qemu-storage-daemon, because the latter does not support qtest for
stepping the clock.

Use copy_mode='write-blocking' for easy checking how many bytes were
written in a given time. In the job's offset, the numbers are
inflated, since a 1 KiB write will mean copying a full cluster of
64 KiB.

Signed-off-by: Fiona Ebner <[email protected]>
---
  tests/qemu-iotests/041     | 155 +++++++++++++++++++++++++++++++++++++
  tests/qemu-iotests/041.out |   4 +-
  2 files changed, 157 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index 8452845f44..7b4a701aba 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -1373,6 +1373,161 @@ class TestFilters(iotests.QMPTestCase):

[...]

+        # Check that requests do not complete faster than 1 per second. They
+        # might complete in batches, so do not check for exactly 1 per second.
+        for i in range(0, self.reqs):
+            result = self.vm.cmd('query-blockstats')
+            assert result[0]['stats']['wr_bytes'] <= (i + 1) * self.req_len
+
+            self.target_vm.qtest(f'clock_step {1 * 1000 * 1000 * 1000}')
+            time.sleep(0.1)
+
+        time.sleep(2)

I’m still not so happy about this sleep (in the loop it’s fine). What exactly do we need it for, what are we trying to test here? It looks like it’s testing that the throttle driver allows the right number of writes through, as it should, but I feel like that should go into another test that uses null as a back-end so that it is not prone to flakiness. I think here we should just trust that the throttle driver works, that is, maybe just complete the job under throttle? Would that work?

Hanna

+
+        # Check that all requests are complete.
+        result = self.vm.cmd('query-blockstats')
+        self.assertEqual(result[0]['stats']['wr_bytes'],
+                         self.reqs * self.req_len)
+
+        self.disable_throttling()
+
+        self.complete_and_wait('mirror', wait_ready=False)
+        self.target_vm.shutdown()
+        self.vm.shutdown()
+        self.assertTrue(iotests.compare_images(test_img, target_img),
+                        'target image does not match source after mirroring')
if __name__ == '__main__':
      iotests.main(supported_fmts=['qcow2', 'qed'],


Reply via email to