Skip to content

Commit 74c8d04

Browse files
committed
Inc_backup: fix a size check failure
Sometimes the actual block allocation isn't in the configured test scope. Because dd_seek is used in data writes and due to the sparsity of the qcow2 format. Now adjust the size check method to fix it. Signed-off-by: Meina Li <[email protected]>
1 parent 251d5bd commit 74c8d04

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

libvirt/tests/src/incremental_backup/incremental_backup_pull_mode_info.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def check_scratch_info(scratch_device):
125125
if scratch_device in three_domstats_output.stdout_text:
126126
test.fail("The scratch device is still existed which is not expected!")
127127

128-
def check_domblk_info(target_min, target_max):
128+
def check_domblk_info(dd_count, dd_seek):
129129
"""
130130
Check the domblk info.
131131
@@ -134,10 +134,17 @@ def check_domblk_info(target_min, target_max):
134134
"""
135135
test.log.debug("TEST STEP: check the domblk info")
136136
domblk_output = virsh.domblkinfo(vm_name, target_disk, debug=True)
137-
block_allocation = 0
138137
for line in domblk_output.stdout_text.splitlines():
139138
if "Allocation" in line:
140-
block_allocation = int(line.split(":")[-1].strip())
139+
block_allocation = float(line.split(":")[-1].strip())
140+
if "Capacity" in line:
141+
disk_capacity_bytes = float(line.split(":")[-1].strip())
142+
capacity_MB = disk_capacity_bytes / 1024 / 1024
143+
write_end_MB = int(dd_seek) + int(dd_count)
144+
expected_MB = min(write_end_MB, capacity_MB)
145+
target_min = expected_MB * 0.8
146+
target_max = expected_MB * 1.2
147+
block_allocation = block_allocation / 1024 / 1024
141148
if not (target_min <= block_allocation <= target_max):
142149
test.fail("The block allocation %s is not expected! It's not between %s and %s."
143150
% (block_allocation, target_min, target_max))
@@ -169,7 +176,7 @@ def check_domblk_info(target_min, target_max):
169176
test.log.debug("TEST STEP2: write datas to the guest disk.")
170177
write_datas(dd_seek)
171178
if domblkinfo_check:
172-
check_domblk_info(target_min, target_max)
179+
check_domblk_info(dd_count, dd_seek)
173180
test.log.debug("TEST STEP3: prepare the backup xml.")
174181
backup_options, scratch_device = prepare_backup_xml()
175182
test.log.debug("TEST STEP4: start the backup job.")
@@ -180,11 +187,12 @@ def check_domblk_info(target_min, target_max):
180187
if not domblkinfo_check:
181188
check_scratch_info(scratch_device)
182189
else:
183-
check_domblk_info(target_min, target_max)
184-
write_datas(dd_seek="300")
185-
check_domblk_info(target_min * 2, target_max * 2)
190+
check_domblk_info(dd_count, dd_seek)
191+
dd_seek = 300
192+
write_datas(dd_seek)
193+
check_domblk_info(dd_count, dd_seek)
186194
virsh.domjobabort(vm_name, debug=True, ignore_status=False)
187-
check_domblk_info(target_min * 2, target_max * 2)
195+
check_domblk_info(dd_count, dd_seek)
188196

189197
finally:
190198
if vm.is_alive():

0 commit comments

Comments
 (0)