Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[experimental]Add recovery functional tests #24

Open
wants to merge 1 commit into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/ocf/ocf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
46 changes: 46 additions & 0 deletions test/ocf/recovery/recovery-from-disk.sh
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions test/ocf/recovery/recovery-from-ram-neg.sh
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions test/ocf/recovery/recovery-from-ram-wrong-disk.sh
Original file line number Diff line number Diff line change
@@ -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