1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#!/bin/bash
. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
# Test if the given process has a number of threads of a given type between
# min and max.
function check_threads() {
local pid="${1}"
local pattern="${2}"
local min="${3}"
local max="${4-}"
local count
count="$(ps hH -o comm ${pid} | grep "${pattern}" | wc -l)"
if [[ ${min} -gt ${count} ]]; then
return 1
fi
if [[ ! -z "${max}" && ${max} -lt ${count} ]]; then
return 1
fi
return 0
}
cleanup
TEST glusterd
# Glusterd shouldn't use any thread
TEST check_threads $(get_glusterd_pid) glfs_tpw 0 0
TEST check_threads $(get_glusterd_pid) glfs_iotwr 0 0
TEST pkill -9 glusterd
TEST glusterd --global-threading
# Glusterd shouldn't use global threads, even if enabled
TEST check_threads $(get_glusterd_pid) glfs_tpw 0 0
TEST check_threads $(get_glusterd_pid) glfs_iotwr 0 0
TEST $CLI volume create $V0 replica 2 $H0:$B0/b{0,1}
# Normal configuration using io-threads on bricks
TEST $CLI volume set $V0 config.global-threading off
TEST $CLI volume set $V0 performance.iot-pass-through off
TEST $CLI volume set $V0 performance.client-io-threads off
TEST $CLI volume start $V0
# There shouldn't be global threads
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b0) glfs_tpw 0 0
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b1) glfs_tpw 0 0
# There should be at least 1 io-thread
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b0) glfs_iotwr 1
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b1) glfs_iotwr 1
# Self-heal should be using global threads
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
TEST check_threads $(get_shd_process_pid) glfs_tpw 1
TEST check_threads $(get_shd_process_pid) glfs_iotwr 0 0
TEST $CLI volume stop $V0
# Configuration with global threads on bricks
TEST $CLI volume set $V0 config.global-threading on
TEST $CLI volume set $V0 performance.iot-pass-through on
TEST $CLI volume start $V0
# There should be at least 1 global thread
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b0) glfs_tpw 1
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b1) glfs_tpw 1
# There shouldn't be any io-thread worker threads
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b0) glfs_iotwr 0 0
TEST check_threads $(get_brick_pid $V0 $H0 $B0/b1) glfs_iotwr 0 0
# Normal configuration using io-threads on clients
TEST $CLI volume set $V0 performance.iot-pass-through off
TEST $CLI volume set $V0 performance.client-io-threads on
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
# There shouldn't be global threads
TEST check_threads $(get_mount_process_pid $V0 $M0) glfs_tpw 0 0
# There should be at least 1 io-thread
TEST check_threads $(get_mount_process_pid $V0 $M0) glfs_iotwr 1
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
# Configuration with global threads on clients
TEST $CLI volume set $V0 performance.client-io-threads off
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 --global-threading $M0
# There should be at least 1 global thread
TEST check_threads $(get_mount_process_pid $V0 $M0) glfs_tpw 1
# There shouldn't be io-threads
TEST check_threads $(get_mount_process_pid $V0 $M0) glfs_iotwr 0 0
# Some basic volume access checks with global-threading enabled everywhere
TEST mkdir ${M0}/dir
TEST dd if=/dev/zero of=${M0}/dir/file bs=128k count=8
cleanup
|