diff --git a/test/ocf/ocf.sh b/test/ocf/ocf.sh index dd81371f35e..e29e32f942a 100755 --- a/test/ocf/ocf.sh +++ b/test/ocf/ocf.sh @@ -5,6 +5,9 @@ rootdir=$(readlink -f $testdir/../..) source $rootdir/test/common/autotest_common.sh +run_test "ocf_recovery_from_ram_wrong_disk" "$testdir/recovery/recovery-from-ram-wrong-disk.sh" +run_test "ocf_recovery_from_ram_neg" "$testdir/recovery/recovery-from-ram-neg.sh" +run_test "ocf_recovery_from_disk" "$testdir/recovery/recovery-from-disk.sh" run_test "ocf_fio_modes" "$testdir/integrity/fio-modes.sh" run_test "ocf_bdevperf_iotypes" "$testdir/integrity/bdevperf-iotypes.sh" run_test "ocf_stats" "$testdir/integrity/stats.sh" diff --git a/test/ocf/recovery/recovery-from-disk.sh b/test/ocf/recovery/recovery-from-disk.sh new file mode 100755 index 00000000000..6045c2808d2 --- /dev/null +++ b/test/ocf/recovery/recovery-from-disk.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/ocf/common.sh +source $rootdir/scripts/common.sh +source $rootdir/test/common/autotest_common.sh +rpc_py=$rootdir/scripts/rpc.py + + +# Setup NVMe devices +$rootdir/scripts/setup.sh + +# Create NVMe config +prepare_nvme_config + +# Clear nvme device which we will use in test +clear_nvme + +# Start SPDK app +start_spdk "$curdir/config" + +# Create 2x256MiB partitions on NVMe device +create_partitions Nvme0n1 2 256 + +# Create CAS device +$rpc_py bdev_ocf_create cas_dev wb Nvme0n1p0 Nvme0n1p1 --create --force + +# Save config +save_and_clean_bdev_config + +# Stop SPDK app +stop_spdk + +# Remove metadata files from RAM +rm -f /dev/shm/cas_dev* + +# Check if recovery from disk works properly +start_spdk "$curdir/config" + +$rpc_py bdev_ocf_get_bdevs | jq -r '.[] .started' | grep true +$rpc_py bdev_ocf_get_bdevs | jq -r '.[] .cache.attached' | grep true +$rpc_py bdev_ocf_get_bdevs | jq -r '.[] .core.attached' | grep true + +# Stop SPDK app +stop_spdk diff --git a/test/ocf/recovery/recovery-from-ram-neg.sh b/test/ocf/recovery/recovery-from-ram-neg.sh new file mode 100755 index 00000000000..a16481fd3ac --- /dev/null +++ b/test/ocf/recovery/recovery-from-ram-neg.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/ocf/common.sh +source $rootdir/scripts/common.sh +source $rootdir/test/common/autotest_common.sh +rpc_py=$rootdir/scripts/rpc.py + + +# Setup NVMe devices +$rootdir/scripts/setup.sh + +for i in 1 2 +do + # Create NVMe config + prepare_nvme_config + + # Clear nvme device which we will use in test + clear_nvme + + # Start SPDK app + start_spdk "$curdir/config" + + # Create 2x256MiB partitions on NVMe device + create_partitions Nvme0n1 2 256 + + # Create CAS device + $rpc_py bdev_ocf_create cas_dev wb Nvme0n1p0 Nvme0n1p1 --create --force + + # Save config + save_and_clean_bdev_config + + # Stop SPDK app + stop_spdk + + # Clear NVMe devices + clear_nvme + + # Remove one OCF metadata file + rm -f /dev/shm/ocf.cas_dev.$i + + # Start SPDK app with config and check if CAS did not start successfully + start_spdk "$curdir/config" + + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .started' | grep false + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .cache.attached' | grep false + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .core.attached' | grep false + + # Stop SPDK app + stop_spdk +done diff --git a/test/ocf/recovery/recovery-from-ram-wrong-disk.sh b/test/ocf/recovery/recovery-from-ram-wrong-disk.sh new file mode 100755 index 00000000000..847a0d9c15c --- /dev/null +++ b/test/ocf/recovery/recovery-from-ram-wrong-disk.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +rootdir=$(readlink -f $curdir/../../..) +source $rootdir/test/ocf/common.sh +source $rootdir/scripts/common.sh +source $rootdir/test/common/autotest_common.sh +rpc_py=$rootdir/scripts/rpc.py + + +# Setup NVMe devices +$rootdir/scripts/setup.sh + +# Create NVMe config +prepare_nvme_config + +# Clear nvme device which we will use in test +clear_nvme + +# Start SPDK app +start_spdk "$curdir/config" + +# Create 3x256MiB partitions on NVMe device +create_partitions Nvme0n1 3 256 + +# Create CAS device +$rpc_py bdev_ocf_create cas_dev wb Nvme0n1p0 Nvme0n1p1 --create --force + +# Save config +save_and_clean_bdev_config + +# Stop SPDK app +stop_spdk + +# Copy original config file to temporary file +cp "$curdir/config" /tmp/config + +for i in 1 2 +do + # Clear NVMe devices + clear_nvme + + # Change cache device in config + sed -i "s/Nvme0n1p$i/Nvme0n1p3/g" "$curdir/config" + + # Start SPDK app with config and check if CAS did not start successfully + start_spdk "$curdir/config" + + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .started' | grep false + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .cache.attached' | grep false + $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .core.attached' | grep false + + # Stop SPDK app + stop_spdk + + # Restore original config + cp /tmp/config "$curdir/config" +done +