Skip to content

Commit

Permalink
iotests: Make 136 less flaky
Browse files Browse the repository at this point in the history
136 executes some AIO requests without a final aio_flush; then it
advances the virtual clock and thus expects the last access time of the
device to be less than the current time when queried (i.e. idle_time_ns
to be greater than 0).  However, without the aio_flush, some requests
may be settled after the clock_step invocation.  In that case,
idle_time_ns would be 0 and the test fails.

Fix this by adding an aio_flush if any AIO request other than some other
aio_flush has been executed.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Signed-off-by: Max Reitz <[email protected]>
  • Loading branch information
XanClic committed Nov 14, 2017
1 parent ddc7093 commit 1902681
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/qemu-iotests/136
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ sector = "%d"
for i in range(failed_wr_ops):
ops.append("aio_write %d 512" % bad_offset)

# We need an extra aio_flush to settle all outstanding AIO
# operations before we can advance the virtual clock, so that
# the last access happens before clock_step and idle_time_ns
# will be greater than 0
extra_flush = 0
if rd_ops + wr_ops + invalid_rd_ops + invalid_wr_ops + \
failed_rd_ops + failed_wr_ops > 0:
extra_flush = 1

if extra_flush > 0:
ops.append("aio_flush")

if failed_wr_ops > 0:
highest_offset = max(highest_offset, bad_offset + 512)

Expand All @@ -251,7 +263,7 @@ sector = "%d"
self.total_wr_bytes += wr_ops * wr_size
self.total_wr_ops += wr_ops
self.total_wr_merged += wr_merged
self.total_flush_ops += flush_ops
self.total_flush_ops += flush_ops + extra_flush
self.invalid_rd_ops += invalid_rd_ops
self.invalid_wr_ops += invalid_wr_ops
self.failed_rd_ops += failed_rd_ops
Expand Down

0 comments on commit 1902681

Please sign in to comment.