}
run_test 107 "Wait for PCC atatch finished on PCC detach command"
+wait_lpcc_purge_scan_end() {
+ local pidfile=$1
+ local statsfile=$2
+ local i
+ local end_time_secs;
+
+ for (( i=0; i<50; i++ )); do
+ do_facet $SINGLEAGT pkill --pidfile $pidfile --signal USR1 \
+ -- lpcc_purge
+ end_time_secs=$(grep "end_time_secs" $statsfile | awk '{print $2}')
+ end_time_secs=${end_time_secs/,/}
+
+ if [[ -n "$end_time_secs" && "$end_time_secs" -gt 0 ]]; then
+ echo "finished at least 1 scanning"
+ break;
+ else
+ echo "wait for 0.7 sec..."
+ sleep 0.7
+ fi
+ done
+ # purging files is async, so wait a little longer
+ sleep 5
+}
+
test_200() {
local loopfile="$TMP/$tfile"
local mntpt="/mnt/pcc.$tdir"
echo "cache device usage($usage) >= high_usage($high_usage)"
fi
- pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local statsfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.stats
do_facet $SINGLEAGT $LPCC_PURGE --mount $MOUNT --cache $hsm_root \
--high-usage $high_usage --low-usage $low_usage \
- --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile --interval 1 -b &
- sleep 5
+ --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile -w $statsfile \
+ --interval 1 -b &
+ wait_lpcc_purge_scan_end $pidfile $statsfile
do_facet $SINGLEAGT pkill --pidfile $pidfile -- lpcc_purge
# Get cache usage
echo "cache device usage ($usage)"
fi
- pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local statsfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.stats
do_facet $SINGLEAGT $LPCC_PURGE --mount $MOUNT --cache $hsm_root \
--high-usage $high_usage --low-usage $low_usage \
- --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile --interval 1 -b &
- sleep 5
+ --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile -w $statsfile \
+ --interval 1 -b &
+ wait_lpcc_purge_scan_end $pidfile $statsfile
do_facet $SINGLEAGT pkill --pidfile $pidfile -- lpcc_purge
# Get cache usage
sleep 0.1
done
- pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local pidfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.pid
+ local statsfile=lpcc_purge-${HSM_ARCHIVE_NUMBER}.stats
do_facet $SINGLEAGT $LPCC_PURGE --mount $MOUNT --cache $hsm_root \
--high-usage $high_usage --low-usage $low_usage \
- --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile --interval 1 -b &
- sleep 5
+ --roid $HSM_ARCHIVE_NUMBER --pidfile $pidfile -w $statsfile \
+ --interval 1 -b &
+ wait_lpcc_purge_scan_end $pidfile $statsfile
do_facet $SINGLEAGT pkill --pidfile $pidfile -- lpcc_purge
# verify that the independent file was not removed
# there should be 54 files been purged
# in theroy, file 1-54 should be purge, 55-100 should be kept.
- # But since we are an approxomate LRU algorithm, we test f.50 being
+ # But since we are an approxomate LRU algorithm, we test f.40 being
# purged and f.60 not
- file=$DIR/$tdir/$tfile.50.dat
+ file=$DIR/$tdir/$tfile.40.dat
check_lpcc_state $file "none"
file=$DIR/$tdir/$tfile.60.dat
check_lpcc_state $file "readonly"