From 8d22cb3e4db0fc6e94a40b899df1abf68c0826fc Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Wed, 1 Apr 2020 14:08:34 +0200 Subject: [PATCH] test/ocf: clean metadata before test Now that we are switching to json config, metadata takes priority at startup, which can result in test failure because some devices were created from metadata. This patch uses clear_nvme() - the same function that is used in test/ocf/management/persistent-metadata.sh It is factored out in following patch. This patch fixes issue #1287 Change-Id: I16d40d0c1586a970c30761c0e1a81445621a419d Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1628 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- test/ocf/integrity/fio-modes.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/ocf/integrity/fio-modes.sh b/test/ocf/integrity/fio-modes.sh index ff6e475c2..114ff33e1 100755 --- a/test/ocf/integrity/fio-modes.sh +++ b/test/ocf/integrity/fio-modes.sh @@ -14,6 +14,27 @@ function cleanup(){ rm -f $curdir/modes.conf } +function clear_nvme() +{ + # Clear metadata on NVMe device + $rootdir/scripts/setup.sh reset + sleep 5 + name=$(get_nvme_name_from_bdf $1) + + mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w) + if [ "$mountpoints" != "0" ]; then + $rootdir/scripts/setup.sh + exit 1 + fi + dd if=/dev/zero of=/dev/$name bs=1M count=1000 oflag=direct + $rootdir/scripts/setup.sh +} + +# Clear only nvme device which we will use in test +bdf=$($rootdir/scripts/gen_nvme.sh --json | jq '.config[0].params.traddr' | sed s/\"//g) + +clear_nvme "$bdf" + trap "cleanup; exit 1" SIGINT SIGTERM EXIT nvme_cfg=$($rootdir/scripts/gen_nvme.sh)