From 5ff092eddbe37cf7831518923a0b15eba7410be1 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Tue, 2 Jul 2019 10:44:18 -0400 Subject: [PATCH] Extend smoke tests set Signed-off-by: Michal Mielewczyk --- test/smoke_test/cache_suspend/01 | 238 ++++++++++++++++++++ test/smoke_test/cache_suspend/02 | 204 +++++++++++++++++ test/smoke_test/cache_suspend/03 | 169 ++++++++++++++ test/smoke_test/eviction_policy/01 | 95 ++++++++ test/smoke_test/eviction_policy/02 | 337 ++++++++++++++++++++++++++++ test/smoke_test/eviction_policy/03 | 330 +++++++++++++++++++++++++++ test/smoke_test/incremental_load/01 | 74 ++++++ test/smoke_test/incremental_load/02 | 82 +++++++ test/smoke_test/init_script/01 | 67 ++++++ test/smoke_test/init_script/02 | 73 ++++++ test/smoke_test/init_script/03 | 78 +++++++ test/smoke_test/recovery/01 | 92 ++++++++ test/smoke_test/recovery/02 | 95 ++++++++ test/smoke_test/write_back/01 | 133 +++++++++++ test/smoke_test/write_back/02 | 114 ++++++++++ 15 files changed, 2181 insertions(+) create mode 100755 test/smoke_test/cache_suspend/01 create mode 100755 test/smoke_test/cache_suspend/02 create mode 100755 test/smoke_test/cache_suspend/03 create mode 100755 test/smoke_test/eviction_policy/01 create mode 100755 test/smoke_test/eviction_policy/02 create mode 100755 test/smoke_test/eviction_policy/03 create mode 100755 test/smoke_test/incremental_load/01 create mode 100755 test/smoke_test/incremental_load/02 create mode 100755 test/smoke_test/init_script/01 create mode 100755 test/smoke_test/init_script/02 create mode 100755 test/smoke_test/init_script/03 create mode 100755 test/smoke_test/recovery/01 create mode 100755 test/smoke_test/recovery/02 create mode 100755 test/smoke_test/write_back/01 create mode 100755 test/smoke_test/write_back/02 diff --git a/test/smoke_test/cache_suspend/01 b/test/smoke_test/cache_suspend/01 new file mode 100755 index 0000000..b67272b --- /dev/null +++ b/test/smoke_test/cache_suspend/01 @@ -0,0 +1,238 @@ +#!/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 Change cache mode while IO is serviced + +# USE_IN_NIGHTLY + +# 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 $* + +TEST_JOBS_NR=8 +TEST_JOBS_FILES_NR=100 +TEST_JOBS_FILES_SIZE=1M + +TEST_JOBS_FILE=/tmp/cas.test. +TEST_JOBS_RESULT=/tmp/cas.result + +TEST_JOBS_PIDS= +TEST_JOB_SUSPEND_PID= +TEST_JOBS_TIME=20 + +TEST_CORE_DEVICE_SIZE=${TEST_JOBS_NR}*${TEST_JOBS_FILES_NR}*$(get_bytes ${TEST_JOBS_FILES_SIZE})+$(get_bytes "3G") +let TEST_CORE_DEVICE_SIZE=$TEST_CORE_DEVICE_SIZE +let TEST_CORE_DEVICE_SIZE=$TEST_CORE_DEVICE_SIZE/$(get_bytes "G") + +TEST_CORE_DEVICE_SIZE="${TEST_CORE_DEVICE_SIZE}G" +TEST_CACHE_DEVICE_SIZE=400M + +#param1 - Job ID +cache_suspend_job() { + local L_ITER=2 + local L_JOB_ID=$1 + local L_FILE="" + local L_FILE_CAS="" + local L_RESULT="0" + local L_FILE_RESULT="${TEST_JOBS_RESULT}-${L_JOB_ID}" + + echo $L_RESULT > $L_FILE_RESULT + + while [ true ] + do + test_log_trace "Test job $L_JOB_ID is running" + + for (( I=0; I<$TEST_JOBS_FILES_NR; I=I+1 )) + do + # Creat test files + L_FILE=${TEST_JOBS_FILE}${L_JOB_ID}-${I} + L_FILE_CAS="${MOUNTPOINT}-1-1/$(basename $L_FILE)" + + rm -f "$L_FILE_CAS" + rm -f "$L_FILE" + + dd if=/dev/urandom of="$L_FILE" bs=$TEST_JOBS_FILES_SIZE count=1 &>/dev/null + + #copy test file + cp $L_FILE $L_FILE_CAS + if [ $? != 0 ] + then + test_log_trace "Copy ERROR, Job ID is $L_JOB_ID" + L_RESULT="-1" + break + fi + + sync && echo 3 > /proc/sys/vm/drop_caches + + #compare copied files with orginal + cmp $L_FILE $L_FILE_CAS + if [ $? != 0 ] + then + test_log_trace "Data Integrity ERROR, Job ID is $L_JOB_ID" + L_RESULT="-1" + break + fi + + sync && echo 3 > /proc/sys/vm/drop_caches + done + + if [ "0" != "L_RESULT" ] + then + break + fi + + for (( I=0; I<$TEST_JOBS_FILES_NR; I=I+1 )) + do + # Check md5 sums + L_FILE=${TEST_JOBS_FILE}${L_JOB_ID}-${I} + L_FILE_CAS="${MOUNTPOINT}-1-1/$(basename $L_FILE)" + + L_FILE_MD5=$(md5sum -b $L_FILE | awk '{ print $1 }') + L_FILE_CAS_MD5=$(md5sum -b $L_CAS_FILE | awk '{ print $1 }') + + if [ "$L_FILE_MD5" != "$L_FILE_CAS_MD5" ] + then + test_log_trace "MD5 sum ERROR, Job ID is $L_JOB_ID" + L_RESULT="-1" + break + fi + done + + let L_ITER=${L_ITER}-1 + if [ 0 -eq $L_ITER ] + then + break; + fi + + if [ "0" != "L_RESULT" ] + then + break + fi + done + + # + # Clean after tests + # + for (( I=0; I<$TEST_JOBS_FILES_NR; I=I+1 )) + do + # Remove test file + L_FILE=${TEST_JOBS_FILE}${L_JOB_ID}-${I} + rm -f $L_FILE + done + + echo $L_RESULT > $L_FILE_RESULT +} + +#param1 - Flushing {YES - Perform Flushing during suspending cache, NO} +cache_suspend() { + local L_CACHE_MODES=("wt" "wb" "wa" "pt" "wa" "wo") + local L_CACHE_MODE + local L_CACHE_MODE_NR + + while [ true ] + do + sleep 1 + + L_CACHE_MODE_NR=${RANDOM} + let L_CACHE_MODE_NR=$L_CACHE_MODE_NR%${#L_CACHE_MODES[@]} + + L_CACHE_MODE=${L_CACHE_MODES[$L_CACHE_MODE_NR]} + + test_log_trace "Switching to $L_CACHE_MODE mode" + DONT_FAIL_ON_ERROR_OPTION="YES" + CACHE_ID_OPTION="1" CACHE_MODE_OPTION="$L_CACHE_MODE" set_cache_mode + done +} + +cache_suspend_start_jobs () { + local L_JOB_ID=$1 + + for (( ID=0; ID<$TEST_JOBS_NR; ID=ID+1 )) + do + cache_suspend_job "${ID}" & + TEST_JOBS[$ID]=$! + done + + cache_suspend & + TEST_JOB_SUSPEND_PID=$! + + return 0 +} + +cache_suspend_wait() { + for (( ID=0; ID<$TEST_JOBS_NR; ID=ID+1 )) + do + wait ${TEST_JOBS[$ID]} + done + kill $TEST_JOB_SUSPEND_PID +} + +cache_suspend_result() { + local L_RESULT + local L_FILE_RESULT="" + + for (( ID=0; ID<$TEST_JOBS_NR; ID=ID+1 )) + do + L_FILE_RESULT="${TEST_JOBS_RESULT}-${ID}" + L_RESULT=$(cat $L_FILE_RESULT) + + if [ "0" != $L_RESULT ] + then + test_log_trace "Test job FAILURE, ID is $ID" + return 1 + fi + done + + return 0 +} + +#param1 - Metadata Varaint +#param2 - File system type +cache_suspend_i() { + local L_RESULT=0 + + cache_suspend_start_jobs + + cache_suspend_wait + + cache_suspend_result + if [ $? != 0 ] + then + result=-1 + test_log_trace "FAILURE" + fi + + if [ 0 -eq $L_RESULT ] + then + return 0 + else + return 1 + fi +} + +test_log_start + +test_log_trace "Cache size is ${TEST_CACHE_DEVICE_SIZE}, Core size is ${TEST_CORE_DEVICE_SIZE}" + +CACHE_LINE_SIZE="all" +NUMBER_OF_CORE_PARTITIONS="1" +NUMBER_OF_CACHE_PARTITIONS="1" +MAKE_FILE_SYSTEM="all" +iteration cache_suspend_i + + +test_log_stop + +# 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/cache_suspend/02 b/test/smoke_test/cache_suspend/02 new file mode 100755 index 0000000..f53805e --- /dev/null +++ b/test/smoke_test/cache_suspend/02 @@ -0,0 +1,204 @@ +#!/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 Verify cache and core read and write stats in WT in PT mode + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# 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_DEVICE_SIZE=1G +CORE_DEVICE_SIZE=10G +TEST_DEVICE=${DEVICE_NAME}1-1 + +#param device +get_stat_sectors_read() { + L_DEVICE=$(basename $1) + L_STAT=$(cat /proc/diskstats | grep $L_DEVICE | awk '{ print $6 }') + echo $L_STAT +} + +#param device +get_stat_sectors_written() { + L_DEVICE=$(basename $1) + L_STAT=$(cat /proc/diskstats | grep $L_DEVICE | awk '{ print $10 }') + echo $L_STAT +} + +cache_suspend_init() { + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + run_cmd dd if=/dev/zero of="${CORE_DEVICE}1" bs=1M count=1 oflag=direct + + # Start cache on CACHE_DEVICE1 + CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +cache_suspend_deinit() { + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache +} + +cache_suspend_test() { + L_CACHE_READS_BEFORE= + L_CACHE_READS_AFTER= + L_CACHE_WRITES_BEFORE= + L_CACHE_WRITES_AFTER= + L_CORE_READS_BEFORE= + L_CORE_READS_AFTER= + + # Write + test_log_trace "Write 4k to be cached" + dd if=/dev/urandom of=${TEST_DEVICE} bs=4k count=1 oflag=direct + + # Suspend the cache, flush dirty data. + test_log_trace "Suspend Cache" + CACHE_MODE_FLUSH_OPTION="yes" CACHE_ID_OPTION="1" CACHE_MODE_OPTION="pt" set_cache_mode + + # Get read cache statistics before. + L_CACHE_READS_BEFORE=$(get_stat_sectors_read ${CACHE_DEVICE}1) + + # Read file + test_log_trace "Read 4k, Read has to be performed from core" + dd if=${TEST_DEVICE} of=/dev/null bs=4k count=1 iflag=direct + + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + L_CACHE_READS_AFTER=$(get_stat_sectors_read ${CACHE_DEVICE}1) + + test_log_trace "Cache reads before : $L_CACHE_READS_BEFORE" + test_log_trace "Cache reads after : $L_CACHE_READS_AFTER" + if [ ${L_CACHE_READS_AFTER} != ${L_CACHE_READS_BEFORE} ] + then + test_log_trace "Unexpected reads from cache" + return 1 + fi + + test_log_trace "Write 4k shall invalidet cached data, write on core only" + # Write (Invalidate cached data) + dd if=/dev/urandom of=${TEST_DEVICE} bs=4k count=1 oflag=direct + + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + # Get statistics + L_CACHE_WRITES_BEFORE=$(get_stat_sectors_written ${CACHE_DEVICE}1) + L_CORE_READS_BEFORE=$(get_stat_sectors_read ${CORE_DEVICE}1) + L_CACHE_READS_BEFORE=$(get_stat_sectors_read ${CACHE_DEVICE}1) + + # Read file + test_log_trace "Read 4k, read form core only" + dd if=${TEST_DEVICE} of=/tmp/baba bs=4k count=1 iflag=direct + + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + # Get statistics + L_CACHE_WRITES_AFTER=$(get_stat_sectors_written ${CACHE_DEVICE}1) + L_CORE_READS_AFTER=$(get_stat_sectors_read ${CORE_DEVICE}1) + L_CACHE_READS_AFTER=$(get_stat_sectors_read ${CACHE_DEVICE}1) + + test_log_trace "Core reads before : $L_CORE_READS_BEFORE" + test_log_trace "Core reads after : $L_CORE_READS_AFTER" + if [ "$L_CORE_READS_BEFORE" == "$L_CORE_READS_AFTER" ] + then + test_log_trace "Expected reads from core" + return 1 + fi + + test_log_trace "Cache writes before : $L_CACHE_WRITES_BEFORE" + test_log_trace "Cache wrties after : $L_CACHE_WRITES_AFTER" + if [ "$L_CACHE_WRITES_BEFORE" != "$L_CACHE_WRITES_AFTER" ] + then + test_log_trace "Unexpected writes on cache" + return 1 + fi + + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + test_log_trace "Resume cache" + # Resume the cache + CACHE_ID_OPTION="1" CACHE_MODE_OPTION="wt" set_cache_mode + + L_CACHE_WRITES_BEFORE=$(get_stat_sectors_written ${CACHE_DEVICE}1) + L_CORE_READS_BEFORE=$(get_stat_sectors_read ${CORE_DEVICE}1) + + test_log_trace "Read 4k, read form core, write on cache" + # Read file + dd if=${TEST_DEVICE} of=/dev/null bs=4k count=1 iflag=direct + + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + L_CORE_READS_AFTER=$(get_stat_sectors_read ${CORE_DEVICE}1) + L_CACHE_WRITES_AFTER=$(get_stat_sectors_written ${CACHE_DEVICE}1) + + test_log_trace "Core reads before : $L_CORE_READS_BEFORE" + test_log_trace "Core reads after : $L_CORE_READS_AFTER" + test_log_trace "Cache writes before : $L_CACHE_WRITES_BEFORE" + test_log_trace "Cache wrties after : $L_CACHE_WRITES_AFTER" + + if [ "$L_CORE_READS_BEFORE" == "$L_CORE_READS_AFTER" ] + then + test_log_trace "Expected reads from core" + return 1 + fi + + if [ "$L_CACHE_WRITES_BEFORE" == "$L_CACHE_WRITES_AFTER" ] + then + test_log_trace "Expected writes on cache" + return 1 + fi + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd cache_suspend_init + +run_cmd cache_suspend_test + +run_cmd cache_suspend_deinit + +test_log_stop + +# +# END TEST +# + +# 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/cache_suspend/03 b/test/smoke_test/cache_suspend/03 new file mode 100755 index 0000000..526a46e --- /dev/null +++ b/test/smoke_test/cache_suspend/03 @@ -0,0 +1,169 @@ +#!/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 Verify cache and core read and write stats in WT in PT mode + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=1G +CORE_DEVICE_SIZE=10G +TEST_DEVICE=${DEVICE_NAME}1-1 +TEST_BS=4k +TEST_COUNT=32768 +TEST_COUNT_HALF=16384 + +#param device +get_stat_sectors_read() { + L_DEVICE=$(basename $1) + L_STAT=$(cat /proc/diskstats | grep $L_DEVICE | awk '{ print $6 }') + echo $L_STAT +} + +#param device +get_stat_sectors_written() { + L_DEVICE=$(basename $1) + L_STAT=$(cat /proc/diskstats | grep $L_DEVICE | awk '{ print $10 }') + echo $L_STAT +} + +cache_suspend_init() { + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + run_cmd dd if=/dev/zero of="${CORE_DEVICE}1" bs=1M count=1 oflag=direct + + # Start cache on CACHE_DEVICE1 + CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +cache_suspend_deinit() { + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache +} + +cache_suspend_test() { + local L_CACHE_READS_BEFORE= + local L_CACHE_READS_AFTER= + local L_CACHE_WRITES_BEFORE= + local L_CACHE_WRITES_AFTER= + local L_CORE_READS_BEFORE= + local L_CORE_READS_AFTER= + local L_CACHE_READS= + local L_CORE_READS= + local L_SIZE_WRITTEN= + local L_SIZE_READ= + + test_log_trace "Block size is ${TEST_BS}" + test_log_trace "Count is ${TEST_COUNT}" + + # Write + test_log_trace "Write into CAS ${TEST_COUNT}" + dd if=/dev/urandom of=${TEST_DEVICE} bs=${TEST_BS} count=${TEST_COUNT} oflag=direct + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + # Suspend the cache + test_log_trace "Suspend Cache" + CACHE_ID_OPTION="1" CACHE_MODE_OPTION="pt" set_cache_mode + + # Write + test_log_trace "Overwrite half ${TEST_COUNT_HALF}" + dd if=/dev/urandom of=${TEST_DEVICE} bs=${TEST_BS} count=${TEST_COUNT_HALF} oflag=direct + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + # Resume the cache + test_log_trace "Resume Cache" + CACHE_ID_OPTION="1" CACHE_MODE_OPTION="wt" set_cache_mode + + # Get statistics before + L_CACHE_READS_BEFORE=$(get_stat_sectors_read ${CACHE_DEVICE}1) + L_CORE_READS_BEFORE=$(get_stat_sectors_read ${CORE_DEVICE}1) + + # Read from + test_log_trace "Read from CAS" + dd if=${TEST_DEVICE} of=/dev/null bs=${TEST_BS} count=${TEST_COUNT} iflag=direct + # Sync + sync && echo 3 > /proc/sys/vm/drop_caches + + # Get statistics after + L_CACHE_READS_AFTER=$(get_stat_sectors_read ${CACHE_DEVICE}1) + L_CORE_READS_AFTER=$(get_stat_sectors_read ${CORE_DEVICE}1) + + test_log_trace "Cache reads before : $L_CACHE_READS_BEFORE" + test_log_trace "Cache reads after : $L_CACHE_READS_AFTER" + + test_log_trace "Core reads before : $L_CORE_READS_BEFORE" + test_log_trace "Core reads after : $L_CORE_READS_AFTER" + + let L_CACHE_READS=${L_CACHE_READS_AFTER}-${L_CACHE_READS_BEFORE} + test_log_trace "Cache reads : ${L_CACHE_READS}" + + let L_CORE_READS=${L_CORE_READS_AFTER}-${L_CORE_READS_BEFORE} + test_log_trace "Core reads : ${L_CORE_READS}" + + let L_SIZE_WRITTEN=$(get_bytes $TEST_BS)*$(get_bytes $TEST_COUNT) + test_log_trace "Size written : $L_SIZE_WRITTEN" + + let L_SIZE_READ=${L_CORE_READS}+${L_CACHE_READS} + let L_SIZE_READ=${L_SIZE_READ}*512 + test_log_trace "Size read : $L_SIZE_READ" + + if [ "$L_SIZE_READ" != "$L_SIZE_WRITTEN" ] + then + test_log_trace "Mismatch between written size and read size" + return 1 + fi + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd cache_suspend_init + +run_cmd cache_suspend_test + +run_cmd cache_suspend_deinit + +test_log_stop + +# +# END TEST +# + +# 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/eviction_policy/01 b/test/smoke_test/eviction_policy/01 new file mode 100755 index 0000000..efefad8 --- /dev/null +++ b/test/smoke_test/eviction_policy/01 @@ -0,0 +1,95 @@ +#!/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 Eviction Policy - Type Selection + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=300M +CORE_DEVICE_SIZE=600M +TEST_DEVICE=${DEVICE_NAME}1-1 + +#param1 - YES - WB mode, NO - WT mode +eviction_policy_init() { + local L_WB=$1 + + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Set WB mode + if [ "YES" == "$L_WB" ] + then + CACHE_MODE_OPTION="wb" + test_log_trace "Cache mode is WB" + else + CACHE_MODE_OPTION="wt" + test_log_trace "Cache mode is WT" + fi + + # Start cache on CACHE_DEVICE1 + CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +eviction_policy_flush() { + CACHE_ID_OPTION="1" flush_cache +} + +eviction_policy_deinit() { + sleep 1 + + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache +} + +# +# START TEST +# + +test_log_start + +run_cmd eviction_policy_init + +run_cmd eviction_policy_deinit + +run_cmd eviction_policy_init YES + +run_cmd eviction_policy_deinit + +test_log_stop + +# +# END TEST +# + +# 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/eviction_policy/02 b/test/smoke_test/eviction_policy/02 new file mode 100755 index 0000000..ba61a87 --- /dev/null +++ b/test/smoke_test/eviction_policy/02 @@ -0,0 +1,337 @@ +#!/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 Eviction Policy - LRU, WT + +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=350M +CORE_DEVICE_SIZE=350M +TEST_DEVICE=${DEVICE_NAME}1-1 +MD5_SUM= +BLOCK_SIZE="128k" + +#param1 - YES - WB mode, NO - WT mode +eviction_policy_init() { + local L_WB=$1 + + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + # Make empty cache device, clear previous content, clear previous metadata + dd if=/dev/zero of="${CACHE_DEVICE}1" bs="4k" count=$CACHE_DEVICE_SIZE &>/dev/null + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Set WB mode + if [ "YES" == "$L_WB" ] + then + CACHE_MODE_OPTION="wb" + test_log_trace "Cache mode is WB" + else + CACHE_MODE_OPTION="wt" + test_log_trace "Cache mode is WT" + fi + + # Start cache on CACHE_DEVICE1 + CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +eviction_policy_flush() { + CACHE_ID_OPTION="1" flush_cache +} + +eviction_policy_deinit() { + sleep 1 + + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache + + test_log_stop +} + +# Get IO state in bytes +#param1 - Device to be stated +eviction_policy_iostat () { + local SIZE_DEVICE + local SIZE_WR + local SIZE_RD + local SIZE + + if [[ $1 =~ ^/dev/(.*)$ ]] ; then + SIZE_DEVICE=${BASH_REMATCH[1]} + else + test_log_trace "Internal test ERROR ($LINENO)" + return 1 + fi + + sync + + SIZE_WR=$(iostat -p | grep $SIZE_DEVICE | awk '{ print $6}') + let SIZE_WR=$SIZE_WR*512 + + SIZE_RD=$(iostat -p | grep $SIZE_DEVICE | awk '{ print $5}') + let SIZE_RD=$SIZE_RD*512 + + let SIZE=$SIZE_RD+$SIZE_WR + + echo $SIZE +} + +# param1 - Device +# param2 - Seek in bytes +# param3 - Size in bytes +eviction_policy_write () { + local PATTERN=/tmp/cas.pattern + + local L_DEVICE=$1 + + local SEEK=$(get_bytes $2) + SEEK=$(get_pages $SEEK "${BLOCK_SIZE}") + + local SIZE=$(get_bytes $3) + SIZE=$(get_pages $SIZE "${BLOCK_SIZE}") + + test_log_trace "Write to the device $L_DEVICE, size is $SIZE, seek is $SEEK" + + rm -f $PATTERN + + # + # Create pattern file + # + dd if=/dev/urandom of=$PATTERN bs="${BLOCK_SIZE}" count=$SIZE &>/dev/null + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Can not create pattern file" + return 1 + fi + # + # Calculte MD5 sum of pattern file + # + MD5_SUM=$(md5sum -b $PATTERN | awk '{ print $1 }') + test_log_trace "MD5 sum of is $MD5_SUM" + + T_START=$(date '+%s') + # + # Copy pattern file into test device + # + warmup ${PATTERN} ${L_DEVICE} ${BLOCK_SIZE} $SIZE $SEEK 0 + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Write ERROR, at offset $OFFSET, size is $BLOCK_SIZE, device size is $DEVICE_SIZE" + return 1 + fi + + T_STOP=$(date '+%s') + let T_DURATION=$T_STOP-$T_START + test_log_trace "Write duration is $T_DURATION" + + echo $MD5_SUM + + return 0 +} + +# param1 - Device +# param2 - Skip in bytes +# param3 - Size in bytes +eviction_policy_read () { + local PATTERN=/tmp/cas.pattern + + local DEVICE=$1 + + local SKIP=$(get_bytes $2) + SKIP=$(get_pages $SKIP "${BLOCK_SIZE}") + + local SIZE=$(get_bytes $3) + SIZE=$(get_pages $SIZE "${BLOCK_SIZE}") + + test_log_trace "Read from the device $DEVICE, size is $SIZE, skip is $SKIP" + + rm -f $PATTERN + + T_START=$(date '+%s') + # + # Read data from test device to the pattern file + # + warmup $DEVICE $PATTERN $BLOCK_SIZE $SIZE 0 $SKIP + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Can not read from test device" + return 1 + fi + + T_STOP=$(date '+%s') + let T_DURATION=$T_STOP-$T_START + test_log_trace "Read duration is $T_DURATION" + + # + # Calculte MD5 sum of pattern file + # + MD5_SUM=$(md5sum -b $PATTERN | awk '{ print $1 }') + test_log_trace "MD5 sum of is $MD5_SUM" + + echo $MD5_SUM + + return 0 +} + +# +# MAIN TEST +# +# param1 - Device for test +# param2 - Core device +# param3 - Device size [bytes] +eviction_policy_test () { + local DEVICE=$1 + local CORE=$2 + local SIZE=$3 + local SIZE_BEFORE + local SIZE_AFTER + local SIZE_HALF + local MD5_SUM_WR_1 + local MD5_SUM_WR_2 + + let SIZE_HALF=$SIZE/2 + + # + # Get IO State Before + # + SIZE_BEFORE=$(eviction_policy_iostat $CORE) + + # + # Write first half of device + # + MD5_SUM_WR_1=$(eviction_policy_write $DEVICE "0" $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Write second half of device + # + MD5_SUM_WR_2=$(eviction_policy_write $DEVICE $SIZE_HALF $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Get IO State Before + # + SIZE_BEFORE=$(eviction_policy_iostat $CORE) + + # + # Read second half of device + # + MD5_SUM_RD_2=$(eviction_policy_read $DEVICE $SIZE_HALF $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Get IO State Before + # + SIZE_AFTER=$(eviction_policy_iostat $CORE) + + # + # Read first half of device + # + MD5_SUM_RD_1=$(eviction_policy_read $DEVICE 0 $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + test_log_trace "First Half WR MD5 sum is $MD5_SUM_WR_1" + test_log_trace "First Half RD MD5 sum is $MD5_SUM_RD_1" + test_log_trace "Second Half WR MD5 sum is $MD5_SUM_WR_2" + test_log_trace "Second Half RD MD5 sum is $MD5_SUM_RD_2" + test_log_trace "IO stat size of core before read first half is $SIZE_BEFORE" + test_log_trace "IO stat size of core after read first half is $SIZE_AFTER" + + if [ $MD5_SUM_WR_1 != $MD5_SUM_RD_1 ] + then + eviction_policy_deinit + error "First half checksum error" + return 1 + fi + + if [ $MD5_SUM_WR_2 != $MD5_SUM_RD_2 ] + then + eviction_policy_deinit + error "Second half checksum error" + return 1 + fi + + if [ $SIZE_BEFORE != $SIZE_AFTER ] + then + eviction_policy_deinit + error "ERROR, Size before and affter shall be the same" + return 1 + fi + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd eviction_policy_init + +run_cmd eviction_policy_test $TEST_DEVICE "${CORE_DEVICE}1" $(get_bytes $CORE_DEVICE_SIZE) + +run_cmd eviction_policy_deinit + +# +# END TEST +# + +# 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/eviction_policy/03 b/test/smoke_test/eviction_policy/03 new file mode 100755 index 0000000..fbf7025 --- /dev/null +++ b/test/smoke_test/eviction_policy/03 @@ -0,0 +1,330 @@ +#!/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 Eviction Policy - LRU, WB + +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=350M +CORE_DEVICE_SIZE=350M +TEST_DEVICE=${DEVICE_NAME}1-1 +MD5_SUM= +BLOCK_SIZE="128k" + +#param1 - YES - WB mode, NO - WT mode +eviction_policy_init() { + local L_WB=$1 + + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + # Make empty cache device, clear previous content, clear previous metadata + dd if=/dev/zero of="${CACHE_DEVICE}1" bs="4k" count=$CACHE_DEVICE_SIZE &>/dev/null + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Set WB mode + if [ "YES" == "$L_WB" ] + then + CACHE_MODE_OPTION="wb" + test_log_trace "Cache mode is WB" + else + CACHE_MODE_OPTION="wt" + test_log_trace "Cache mode is WT" + fi + + # Start cache on CACHE_DEVICE1 + CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +eviction_policy_flush() { + CACHE_ID_OPTION="1" flush_cache +} + +eviction_policy_deinit() { + sleep 1 + + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache + + test_log_stop +} + +# Get IO state in bytes +#param1 - Device to be stated +eviction_policy_iostat () { + local SIZE_DEVICE + local SIZE_WR + local SIZE_RD + local SIZE + + if [[ $1 =~ ^/dev/(.*)$ ]] ; then + SIZE_DEVICE=${BASH_REMATCH[1]} + else + test_log_trace "Internal test ERROR ($LINENO)" + return 1 + fi + + sync + + SIZE_WR=$(iostat -p | grep $SIZE_DEVICE | awk '{ print $6}') + let SIZE_WR=$SIZE_WR*512 + + SIZE_RD=$(iostat -p | grep $SIZE_DEVICE | awk '{ print $5}') + let SIZE_RD=$SIZE_RD*512 + + let SIZE=$SIZE_RD+$SIZE_WR + + echo $SIZE +} + +# param1 - Device +# param2 - Seek in bytes +# param3 - Size in bytes +eviction_policy_write () { + local PATTERN=/tmp/cas.pattern + + local L_DEVICE=$1 + + local SEEK=$(get_bytes $2) + SEEK=$(get_pages $SEEK "${BLOCK_SIZE}") + + local SIZE=$(get_bytes $3) + SIZE=$(get_pages $SIZE "${BLOCK_SIZE}") + + test_log_trace "Write to the device $L_DEVICE, size is $SIZE, seek is $SEEK" + + rm -f $PATTERN + + # + # Create pattern file + # + dd if=/dev/urandom of=$PATTERN bs="${BLOCK_SIZE}" count=$SIZE &>/dev/null + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Can not create pattern file" + return 1 + fi + # + # Calculte MD5 sum of pattern file + # + MD5_SUM=$(md5sum -b $PATTERN | awk '{ print $1 }') + test_log_trace "MD5 sum $PATTERN of is $MD5_SUM" + + local T_START=$(date '+%s') + # + # Copy pattern file into test device + # + warmup ${PATTERN} ${L_DEVICE} ${BLOCK_SIZE} $SIZE $SEEK 0 + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Write ERROR, at offset $OFFSET, size is $BLOCK_SIZE, device size is $DEVICE_SIZE" + return 1 + fi + + local T_STOP=$(date '+%s') + let T_DURATION=${T_STOP}-${T_START} + test_log_trace "Write duration is $T_DURATION" + + echo $MD5_SUM + + return 0 +} + +# param1 - Device +# param2 - Skip in bytes +# param3 - Size in bytes +eviction_policy_read () { + local PATTERN=/tmp/cas.pattern + + local DEVICE=$1 + + local SKIP=$(get_bytes $2) + SKIP=$(get_pages $SKIP "${BLOCK_SIZE}") + + local SIZE=$(get_bytes $3) + SIZE=$(get_pages $SIZE "${BLOCK_SIZE}") + + test_log_trace "Read from the device $DEVICE, size is $SIZE, skip is $SKIP" + + rm -f $PATTERN + + local T_START=$(date '+%s') + # + # Read data from test device to the pattern file + # + warmup $DEVICE $PATTERN $BLOCK_SIZE $SIZE 0 $SKIP + # + # Check dd result + # + if [ $? != 0 ] + then + test_log_trace "Can not read from test device" + return 1 + fi + + local T_STOP=$(date '+%s') + let T_DURATION=${T_STOP}-${T_START} + test_log_trace "Read duration is $T_DURATION" + + # + # Calculte MD5 sum of pattern file + # + MD5_SUM=$(md5sum -b $PATTERN | awk '{ print $1 }') + test_log_trace "MD5 sum of is $MD5_SUM" + + echo $MD5_SUM + + return 0 +} + +# +# MAIN TEST +# +# param1 - Device for test +# param2 - Core device +# param3 - Device size [bytes] +eviction_policy_test () { + local DEVICE=$1 + local CORE=$2 + local SIZE=$3 + local SIZE_BEFORE + local SIZE_AFTER + local SIZE_HALF + local MD5_SUM_WR_1 + local MD5_SUM_WR_2 + + let SIZE_HALF=$SIZE/2 + + # + # Get IO State Before + # + SIZE_BEFORE=$(eviction_policy_iostat $CORE) + + # + # Write first half of device + # + MD5_SUM_WR_1=$(eviction_policy_write $DEVICE "0" $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Write second half of device + # + MD5_SUM_WR_2=$(eviction_policy_write $DEVICE $SIZE_HALF $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Get IO State Before + # + SIZE_BEFORE=$(eviction_policy_iostat $CORE) + + # + # Read second half of device + # + MD5_SUM_RD_2=$(eviction_policy_read $DEVICE $SIZE_HALF $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + # + # Get IO State Before + # + SIZE_AFTER=$(eviction_policy_iostat $CORE) + + # + # Read first half of device + # + MD5_SUM_RD_1=$(eviction_policy_read $DEVICE 0 $SIZE_HALF) + if [ $? != 0 ] + then + test_log_trace "Can not write first half of test device" + eviction_policy_deinit + return 1 + fi + + test_log_trace "First Half WR MD5 sum is $MD5_SUM_WR_1" + test_log_trace "First Half RD MD5 sum is $MD5_SUM_RD_1" + test_log_trace "Second Half WR MD5 sum is $MD5_SUM_WR_2" + test_log_trace "Second Half RD MD5 sum is $MD5_SUM_RD_2" + test_log_trace "IO stat size of core before read first half is $SIZE_BEFORE" + test_log_trace "IO stat size of core after read first half is $SIZE_AFTER" + + if [ $MD5_SUM_WR_1 != $MD5_SUM_RD_1 ] + then + eviction_policy_deinit + error "First half checksum error" + return 1 + fi + + if [ $MD5_SUM_WR_2 != $MD5_SUM_RD_2 ] + then + eviction_policy_deinit + error "Second half checksum error" + return 1 + fi + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd eviction_policy_init "YES" + +run_cmd eviction_policy_test $TEST_DEVICE "${CORE_DEVICE}1" $(get_bytes $CORE_DEVICE_SIZE) + +run_cmd eviction_policy_deinit + +# +# END TEST +# + +# 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/incremental_load/01 b/test/smoke_test/incremental_load/01 new file mode 100755 index 0000000..15a542f --- /dev/null +++ b/test/smoke_test/incremental_load/01 @@ -0,0 +1,74 @@ +#!/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 Try add 3 cores to pool, try load cache and check if cache is running + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" +# USE_IN_BVT +# USE_IN_NIGHTLY + +# 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 $* + +# 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 primary partition 2000M size on CACHE_DEVICE +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1" make_primary_partitions +# Create primary partition 4000M size on CORE_DEVICE +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +# Prepare cache on CACHE_DEVICE1 (/dev/sdd1, e.g.) and add core device using CORE_DEVICE1, CORE_DEVICE2 and CORE_DEVICE3 (/dev/sde1, /dev/sde2, /dev/sde3, e.g) +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}2" add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}3" add_core + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state + +# Stop prepared setup +CACHE_ID_OPTION="1" stop_cache + +# Add cores to pool, then load cache and check if cache is running +# Try to add core devices and check their states +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" CORE_ID_OPTION="1" try_add_core +DEVICE_ID_OPTION=${CORE_DEVICE}1 DEMANDED_STATE_OPTION="Detached" check_device_state + +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}2" CORE_ID_OPTION="2" try_add_core +DEVICE_ID_OPTION=${CORE_DEVICE}2 DEMANDED_STATE_OPTION="Detached" check_device_state + +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}3" CORE_ID_OPTION="3" try_add_core +DEVICE_ID_OPTION=${CORE_DEVICE}3 DEMANDED_STATE_OPTION="Detached" check_device_state + + +# Try to load cache device, check if it is running and if all cores status is appropirate +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_LOAD_METADATA_OPTION="y" start_cache +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state + + +# Stop prepared setup +CACHE_ID_OPTION="1" stop_cache + +# 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/incremental_load/02 b/test/smoke_test/incremental_load/02 new file mode 100755 index 0000000..c9b1009 --- /dev/null +++ b/test/smoke_test/incremental_load/02 @@ -0,0 +1,82 @@ +#!/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 Start cache device, add sequentially core devices and check if cache is running + +# The line below says that this test should be included in NIGHTLY - it will be launched, when we use "./run_tests -n" +# USE_IN_BVT +# USE_IN_NIGHTLY + +# 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 $* + +# 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 primary partition 2000M size on CACHE_DEVICE +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1" make_primary_partitions +# Create primary partition 4000M size on CORE_DEVICE +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +# Prepare cache on CACHE_DEVICE1 (/dev/sdd1, e.g.) and add core device using CORE_DEVICE1, CORE_DEVICE2 and CORE_DEVICE3 (/dev/sde1, /dev/sde2, /dev/sde3, e.g) +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}2" add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}3" add_core + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state + +# Stop prepared setup +CACHE_ID_OPTION="1" stop_cache +# Hide part of core devices to protect them before be automatically loading +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2" make_primary_partitions +sleep 1 +# Load cache, then add cores and check if chache is running +# Try to load cache device, check its state and cores state +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_LOAD_METADATA_OPTION="y" start_cache +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Incomplete" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Inactive" check_device_state + +# Prepare partition for core device to be added +CACHE_ID_OPTION="1" CACHE_DONT_FLUSH_DATA_OPTION="1" stop_cache +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions +sleep 1 +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" CORE_ID_OPTION="1" try_add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}2" CORE_ID_OPTION="2" try_add_core +CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}3" CORE_ID_OPTION="3" try_add_core +DEVICE_ID_OPTION="${CORE_DEVICE}1" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}2" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}3" DEMANDED_STATE_OPTION="Detached" check_device_state + +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" CACHE_LOAD_METADATA_OPTION="y" start_cache + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state +# Clean up after test +CACHE_ID_OPTION="1" stop_cache + +# 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/init_script/01 b/test/smoke_test/init_script/01 new file mode 100755 index 0000000..0676d51 --- /dev/null +++ b/test/smoke_test/init_script/01 @@ -0,0 +1,67 @@ +#!/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 Test basic casctl script functionality + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# 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 $* + +# This is where the real test starts + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1" make_primary_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +cat > $CAS_CONFIG_PATH <<- EOM +${CAS_CONFIG_VERSION_TAG} +[caches] +1 ${CACHE_DEVICE}1 WT +[cores] +1 1 ${CORE_DEVICE}1 +1 2 ${CORE_DEVICE}2 +1 3 ${CORE_DEVICE}3 +EOM + +run_cmd "casctl init" + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state + +run_cmd "casctl stop" + +check_no_cache_running + +run_cmd "casctl start" + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-1" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-2" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}1-3" DEMANDED_STATE_OPTION="Active" check_device_state + +run_cmd "casctl stop" + +check_no_cache_running + +# 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/init_script/02 b/test/smoke_test/init_script/02 new file mode 100755 index 0000000..c5b727d --- /dev/null +++ b/test/smoke_test/init_script/02 @@ -0,0 +1,73 @@ +#!/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 Test some corner cases for casctl script + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# USE_IN_NIGHTLY + +# 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 $* + +# This is where the real test starts + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1" make_primary_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2" make_primary_partitions + +clear_config + +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +cat > $CAS_CONFIG_PATH <<- EOM +${CAS_CONFIG_VERSION_TAG} +[caches] +16384 ${CACHE_DEVICE}1 WB cleaning_policy=acp +[cores] +16384 4095 ${CORE_DEVICE}1 +16384 4094 ${CORE_DEVICE}2 +16384 0 ${CORE_DEVICE}3 +EOM + +run_cmd "casctl init" + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-0" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-4095" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-4094" DEMANDED_STATE_OPTION="Active" check_device_state + +run_cmd "casadm -G -n cleaning -i 16384 | grep "acp" &>/dev/null" + +run_cmd "casctl stop" + +check_no_cache_running + +run_cmd "casctl start" + +DEVICE_ID_OPTION=${CACHE_DEVICE}1 DEMANDED_STATE_OPTION="Running" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-0" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-4095" DEMANDED_STATE_OPTION="Active" check_device_state +DEVICE_ID_OPTION="${DEVICE_NAME}16384-4094" DEMANDED_STATE_OPTION="Active" check_device_state + +run_cmd "casctl stop" + +check_no_cache_running + +# 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/init_script/03 b/test/smoke_test/init_script/03 new file mode 100755 index 0000000..9950fd9 --- /dev/null +++ b/test/smoke_test/init_script/03 @@ -0,0 +1,78 @@ +#!/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 Check if casctl stop/start handles flushing/loading properly + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# USE_IN_NIGHTLY + +# 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 $* + +# This is where the real test starts + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" remove_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions + +TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1" make_primary_partitions +TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions + +cat > $CAS_CONFIG_PATH <<- EOM +${CAS_CONFIG_VERSION_TAG} +[caches] +1 ${CACHE_DEVICE}1 WB cleaning_policy=nop +[cores] +1 1 ${CORE_DEVICE}1 +1 2 ${CORE_DEVICE}2 +1 3 ${CORE_DEVICE}3 +EOM + +run_cmd "casctl init" + +run_cmd "dd if=/dev/urandom of=${DEVICE_NAME}1-2 count=1000 bs=4096 oflag=direct" + +run_cmd "casctl stop" + +# We shouldn't be able to start cache on this device, it contains dirty data +NEGATIVE_TEST_OPTION=1 CACHE_DEVICE_OPTION=${CACHE_DEVICE}1 CACHE_ID_OPTION=1 start_cache + +NEGATIVE_TEST_OPTION=1 run_cmd "casctl init" +clear_options + +run_cmd "casctl start" + +run_cmd "casctl stop" + +# We still shouldn't be able to start +NEGATIVE_TEST_OPTION=1 CACHE_DEVICE_OPTION=${CACHE_DEVICE}1 CACHE_ID_OPTION=1 start_cache + +NEGATIVE_TEST_OPTION=1 run_cmd "casctl init" +clear_options + +run_cmd "casctl init --force" + +run_cmd "dd if=/dev/urandom of=${DEVICE_NAME}1-2 count=1000 bs=4096 oflag=direct" + +run_cmd "casctl stop --flush" + +run_cmd "casadm -S -d ${CACHE_DEVICE}1" + +run_cmd "casctl stop" + +check_no_cache_running + +# 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/recovery/01 b/test/smoke_test/recovery/01 new file mode 100755 index 0000000..bdc120d --- /dev/null +++ b/test/smoke_test/recovery/01 @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Copyright(c) 2012-2019 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +# DESCRIPTION Data integrity after turning off cache device + +# 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 +# USE_IN_BVT +# USE_IN_NIGHTLY + +TESTS_DIR="$(dirname $0)/../" +. $TESTS_DIR/cas_lib +start_test $* + +# 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_MODE_OPTION="wb" 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_MODE_OPTION="wb" 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_MODE_OPTION="wb" 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" +done + +CACHE_DEVICE_OPTION="${CACHE_DEVICE}" turn_off_device +for ID in 1 2 3 ; do + DONT_FAIL_ON_ERROR_OPTION="YES" CACHE_ID_OPTION="$ID" stop_cache +done +CACHE_DEVICE_OPTION="${CACHE_DEVICE}" turn_on_device + +for ID in 1 2 3 ; do + CACHE_ID_OPTION="$ID" CACHE_DEVICE_OPTION="${CACHE_DEVICE}$ID" CACHE_LOAD_METADATA_OPTION="y" CACHE_MODE_OPTION="wb" start_cache + CACHE_ID_OPTION="$ID" stop_cache + 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 +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE:4}" dirty_stop diff --git a/test/smoke_test/recovery/02 b/test/smoke_test/recovery/02 new file mode 100755 index 0000000..23891f2 --- /dev/null +++ b/test/smoke_test/recovery/02 @@ -0,0 +1,95 @@ +#!/bin/bash +# +# Copyright(c) 2012-2019 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +# DESCRIPTION Recovery test + +# 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 +# USE_IN_BVT +# USE_IN_NIGHTLY + +TESTS_DIR="$(dirname $0)/../" +. $TESTS_DIR/cas_lib +start_test $* + +# 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_MODE_OPTION="wb" 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_MODE_OPTION="wb" 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_MODE_OPTION="wb" 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" +done + +CACHE_DEVICE_OPTION="${CACHE_DEVICE}" turn_off_device +for ID in 1 2 3 ; do + DONT_FAIL_ON_ERROR_OPTION="YES" CACHE_ID_OPTION="$ID" stop_cache +done +CACHE_DEVICE_OPTION="${CACHE_DEVICE}" turn_on_device + +for ID in 1 2 3 ; do + CACHE_ID_OPTION="$ID" CACHE_DEVICE_OPTION="${CACHE_DEVICE}$ID" CACHE_LOAD_METADATA_OPTION="y" CACHE_MODE_OPTION="wb" start_cache + CACHE_ID_OPTION="$ID" CORE_ID_OPTION="1" mount_cache +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 + +for ID in 1 2 3 ; do + CACHE_ID_OPTION="$ID" stop_cache +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 +CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE:4}" dirty_stop diff --git a/test/smoke_test/write_back/01 b/test/smoke_test/write_back/01 new file mode 100755 index 0000000..e388b43 --- /dev/null +++ b/test/smoke_test/write_back/01 @@ -0,0 +1,133 @@ +#!/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 Copy file greater then cache + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=500M +CORE_DEVICE_SIZE=20G +TEST_DEVICE=${DEVICE_NAME}1-1 +TEST_FILE=/tmp/cas.testfile + +wb_init() { + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Make ext3 file system + TARGET_DEVICE_OPTION="${CORE_DEVICE}1" FILESYSTEM_TYPE="ext3" make_filesystem + + # Start cache on CACHE_DEVICE1 + CACHE_MODE_OPTION="wb" CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core + + #Mount file system + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" mount_cache +} + +wb_deinit() { + run_cmd "umount ${MOUNTPOINT}-1-1" + + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache +} + +wb_test() { + local L_TEST_FILE_CACHE + local L_MD5_1 + local L_MD5_2 + + test_log_trace "Prepare test file =${TEST_FILE}" + dd if=/dev/urandom of=${TEST_FILE} bs=10M count=$(get_pages 3G 10M) + + L_MD5_1=$(md5sum -b $TEST_FILE | awk '{ print $1 }') + test_log_trace "MD5 check sum of ${TEST_FILE} : $L_MD5_1" + + # Copy test file into core file system + cp ${TEST_FILE} ${MOUNTPOINT}-1-1 + if [ $? != 0 ] + then + test_log_trace "Cannot copy file into core filesystem" + return 1 + fi + test_log_trace "Copy ${TEST_FILE} to ${MOUNTPOINT}-1-1" + + # Perform sync + test_log_trace "Sync" + sync && echo 1 > /proc/sys/vm/drop_caches + + # Get check sum of copied file + L_TEST_FILE_CACHE=$(basename $TEST_FILE) + L_MD5_2=$(md5sum -b "${MOUNTPOINT}-1-1/${L_TEST_FILE_CACHE}" | awk '{ print $1 }') + if [ $? != 0 ] + then + test_log_trace "Cannot calculate checksum of file on core filesystem" + return 1 + fi + test_log_trace "MD5 check sum of ${MOUNTPOINT}-1-1/${L_TEST_FILE_CACHE} : $L_MD5_2" + + if [ "$L_MD5_1" != "$L_MD5_2" ] + then + test_log_trace "MD5 sum ERROR" + return 1 + fi + + # Perform sync + test_log_trace "Sync" + sync && echo 1 > /proc/sys/vm/drop_caches + + # remove test file + rm -f $TEST_FILE + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd wb_init + +run_cmd wb_test + +run_cmd wb_deinit + +test_log_stop + +# +# END TEST +# + +# 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/write_back/02 b/test/smoke_test/write_back/02 new file mode 100755 index 0000000..654b894 --- /dev/null +++ b/test/smoke_test/write_back/02 @@ -0,0 +1,114 @@ +#!/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 Write Back - Sequential cache read vs. Sequential cache HDD + +# The line below says that this test should be included in BVT - it will be launched, when we use "./run_tests -b" + +# USE_IN_NIGHTLY + +# 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_DEVICE_SIZE=1G +CORE_DEVICE_SIZE=2G +TEST_DEVICE=${DEVICE_NAME}1-1 +TEST_FILE=/tmp/cas.testfile +TEST_BS=32k +TEST_COUNT=16 + +wb_init() { + # 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 1 primary partitions on CACHE_DEVICE + TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION=$CACHE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Create 1 primary partitions on CORE_DEVICE + TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION=$CORE_DEVICE_SIZE PARTITION_IDS_OPTION="1" make_primary_partitions + + # Make ext3 file system + TARGET_DEVICE_OPTION="${CORE_DEVICE}1" FILESYSTEM_TYPE="ext3" make_filesystem + + # Start cache on CACHE_DEVICE1 + CACHE_MODE_OPTION="wb" CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}1" start_cache + + # Add a core device using CORE_DEVICE1 + CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}1" add_core +} + +wb_deinit() { + # Remove the core device from cache + CACHE_ID_OPTION="1" CORE_ID_OPTION="1" remove_core + + # Clean up after the test + CACHE_ID_OPTION="1" stop_cache +} + +wb_test() { + wb_init + + local L_MD5_1 + local L_MD5_2 + + test_log_trace "Fill cache, ${TEST_DEVICE}" + dd if=/dev/urandom of=${TEST_DEVICE} bs=${TEST_BS} count=${TEST_COUNT} oflag=direct + + test_log_trace "Calculate MD5SUM of ${TEST_DEVICE}" + local T_START=$(date '+%s') + L_MD5_1=$(md5sum -b ${TEST_DEVICE} | awk '{ print $1 }') + test_log_trace "MD5 check sum of ${TEST_DEVICE} : $L_MD5_1" + local T_STOP=$(date '+%s') + let T_DURATION=${T_STOP}-${T_START} + test_log_trace "Calculation duration of ${TEST_DEVICE} is $T_DURATION" + + wb_deinit + + # Calculate md5sum of HDD + test_log_trace "Calculate MD5SUM of ${CORE_DEVICE}1" + local T_START=$(date '+%s') + L_MD5_2=$(md5sum -b ${CORE_DEVICE}1 | awk '{ print $1 }') + test_log_trace "MD5 check sum of ${CORE_DEVICE}1 : $L_MD5_2" + local T_STOP=$(date '+%s') + let T_DURATION=${T_STOP}-${T_START} + test_log_trace "Calculation duration of ${CORE_DEVICE}1 is $T_DURATION" + + if [ "$L_MD5_1" != "$L_MD5_2" ] + then + test_log_trace "MD5 sum ERROR" + test_log_stop + return 1 + fi + + return 0 +} + +# +# START TEST +# + +test_log_start + +run_cmd wb_test + +test_log_stop + +# +# END TEST +# + +# 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