test/iscsi_tgt: Delete temporary files when trap catches error
In iscsi_tgt tests, when error is caught by trap command, temporary files are not deleted. By this patch, delete temporary files in trap handlers. Change-Id: I317a102db346b345c3d25a4977528c737b861748 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/419311 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Seth Howell <seth.howell5141@gmail.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
64ac643aa5
commit
051297114c
@ -4,6 +4,11 @@ rootdir=$(readlink -f $testdir/../../..)
|
||||
source $rootdir/test/common/autotest_common.sh
|
||||
source $rootdir/test/iscsi_tgt/common.sh
|
||||
|
||||
delete_tmp_conf_files() {
|
||||
rm -f /usr/local/etc/its.conf
|
||||
rm -f /usr/local/etc/auth.conf
|
||||
}
|
||||
|
||||
if [ ! -d /usr/local/calsoft ]; then
|
||||
echo "skipping calsoft tests"
|
||||
exit 0
|
||||
@ -31,7 +36,7 @@ $ISCSI_APP -c $testdir/iscsi.conf -m 0x1 &
|
||||
pid=$!
|
||||
echo "Process pid: $pid"
|
||||
|
||||
trap "killprocess $pid; exit 1 " SIGINT SIGTERM EXIT
|
||||
trap "killprocess $pid; delete_tmp_conf_files; exit 1 " SIGINT SIGTERM EXIT
|
||||
|
||||
waitforlisten $pid
|
||||
echo "iscsi_tgt is listening. Running tests..."
|
||||
@ -59,5 +64,6 @@ fi
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
|
||||
killprocess $pid
|
||||
delete_tmp_conf_files
|
||||
timing_exit calsoft
|
||||
exit $failed
|
||||
|
@ -23,7 +23,7 @@ $ISCSI_APP -c $testdir/iscsi.conf &
|
||||
pid=$!
|
||||
echo "Process pid: $pid"
|
||||
|
||||
trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "killprocess $pid; rm -f $testdir/iscsi.conf; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
waitforlisten $pid
|
||||
echo "iscsi_tgt is listening. Running tests..."
|
||||
@ -43,7 +43,7 @@ iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
||||
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
||||
|
||||
trap 'for new_dir in `dir -d /mnt/*dir`; do umount $new_dir; rm -rf $new_dir; done; \
|
||||
iscsicleanup; killprocess $pid; exit 1' SIGINT SIGTERM EXIT
|
||||
iscsicleanup; killprocess $pid; rm -f $testdir/iscsi.conf; exit 1' SIGINT SIGTERM EXIT
|
||||
|
||||
sleep 1
|
||||
|
||||
|
@ -5,6 +5,11 @@ rootdir=$(readlink -f $testdir/../../..)
|
||||
source $rootdir/test/common/autotest_common.sh
|
||||
source $rootdir/test/iscsi_tgt/common.sh
|
||||
|
||||
delete_tmp_files() {
|
||||
rm -f $testdir/iscsi.conf
|
||||
rm -f ./local-job0-0-verify.state
|
||||
}
|
||||
|
||||
function running_config() {
|
||||
# generate a config file from the running iscsi_tgt
|
||||
# running_config.sh will leave the file at /tmp/iscsi.conf
|
||||
@ -15,14 +20,14 @@ function running_config() {
|
||||
# keep the same iscsiadm configuration to confirm that the
|
||||
# config file matched the running configuration
|
||||
killprocess $pid
|
||||
trap "iscsicleanup; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "iscsicleanup; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
timing_enter start_iscsi_tgt2
|
||||
|
||||
$ISCSI_APP -c /tmp/iscsi.conf &
|
||||
pid=$!
|
||||
echo "Process pid: $pid"
|
||||
trap "iscsicleanup; killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "iscsicleanup; killprocess $pid; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
||||
waitforlisten $pid
|
||||
echo "iscsi_tgt is listening. Running tests..."
|
||||
|
||||
@ -58,7 +63,7 @@ $ISCSI_APP -c $testdir/iscsi.conf &
|
||||
pid=$!
|
||||
echo "Process pid: $pid"
|
||||
|
||||
trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "killprocess $pid; rm -f $testdir/iscsi.conf; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
waitforlisten $pid
|
||||
echo "iscsi_tgt is listening. Running tests..."
|
||||
@ -78,7 +83,7 @@ sleep 1
|
||||
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
||||
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
||||
|
||||
trap "iscsicleanup; killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "iscsicleanup; killprocess $pid; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
sleep 1
|
||||
$fio_py 4096 1 randrw 1 verify
|
||||
@ -118,10 +123,10 @@ set -e
|
||||
iscsicleanup
|
||||
$rpc_py delete_target_node 'iqn.2016-06.io.spdk:Target3'
|
||||
|
||||
rm -f ./local-job0-0-verify.state
|
||||
delete_tmp_files
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
iscsicleanup
|
||||
rm -f $testdir/iscsi.conf
|
||||
|
||||
killprocess $pid
|
||||
#echo 1 > /sys/bus/pci/rescan
|
||||
#sleep 2
|
||||
|
@ -34,7 +34,7 @@ $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE
|
||||
# "-d" ==> disable CHAP authentication
|
||||
$rpc_py construct_target_node disk1 disk1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 256 -d
|
||||
sleep 1
|
||||
trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "killprocess $pid; rm -f $testdir/bdev.conf; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
# Prepare config file for iSCSI initiator
|
||||
cp $testdir/bdev.conf.in $testdir/bdev.conf
|
||||
|
@ -40,7 +40,7 @@ function run_nvme_remote() {
|
||||
$ISCSI_APP -r "$iscsi_rpc_addr" -c $testdir/iscsi.conf.tmp -m 0x1 -p 0 -s 512 &
|
||||
iscsipid=$!
|
||||
echo "iSCSI target launched. pid: $iscsipid"
|
||||
trap "killprocess $iscsipid; killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "killprocess $iscsipid; killprocess $nvmfpid; rm -f $testdir/iscsi.conf.tmp; exit 1" SIGINT SIGTERM EXIT
|
||||
waitforlisten $iscsipid "$iscsi_rpc_addr"
|
||||
echo "iSCSI target has started."
|
||||
|
||||
@ -67,7 +67,7 @@ NVMF_APP="$rootdir/app/nvmf_tgt/nvmf_tgt"
|
||||
$NVMF_APP -c $rootdir/test/nvmf/nvmf.conf -m 0x2 -p 1 -s 512 &
|
||||
nvmfpid=$!
|
||||
echo "NVMf target launched. pid: $nvmfpid"
|
||||
trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "killprocess $nvmfpid; rm -f $testdir/iscsi.conf.tmp; exit 1" SIGINT SIGTERM EXIT
|
||||
waitforlisten $nvmfpid
|
||||
echo "NVMf target has started."
|
||||
bdevs=$($rpc_py construct_malloc_bdev 64 512)
|
||||
@ -78,7 +78,8 @@ timing_enter start_iscsi_tgt
|
||||
|
||||
run_nvme_remote "local"
|
||||
|
||||
trap "iscsicleanup; killprocess $iscsipid; killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "iscsicleanup; killprocess $iscsipid; killprocess $nvmfpid; rm -f $testdir/iscsi.conf.tmp; \
|
||||
rm -f ./local-job0-0-verify.state; exit 1" SIGINT SIGTERM EXIT
|
||||
sleep 1
|
||||
|
||||
echo "Running FIO"
|
||||
|
Loading…
Reference in New Issue
Block a user