test/lvol: Add test to check 'clear_method none' behaviour

Change-Id: I5e4581a8d9b100c965d14dc3e263084c4b729af6
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467967
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Pawel Kaminski 2019-09-10 10:44:54 -04:00 committed by Tomasz Zawadzki
parent ca667d064f
commit 6fc7f49c16
3 changed files with 72 additions and 2 deletions

View File

@ -72,6 +72,7 @@ function usage() {
802: 'rename_lvs_EEXIST',
803: 'bdev_lvol_rename_nonexistent',
804: 'bdev_lvol_rename_EEXIST',
850: 'clear_method_none',
10000: 'SIGTERM'
or
all: This parameter runs all tests

View File

@ -126,7 +126,7 @@ class Commands_Rpc(object):
output = self.rpc.bdev_lvol_create_lvstore(base_name, lvs_name)[0]
return output.rstrip('\n')
def bdev_lvol_create(self, uuid, lbd_name, size, thin=False):
def bdev_lvol_create(self, uuid, lbd_name, size, thin=False, clear_method=None):
print("INFO: RPC COMMAND bdev_lvol_create")
try:
uuid_obj = UUID(uuid)
@ -136,7 +136,10 @@ class Commands_Rpc(object):
thin_provisioned = ""
if thin:
thin_provisioned = "-t"
output = self.rpc.bdev_lvol_create(name_opt, uuid, lbd_name, size, thin_provisioned)[0]
c_m = ""
if clear_method:
c_m = "--clear-method {clear_m}".format(clear_m=clear_method)
output = self.rpc.bdev_lvol_create(name_opt, uuid, lbd_name, size, thin_provisioned, c_m)[0]
return output.rstrip('\n')
def bdev_lvol_delete_lvstore(self, uuid):

View File

@ -1,4 +1,5 @@
import io
import math
import time
import sys
import random
@ -169,6 +170,8 @@ def case_message(func):
802: 'rename_lvs_EEXIST',
803: 'bdev_lvol_rename_nonexistent',
804: 'bdev_lvol_rename_EEXIST',
# logical volume clear_method test
850: 'clear_method_none',
# SIGTERM
10000: 'SIGTERM',
}
@ -3061,6 +3064,69 @@ class TestCases(object):
# - no other operation fails
return fail_count
@case_message
def test_case850(self):
""""
Clear_method
Test for clear_method equals to none
"""
# Create malloc bdev
base_name = self.c.bdev_malloc_create(self.total_size,
self.block_size)
# Construct lvol store on created malloc bddev
lvs_uuid = self.c.bdev_lvol_create_lvstore(base_name,
self.lvs_name)
# Check correct uuid values in response bdev_lvol_get_lvstores command
fail_count = self.c.check_bdev_lvol_get_lvstores(base_name, lvs_uuid,
self.cluster_size)
lvs = self.c.bdev_lvol_get_lvstores(self.lvs_name)[0]
# Construct lvol bdev on lvol store
lbd_size = int(lvs['cluster_size'] / MEGABYTE)
bdev_uuid = self.c.bdev_lvol_create(lvs_uuid,
self.lbd_name,
lbd_size,
clear_method='none')
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_uuid)
nbd_name = "/dev/nbd0"
fail_count += self.c.nbd_start_disk(bdev_uuid, nbd_name)
# Write pattern to lvol bdev starting from offset 0.
fail_count += self.run_fio_test(nbd_name, 0, lvs['cluster_size'],
"write", "0xdd")
fail_count += self.c.nbd_stop_disk(nbd_name)
# Delete lvol bdev
fail_count += self.c.bdev_lvol_delete(bdev_uuid)
# Delete lvol store. We need to do this so that we can attach the underlying malloc
# bdev to nbd to examine its contents.
fail_count += self.c.bdev_lvol_delete_lvstore(lvs_uuid)
fail_count += self.c.nbd_start_disk(base_name, nbd_name)
metadata_pages = 1 + lvs['total_data_clusters'] + (math.ceil(5 + math.ceil(lvs['total_data_clusters'] / 8) / 4096)) * 3
last_metadata_lba = int(metadata_pages * 4096 / self.block_size)
offset_metadata_end = int(last_metadata_lba * self.block_size)
last_cluster_of_metadata = math.ceil(metadata_pages / lvs['cluster_size'] / 4096)
offset = last_cluster_of_metadata * lvs['cluster_size']
size_metadata_end = offset - offset_metadata_end
# Check if data on area between end of metadata
# and first cluster of lvol bdev remained unchaged
fail_count += self.run_fio_test("/dev/nbd0", offset_metadata_end,
size_metadata_end, "read", "0x00")
# Check if data on first lvol bdevs remains unchanged.
fail_count += self.run_fio_test("/dev/nbd0", offset, lvs['cluster_size'], "read", "0xdd")
fail_count += self.c.nbd_stop_disk(nbd_name)
self.c.bdev_malloc_delete(base_name)
# Expected result:
# - calls successful, return code = 0
# - get_bdevs: no change
# - no other operation fails
return fail_count
@case_message
def test_case10000(self):
"""