]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/iscsi_tgt/filesystem/filesystem.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / test / iscsi_tgt / filesystem / filesystem.sh
CommitLineData
7c673cae
FG
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
11fdf7f2
TL
5source $rootdir/test/common/autotest_common.sh
6source $rootdir/test/iscsi_tgt/common.sh
7source $rootdir/scripts/common.sh
7c673cae 8
11fdf7f2 9timing_enter filesystem
7c673cae 10
11fdf7f2
TL
11rpc_py="$rootdir/scripts/rpc.py"
12# Remove lvol bdevs and stores.
13function remove_backends() {
14 echo "INFO: Removing lvol bdev"
15 $rpc_py destroy_lvol_bdev "lvs_0/lbd_0"
7c673cae 16
11fdf7f2
TL
17 echo "INFO: Removing lvol stores"
18 $rpc_py destroy_lvol_store -l lvs_0
7c673cae 19
11fdf7f2
TL
20 echo "INFO: Removing NVMe"
21 $rpc_py delete_nvme_controller Nvme0
7c673cae 22
11fdf7f2
TL
23 return 0
24}
7c673cae 25
11fdf7f2
TL
26timing_enter start_iscsi_tgt
27
28$ISCSI_APP -m $ISCSI_TEST_CORE_MASK --wait-for-rpc &
7c673cae
FG
29pid=$!
30echo "Process pid: $pid"
31
32trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT
33
11fdf7f2
TL
34waitforlisten $pid
35$rpc_py set_iscsi_options -o 30 -a 16
36$rpc_py start_subsystem_init
7c673cae
FG
37echo "iscsi_tgt is listening. Running tests..."
38
11fdf7f2
TL
39timing_exit start_iscsi_tgt
40
41bdf=$(iter_pci_class_code 01 08 02 | head -1)
42$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
7c673cae 43$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
11fdf7f2
TL
44$rpc_py construct_nvme_bdev -b "Nvme0" -t "pcie" -a $bdf
45
46ls_guid=$($rpc_py construct_lvol_store Nvme0n1 lvs_0)
47free_mb=$(get_lvs_free_mb "$ls_guid")
48# Using maximum 2048MiB to reduce the test time
49if [ $free_mb -gt 2048 ]; then
50 $rpc_py construct_lvol_bdev -u $ls_guid lbd_0 2048
51else
52 $rpc_py construct_lvol_bdev -u $ls_guid lbd_0 $free_mb
53fi
54# "lvs_0/lbd_0:0" ==> use lvs_0/lbd_0 blockdev for LUN0
7c673cae 55# "1:2" ==> map PortalGroup1 to InitiatorGroup2
11fdf7f2
TL
56# "256" ==> iSCSI queue depth 256
57# "-d" ==> disable CHAP authentication
58$rpc_py construct_target_node Target1 Target1_alias 'lvs_0/lbd_0:0' $PORTAL_TAG:$INITIATOR_TAG 256 -d
7c673cae
FG
59sleep 1
60
11fdf7f2
TL
61iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
62iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
7c673cae 63
11fdf7f2 64trap "remove_backends; umount /mnt/device; rm -rf /mnt/device; iscsicleanup; killprocess $pid; exit 1" SIGINT SIGTERM EXIT
7c673cae
FG
65
66sleep 1
67
11fdf7f2 68mkdir -p /mnt/device
7c673cae
FG
69
70dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
71
72parted -s /dev/$dev mklabel msdos
73parted -s /dev/$dev mkpart primary '0%' '100%'
74sleep 1
75
76for fstype in "ext4" "btrfs" "xfs"; do
77
78 if [ "$fstype" == "ext4" ]; then
79 mkfs.${fstype} -F /dev/${dev}1
80 else
81 mkfs.${fstype} -f /dev/${dev}1
82 fi
83 mount /dev/${dev}1 /mnt/device
11fdf7f2
TL
84 if [ $RUN_NIGHTLY -eq 1 ]; then
85 fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randwrite -ioengine=libaio -bs=4k \
86 -size=1024M -name=job0
87 umount /mnt/device
88
89 iscsiadm -m node --logout
90 sleep 1
91 iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
92 sleep 1
93 dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
94 mount -o rw /dev/${dev}1 /mnt/device
95 if [ -f "/mnt/device/test" ]; then
96 echo "File existed."
97 fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randread \
98 -ioengine=libaio -bs=4k -runtime=20 -time_based=1 -name=job0
99 else
100 echo "File doesn't exist."
101 exit 1
102 fi
103
104 rm -rf /mnt/device/test
105 umount /mnt/device
7c673cae 106 else
11fdf7f2
TL
107 touch /mnt/device/aaa
108 umount /mnt/device
109
110 iscsiadm -m node --logout
111 sleep 1
112 iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
113 sleep 1
114 dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
115 mount -o rw /dev/${dev}1 /mnt/device
116
117 if [ -f "/mnt/device/aaa" ]; then
118 echo "File existed."
119 else
120 echo "File doesn't exist."
121 exit 1
122 fi
123
124 rm -rf /mnt/device/aaa
125 umount /mnt/device
7c673cae 126 fi
7c673cae
FG
127done
128
129rm -rf /mnt/device
130
131trap - SIGINT SIGTERM EXIT
132
133iscsicleanup
11fdf7f2 134remove_backends
7c673cae
FG
135killprocess $pid
136timing_exit filesystem