diff --git a/test/smoke_test/cas_functions b/test/smoke_test/cas_functions index 3b497e1..d4f71b5 100644 --- a/test/smoke_test/cas_functions +++ b/test/smoke_test/cas_functions @@ -126,10 +126,56 @@ remove_core() { clear_options } -check_device_state() { + +check_cache_state() { check_options ${FUNCNAME[0]} - local COMMAND="$CAS --list-caches -o csv | grep `readlink -m $DEVICE_ID_OPTION` | cut -d',' -f4 | grep $DEMANDED_STATE_OPTION &> /dev/null" + get_cache_device_entry() { + $CAS --list-caches -o csv | \ + awk -F, -v cache=$CACHE_ID_OPTION '{ + if ($1 == "cache" && $2 == cache) print $0; + }' + } + + local COMMAND="get_cache_device_entry | grep $DEMANDED_STATE_OPTION &> /dev/null" + + run_cmd $COMMAND + + clear_options +} + +check_core_state() { + check_options ${FUNCNAME[0]} + + get_core_device_entry() { + $CAS --list-caches -o csv | \ + awk -F, -v cache=$CACHE_ID_OPTION -v core=$CORE_ID_OPTION '{ + if ($1 == "cache") curr_cache = $2; + if ($1 == "core") curr_core = $2; + if (curr_cache == cache && curr_core == core) print $0; + }' + } + + local COMMAND="get_core_device_entry | grep $DEMANDED_STATE_OPTION &> /dev/null" + + run_cmd $COMMAND + + clear_options +} + +check_device_in_core_pool() { + check_options ${FUNCNAME[0]} + + get_core_pool_entry() { + $CAS --list-caches -o csv | \ + awk -F, -v device=$(readlink -m $DEVICE_ID_OPTION) '{ + if ($1 == "core pool") pool = 1; + if ($1 == "cache") pool = 0; + if (pool == 1 && $3 == device) print $0; + }' + } + + local COMMAND="get_core_pool_entry | grep "Detached" &> /dev/null" run_cmd $COMMAND @@ -694,7 +740,9 @@ export -f set_cache_mode export -f add_core export -f try_add_core export -f remove_core -export -f check_device_state +export -f check_cache_state +export -f check_core_state +export -f check_device_in_core_pool export -f get_stats_value export -f init export -f iteration diff --git a/test/smoke_test/cas_options b/test/smoke_test/cas_options index d17b680..b82bbe1 100644 --- a/test/smoke_test/cas_options +++ b/test/smoke_test/cas_options @@ -37,7 +37,9 @@ export START_CACHE_REQUIRED_OPTIONS="CACHE_DEVICE_OPTION" export STOP_CACHE_REQUIRED_OPTIONS="CACHE_ID_OPTION" export ADD_CORE_REQUIRED_OPTIONS="CACHE_ID_OPTION CORE_DEVICE_OPTION" export TRY_ADD_CORE_REQUIRED_OPTIONS="CACHE_ID_OPTION CORE_ID_OPTION CORE_DEVICE_OPTION" -export CHECK_DEVICE_STATE_REQUIRED_OPTIONS="DEVICE_ID_OPTION DEMANDED_STATE_OPTION" +export CHECK_CACHE_STATE_REQUIRED_OPTIONS="CACHE_ID_OPTION DEMANDED_STATE_OPTION" +export CHECK_CORE_STATE_REQUIRED_OPTIONS="CACHE_ID_OPTION CORE_ID_OPTION DEMANDED_STATE_OPTION" +export CHECK_DEVICE_IN_CORE_POOL_REQUIRED_OPTIONS="DEVICE_ID_OPTION" export REMOVE_CORE_REQUIRED_OPTIONS="CACHE_ID_OPTION CORE_ID_OPTION" export REMOVE_PARTITIONS_REQUIRED_OPTIONS="TARGET_DEVICE_OPTION" export FLUSH_CACHE_REQUIRED_OPTIONS="CACHE_ID_OPTION" diff --git a/test/smoke_test/incremental_load/01 b/test/smoke_test/incremental_load/01 index 70ae000..b6b612c 100755 --- a/test/smoke_test/incremental_load/01 +++ b/test/smoke_test/incremental_load/01 @@ -36,10 +36,10 @@ CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part1" add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part2" add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part3" add_core -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state # Stop prepared setup CACHE_ID_OPTION="1" stop_cache @@ -47,21 +47,21 @@ 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}-part1" CORE_ID_OPTION="1" try_add_core -DEVICE_ID_OPTION="${CORE_DEVICE}-part1" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}-part1" check_device_in_core_pool CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part2" CORE_ID_OPTION="2" try_add_core -DEVICE_ID_OPTION="${CORE_DEVICE}-part2" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}-part2" check_device_in_core_pool CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part3" CORE_ID_OPTION="3" try_add_core -DEVICE_ID_OPTION="${CORE_DEVICE}-part3" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}-part3" check_device_in_core_pool # Try to load cache device, check if it is running and if all cores status is appropirate CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part1" CACHE_LOAD_METADATA_OPTION="y" start_cache -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state # Stop prepared setup diff --git a/test/smoke_test/incremental_load/02 b/test/smoke_test/incremental_load/02 index 78ed23f..8b68c56 100755 --- a/test/smoke_test/incremental_load/02 +++ b/test/smoke_test/incremental_load/02 @@ -36,10 +36,10 @@ CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part1" add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part2" add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part3" add_core -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state # Stop prepared setup CACHE_ID_OPTION="1" stop_cache @@ -49,10 +49,10 @@ 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_DEVICE_OPTION="${CACHE_DEVICE}-part1" CACHE_LOAD_METADATA_OPTION="y" start_cache -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Incomplete" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Inactive" check_core_state # Prepare partition for core device to be added CACHE_ID_OPTION="1" CACHE_DONT_FLUSH_DATA_OPTION="1" stop_cache @@ -62,16 +62,16 @@ sleep 1 CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part1" CORE_ID_OPTION="1" try_add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part2" CORE_ID_OPTION="2" try_add_core CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part3" CORE_ID_OPTION="3" try_add_core -DEVICE_ID_OPTION="${CORE_DEVICE}-part1" DEMANDED_STATE_OPTION="Detached" check_device_state -DEVICE_ID_OPTION="${CORE_DEVICE}-part2" DEMANDED_STATE_OPTION="Detached" check_device_state -DEVICE_ID_OPTION="${CORE_DEVICE}-part3" DEMANDED_STATE_OPTION="Detached" check_device_state +DEVICE_ID_OPTION="${CORE_DEVICE}-part1" check_device_in_core_pool +DEVICE_ID_OPTION="${CORE_DEVICE}-part2" check_device_in_core_pool +DEVICE_ID_OPTION="${CORE_DEVICE}-part3" check_device_in_core_pool CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part1" CACHE_LOAD_METADATA_OPTION="y" start_cache -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state # Clean up after test CACHE_ID_OPTION="1" stop_cache diff --git a/test/smoke_test/init_script/01 b/test/smoke_test/init_script/01 index 00114f0..f2c7f22 100755 --- a/test/smoke_test/init_script/01 +++ b/test/smoke_test/init_script/01 @@ -42,10 +42,10 @@ run_cmd "casctl init" run_cmd "udevadm settle" -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state run_cmd "casctl stop" @@ -53,10 +53,10 @@ check_no_cache_running run_cmd "casctl start" -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state run_cmd "casctl stop" diff --git a/test/smoke_test/init_script/02 b/test/smoke_test/init_script/02 index dc4ce93..cd91bbc 100755 --- a/test/smoke_test/init_script/02 +++ b/test/smoke_test/init_script/02 @@ -44,10 +44,10 @@ EOM run_cmd "casctl init" -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state run_cmd "casadm -G -n cleaning -i 16384 | grep "acp" &>/dev/null" @@ -57,10 +57,10 @@ check_no_cache_running run_cmd "casctl start" -DEVICE_ID_OPTION="${CACHE_DEVICE}-part1" 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 +CACHE_ID_OPTION="1" DEMANDED_STATE_OPTION="Running" check_cache_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="1" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="2" DEMANDED_STATE_OPTION="Active" check_core_state +CACHE_ID_OPTION="1" CORE_ID_OPTION="3" DEMANDED_STATE_OPTION="Active" check_core_state run_cmd "casctl stop"