From cef2f89a87227c4948170040a47ffcf754c6f262 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Wed, 12 Jun 2019 14:59:38 -0400 Subject: [PATCH] Extend BVT tests to cover WO cache mode Signed-off-by: Adam Rutkowski --- test/smoke_test/basic/12 | 11 +++-- test/smoke_test/basic/13 | 86 +++++++++++++++++++++++++++++++++++ test/smoke_test/cas_functions | 2 +- 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100755 test/smoke_test/basic/13 diff --git a/test/smoke_test/basic/12 b/test/smoke_test/basic/12 index bd827ba..8a4ea6c 100755 --- a/test/smoke_test/basic/12 +++ b/test/smoke_test/basic/12 @@ -6,8 +6,7 @@ # The line below specified that line under it should be used as the test's short description when launching test via run_tests script. # The text should not be longer than 80 chars - if it is, the script will strip addititonal characters -# DESCRIPTION WriteBack mode test: Test files on core devices with different filesystems after flushing and stopping cache -# with 'don't flush dirty data on exit' option. +# DESCRIPTION WB data integrity ext3/ext4/xfs after clean shutdown, no flush # USE_IN_NIGHTLY # USE_IN_BVT @@ -18,6 +17,8 @@ TESTS_DIR="$(dirname $0)/../" . $TESTS_DIR/cas_lib start_test $* +CACHE_MODE="wb" + # This is where the real test starts # Use CACHE_DEVICE and CORE_DEVICE provided by configuration file and remove partitions from those devices @@ -30,15 +31,15 @@ TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions # Start cache on CACHE_DEVICE1 (/dev/sdd1, for example) with ID=1 and add a core device using CORE_DEVICE1 (/dev/sde1, for example) -CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION="wb" start_cache +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core # Start cache on CACHE_DEVICE2 (/dev/sdd2, for example) with ID=2 and add a core device using CORE_DEVICE2 (/dev/sde2, for example) -CACHE_ID_OPTION="2" CACHE_DEVICE_OPTION="${CACHE_DEVICE}2" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION="wb" start_cache +CACHE_ID_OPTION="2" CACHE_DEVICE_OPTION="${CACHE_DEVICE}2" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache CACHE_ID_OPTION="2" CORE_DEVICE_OPTION="${CORE_DEVICE}2" add_core # Start cache on CACHE_DEVICE3 (/dev/sdd3, for example) with ID=3 and add a core device using CORE_DEVICE3 (/dev/sde3, for example) -CACHE_ID_OPTION="3" CACHE_DEVICE_OPTION="${CACHE_DEVICE}3" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION="wb" start_cache +CACHE_ID_OPTION="3" CACHE_DEVICE_OPTION="${CACHE_DEVICE}3" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache CACHE_ID_OPTION="3" CORE_DEVICE_OPTION="${CORE_DEVICE}3" add_core # Create filesystems on cached devices - we do this using run_cmd because it is not in the API (and probably won't be). diff --git a/test/smoke_test/basic/13 b/test/smoke_test/basic/13 new file mode 100755 index 0000000..2db81cd --- /dev/null +++ b/test/smoke_test/basic/13 @@ -0,0 +1,86 @@ +#!/bin/bash +# +# Copyright(c) 2012-2019 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +# The line below specified that line under it should be used as the test's short description when launching test via run_tests script. +# The text should not be longer than 80 chars - if it is, the script will strip addititonal characters +# DESCRIPTION WO data integrity ext3/ext4/xfs after clean shutdown, no flush + +# USE_IN_NIGHTLY +# USE_IN_BVT +# Standard beginning for every test - get the main tests directory and +# link the cas_lib file for CAS API, then use "start_test $*" to pass params +# and do other necessary checks and setup +TESTS_DIR="$(dirname $0)/../" +. $TESTS_DIR/cas_lib +start_test $* + +CACHE_MODE="wo" + +# This is where the real test starts + +# Use CACHE_DEVICE and CORE_DEVICE provided by configuration file and remove partitions from those devices +TARGET_DEVICE_OPTION="$CACHE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions + +# Create 3 primary partitions on CACHE_DEVICE, each of 2000M size +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions +# Create 3 primary partitions on CORE_DEVICE, each of 4000M size +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +# Start cache on CACHE_DEVICE1 (/dev/sdd1, for example) with ID=1 and add a core device using CORE_DEVICE1 (/dev/sde1, for example) +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core + +# Start cache on CACHE_DEVICE2 (/dev/sdd2, for example) with ID=2 and add a core device using CORE_DEVICE2 (/dev/sde2, for example) +CACHE_ID_OPTION="2" CACHE_DEVICE_OPTION="${CACHE_DEVICE}2" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache +CACHE_ID_OPTION="2" CORE_DEVICE_OPTION="${CORE_DEVICE}2" add_core + +# Start cache on CACHE_DEVICE3 (/dev/sdd3, for example) with ID=3 and add a core device using CORE_DEVICE3 (/dev/sde3, for example) +CACHE_ID_OPTION="3" CACHE_DEVICE_OPTION="${CACHE_DEVICE}3" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache +CACHE_ID_OPTION="3" CORE_DEVICE_OPTION="${CORE_DEVICE}3" add_core + +# Create filesystems on cached devices - we do this using run_cmd because it is not in the API (and probably won't be). +# The test framework will accept invoking the commands directly (e.g. "mkfs.ext3 [...]" without the "run_cmd"), but the +# results have to be checked manually by the test. +TARGET_DEVICE_OPTION="${DEVICE_NAME}1-1" FILESYSTEM_TYPE="ext3" make_filesystem +TARGET_DEVICE_OPTION="${DEVICE_NAME}2-1" FILESYSTEM_TYPE="ext4" make_filesystem +TARGET_DEVICE_OPTION="${DEVICE_NAME}3-1" FILESYSTEM_TYPE="xfs" make_filesystem + +# Specify a temporary file used for md5sums - note that it resides in $TMP_DIR, which is a special directory defined in cas_config. +# Everytime we use temporary files, they should be placed in that special directory. Its contents are cleared after every test. +MD5_FILE="$TMP_DIR/cas_md5_sum_" + +# Mount the filesystems, then create the example files and save their MD5 sums locally in the temporary place +# Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}. +for ID in 1 2 3 ; do + CACHE_ID_OPTION="$ID" CORE_ID_OPTION="1" mount_cache + run_cmd "dd if=/dev/urandom of=${MOUNTPOINT}-${ID}-1/test bs=50M count=1" + run_cmd "md5sum ${MOUNTPOINT}-${ID}-1/test > ${MD5_FILE}_${ID}" +done + +# Umount & stop the caches, then mount the core devices +# Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}. +for ID in 1 2 3 ; do + run_cmd "umount ${MOUNTPOINT}-${ID}-1" + CACHE_ID_OPTION="$ID" flush_cache + CACHE_ID_OPTION="$ID" CACHE_DONT_FLUSH_DATA_OPTION="1" stop_cache + run_cmd dd if=/dev/zero of="${CACHE_DEVICE}${ID}" bs=1M count=1 oflag=direct + run_cmd "mount ${CORE_DEVICE}${ID} ${MOUNTPOINT}-${ID}-1" +done + +# Now check for files' presence and umount core devices +# Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}. +for ID in 1 2 3 ; do + run_cmd "test -f ${MOUNTPOINT}-${ID}-1/test" + run_cmd "md5sum -c ${MD5_FILE}_${ID}" + run_cmd "umount ${MOUNTPOINT}-${ID}-1" +done + +# Always return 0 at the end of the test - if at any point something has failed +# in the API functions, test will end and return a proper result. +# If you need to check other things during the test and end the test earlier, you +# should end the test using "end_test $retval" function +end_test 0 diff --git a/test/smoke_test/cas_functions b/test/smoke_test/cas_functions index 521ba17..ed65bfd 100644 --- a/test/smoke_test/cas_functions +++ b/test/smoke_test/cas_functions @@ -359,7 +359,7 @@ iteration() { fi if [ -n "$CACHE_MODE_OPTION" ] ; then if [ "$CACHE_MODE_OPTION" == "all" ] ; then - L_CACHE_MODE_OPTION="wa wb wt pt" + L_CACHE_MODE_OPTION="wa wb wt pt wo" else L_CACHE_MODE_OPTION="$CACHE_MODE_OPTION" fi