Update smoke tests utilities
according to recent changes Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
031a37a041
commit
0d9a56b4f0
@ -74,12 +74,12 @@ check_config() {
|
||||
fi
|
||||
|
||||
# Check if core and cache devices are free for us or not
|
||||
if [ -z $IGNORE_WARNINGS ] && [ -n "$(ls ${CORE_DEVICE}[0-9]* 2> /dev/null)" ] ; then
|
||||
if [ -z $IGNORE_WARNINGS ] && [ -n "$(ls ${CORE_DEVICE}-part[0-9]* 2> /dev/null)" ] ; then
|
||||
warning "The core device $CORE_DEVICE is partitioned! Some tests may remove partitions from this device"
|
||||
warning "Use --ignore | -i flag to force using this core device"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z $IGNORE_WARNINGS ] && [ -n "$(ls ${CACHE_DEVICE}[0-9]* 2> /dev/null)" ] ; then
|
||||
if [ -z $IGNORE_WARNINGS ] && [ -n "$(ls ${CACHE_DEVICE}-part[0-9]* 2> /dev/null)" ] ; then
|
||||
warning "The cache device $CACHE_DEVICE is partitioned!"
|
||||
warning "Use --ignore | -i flag to force using this cache device"
|
||||
exit 1
|
||||
@ -93,11 +93,15 @@ check_config() {
|
||||
umount $DEVICE_TO_UMOUNT
|
||||
done
|
||||
|
||||
if [ -n "$(mount | grep $CACHE_DEVICE)" ] ; then
|
||||
SHORT_CACHE_LINK=$(realpath $CACHE_DEVICE)
|
||||
OUTPUT_MOUNT_CACHE=$(mount | grep -E "$CACHE_DEVICE|$SHORT_CACHE_LINK")
|
||||
if [ -n "$OUTPUT_MOUNT_CACHE" ] ; then
|
||||
error "The cache device $CACHE_DEVICE or one of its partitions is mounted!"
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$(mount | grep $CORE_DEVICE)" ] ; then
|
||||
SHORT_CORE_LINK=$(realpath $CORE_DEVICE)
|
||||
OUTPUT_MOUNT_CORE=$(mount | grep -E $CORE_DEVICE|$SHORT_CORE_LINK)
|
||||
if [ -n "$OUTPUT_MOUNT_CORE" ] ; then
|
||||
error "The core device $CORE_DEVICE or one of its partitions is mounted!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -16,6 +16,7 @@ OCF
|
||||
RHEL
|
||||
SLES
|
||||
SSD
|
||||
SSDP
|
||||
SUSE
|
||||
TERM
|
||||
TTY
|
||||
@ -48,7 +49,10 @@ reseller
|
||||
resizing
|
||||
runtime
|
||||
sdb
|
||||
sdx
|
||||
utf
|
||||
wa
|
||||
wb
|
||||
wt
|
||||
wo
|
||||
wwn
|
||||
|
@ -30,18 +30,6 @@ restore_config() {
|
||||
start_cache() {
|
||||
check_options ${FUNCNAME[0]}
|
||||
|
||||
CACHE_DEVICE_NVME_REGEX="(/dev/nvme[0-9]n[0-9])([0-9]*)"
|
||||
if [ ! -b ${CACHE_DEVICE_OPTION} ]
|
||||
then
|
||||
if [[ "${CACHE_DEVICE_OPTION}" =~ ${CACHE_DEVICE_NVME_REGEX} ]]
|
||||
then
|
||||
if [ -b ${BASH_REMATCH[1]}p${BASH_REMATCH[2]} ]
|
||||
then
|
||||
CACHE_DEVICE_OPTION=${BASH_REMATCH[1]}p${BASH_REMATCH[2]}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
local COMMAND="$CAS --start-cache --cache-device $CACHE_DEVICE_OPTION --cache-id $CACHE_ID_OPTION"
|
||||
|
||||
if [ -n "$CACHE_FORCE_OPTION" ] ; then
|
||||
@ -113,7 +101,8 @@ add_core() {
|
||||
return 0
|
||||
fi
|
||||
local i=0
|
||||
local CAS_DEV=` casadm -L | egrep "^.core +[0-9]+ +$CORE_DEVICE_OPTION" | awk '{print $NF}'`
|
||||
local SHORT_LINK=$(realpath $CORE_DEVICE_OPTION)
|
||||
local CAS_DEV=` casadm -L | egrep "^.core +[0-9]+ +$SHORT_LINK" | awk '{print $NF}'`
|
||||
clear_options
|
||||
while [ ! -e $CAS_DEV ]; do
|
||||
sleep 2
|
||||
@ -291,10 +280,10 @@ init() {
|
||||
CACHE_LINE_SIZE="$L_CACHE_LINE_SIZE"
|
||||
fi
|
||||
|
||||
CACHE_ID_OPTION="$i" CACHE_DEVICE_OPTION="${CACHE_DEVICE}$i" start_cache
|
||||
CACHE_ID_OPTION="$i" CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part$i" start_cache
|
||||
|
||||
for ((j = 1; j <= L_NUMBER_OF_CORE_PARTITIONS && j <= MAX_NUMBER_OF_CORE_PARTITIONS; j++)); do
|
||||
CACHE_ID_OPTION="$i" CORE_DEVICE_OPTION="${CORE_DEVICE}$k" add_core
|
||||
CACHE_ID_OPTION="$i" CORE_DEVICE_OPTION="${CORE_DEVICE}-part$k" add_core
|
||||
k=`expr $k \+ 1`
|
||||
done
|
||||
done
|
||||
@ -808,9 +797,9 @@ make_primary_partitions() {
|
||||
|
||||
for ID in `seq 1 $PART_NUM`; do
|
||||
local i=0
|
||||
local TEST_DEV="${TARGET_DEVICE_OPTION}${ID}"
|
||||
local TEST_DEV_P="${TARGET_DEVICE_OPTION}p${ID}"
|
||||
while ! [[ -b $TEST_DEV || -b $TEST_DEV_P ]] ; do
|
||||
local TEST_DEV="${DEV_NAME}-part${ID}"
|
||||
local TEST_DEV_P="${DEV_NAME}-part${ID}"
|
||||
while ! [[ -L $TEST_DEV || -L $TEST_DEV_P ]] ; do
|
||||
# make sure that partition is detected if it was created
|
||||
partprobe
|
||||
sleep 1
|
||||
@ -829,7 +818,7 @@ make_primary_partitions() {
|
||||
# erase all filesystem/cas cache metadata that may have existed on it
|
||||
# before.
|
||||
|
||||
if [ -b $TEST_DEV ]
|
||||
if [ -L $TEST_DEV ]
|
||||
then
|
||||
run_cmd dd if=/dev/zero of="${TEST_DEV}" bs=1M count=1 oflag=direct
|
||||
else
|
||||
@ -913,6 +902,7 @@ remove_caches() {
|
||||
}
|
||||
|
||||
turn_on_device() {
|
||||
# Use realpath resolved before turning off device
|
||||
check_options ${FUNCNAME[0]}
|
||||
if [[ $CACHE_DEVICE_OPTION == "/dev/nvme"* ]] ; then
|
||||
turn_on_nvme_device
|
||||
@ -925,17 +915,19 @@ turn_on_device() {
|
||||
|
||||
turn_off_device() {
|
||||
check_options ${FUNCNAME[0]}
|
||||
if [[ $CACHE_DEVICE_OPTION == "/dev/nvme"* ]] ; then
|
||||
SHORT_LINK=$(realpath $CACHE_DEVICE_OPTION)
|
||||
if [[ $SHORT_LINK == "/dev/nvme"* ]] ; then
|
||||
turn_off_nvme_device
|
||||
else
|
||||
local COMMAND="echo 'offline' > /sys/block/${CACHE_DEVICE_OPTION:4}/device/state"
|
||||
local COMMAND="echo 'offline' > /sys/block/${SHORT_LINK:4}/device/state"
|
||||
run_cmd $COMMAND
|
||||
fi
|
||||
}
|
||||
|
||||
turn_off_nvme_device() {
|
||||
check_options ${FUNCNAME[0]}
|
||||
COMMAND="echo '1' > /sys/block/${CACHE_DEVICE_OPTION:4}/device/device/remove"
|
||||
SHORT_LINK=$(realpath $CACHE_DEVICE_OPTION)
|
||||
COMMAND="echo '1' > /sys/block/${SHORT_LINK:4}/device/device/remove"
|
||||
run_cmd $COMMAND
|
||||
clear_options
|
||||
}
|
||||
|
@ -30,6 +30,21 @@ check_if_root_or_exit() {
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_path() {
|
||||
local BY_ID_DIR="/dev/disk/by-id"
|
||||
local BY_ID_LINKS=$(ls $BY_ID_DIR)
|
||||
|
||||
for BY_ID_PATH in $BY_ID_LINKS
|
||||
do
|
||||
FULL_PATH="${BY_ID_DIR}/${BY_ID_PATH}"
|
||||
if [[ "$(realpath $FULL_PATH)" -ef "$(realpath $DEVICE)" ]]
|
||||
then
|
||||
DEVICE=$FULL_PATH
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while [ -n "$1" ] ; do
|
||||
|
||||
@ -51,10 +66,14 @@ parse_args() {
|
||||
-i | --ignore ) export IGNORE_WARNINGS="1"
|
||||
;;
|
||||
-c | --cache ) shift
|
||||
CACHE_DEVICE="$1"
|
||||
DEVICE="$1"
|
||||
resolve_path
|
||||
CACHE_DEVICE=$DEVICE
|
||||
;;
|
||||
-d | --core ) shift
|
||||
CORE_DEVICE="$1"
|
||||
DEVICE="$1"
|
||||
resolve_path
|
||||
CORE_DEVICE=$DEVICE
|
||||
;;
|
||||
* ) echo "Unrecognized option"
|
||||
usage
|
||||
|
@ -494,7 +494,7 @@ Defines output format for list of all cache instances and core devices. It can b
|
||||
.TP
|
||||
.B -b --by-id-path
|
||||
Display path to devices in long format (/dev/disk/by-id/some_link).
|
||||
If this option is not given, displays path in short format (/dev/sdX) instead.
|
||||
If this option is not given, displays path in short format (/dev/sdx) instead.
|
||||
|
||||
.SH Options that are valid with --stats (-P) are:
|
||||
.TP
|
||||
@ -539,7 +539,7 @@ Defines output format for statistics. It can be either \fBtable\fR
|
||||
.TP
|
||||
.B -b --by-id-path
|
||||
Display path to device in long format (/dev/disk/by-id/some_link).
|
||||
If this option is not given, displays path in short format (/dev/sdX) instead.
|
||||
If this option is not given, displays path in short format (/dev/sdx) instead.
|
||||
|
||||
.SH Options that are valid with --reset-counters (-Z) are:
|
||||
.TP
|
||||
|
Loading…
Reference in New Issue
Block a user