Commit f538c202 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Ben Walker
Browse files

test/ftl: Test upgrade shutdown for bands

parent d4a2d28d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ function tcp_target_setup() {
	local base_bdev=""
	local cache_bdev=""

	if [ -f "$spdk_tgt_cnfg" ]; then
	if [[ -f "$spdk_tgt_cnfg" ]]; then
		$spdk_tgt_bin "--cpumask=$spdk_tgt_cpumask" --config="$spdk_tgt_cnfg" &
	else
		$spdk_tgt_bin "--cpumask=$spdk_tgt_cpumask" &
@@ -133,6 +133,13 @@ function tcp_target_shutdown() {
	fi
}

function tcp_target_shutdown_dirty() {
	if [[ -n "$spdk_tgt_pid" ]]; then
		kill -9 "$spdk_tgt_pid"
		unset spdk_tgt_pid
	fi
}

function tcp_target_cleanup() {
	tcp_target_shutdown
	rm -f "$spdk_tgt_cnfg"
+33 −17
Original line number Diff line number Diff line
@@ -55,9 +55,12 @@ $rpc_py bdev_ftl_get_properties -b ftl
# Enable upgrade shutdown
$rpc_py bdev_ftl_set_property -b ftl -p prep_upgrade_on_shutdown -v true

function ftl_get_properties() {
	$rpc_py bdev_ftl_get_properties -b $FTL_BDEV
}

# Validate there are utilized chunks
used=$($rpc_py bdev_ftl_get_properties -b ftl \
	| jq '[.properties[] | select(.name == "cache_device") | .chunks[] | select(.utilization != 0.0)] | length')
used=$(ftl_get_properties | jq '[.properties[] | select(.name == "cache_device") | .chunks[] | select(.utilization != 0.0)] | length')
if [[ "$used" -eq 0 ]]; then
	echo "Shutdown upgrade ERROR, excepted utilized chunks"
	exit 1
@@ -76,18 +79,24 @@ $rpc_py bdev_ftl_set_property -b ftl -p verbose_mode -v true
$rpc_py bdev_ftl_get_properties -b ftl

# Validate if all chunks utilization is 0.0
used=$($rpc_py bdev_ftl_get_properties -b ftl \
	| jq '[.properties[] | select(.name == "cache_device") | .chunks[] | select(.utilization != 0.0)] | length')
used=$(ftl_get_properties | jq '[.properties[] | select(.name == "cache_device") | .chunks[] | select(.utilization != 0.0)] | length')
if [[ "$used" -ne 0 ]]; then
	echo "Shutdown upgrade ERROR, excepted only empty chunks"
	exit 1
fi

# Validate MD5 checksum
# Validate no opened bands
opened=$(ftl_get_properties | jq '[.properties[] | select(.name == "bands") | .bands[] | select(.state == "OPENED")] | length')
if [[ "$opened" -ne 0 ]]; then
	echo "Shutdown upgrade ERROR, excepted no opened band"
	exit 1
fi

function test_validate_checksum() {
	skip=0
	for ((i = 0; i < iterations; i++)); do
		echo "Validate MD5 checksum, iteration $((i + 1))"
	tcp_dd --ib=ftln1 --of="${testdir}/file" --bs="$bs" --count="$count" --qd="$qd" --skip="$skip"
		tcp_dd --ib=ftln1 --of="${testdir}/file" --bs="$bs" --count="$count" --qd="${qd}" --skip="$skip"
		skip=$((skip + count))

		md5sum "${testdir}/file" > "${testdir}/file.md5"
@@ -98,6 +107,13 @@ for ((i = 0; i < iterations; i++)); do
			exit 1
		fi
	done
}
test_validate_checksum

# Data integrity test after dirty shutdown after upgrade
tcp_target_shutdown_dirty
tcp_target_setup
test_validate_checksum

trap - SIGINT SIGTERM EXIT
cleanup