Skip to content

Commit

Permalink
TEST: eos-instance-test - Added LRU system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ccaffy committed Jan 14, 2025
1 parent d0ab172 commit 71d8ddf
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/eos-test.install
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ usr/sbin/eos-fusex-certify
usr/sbin/eos-instance-test
usr/sbin/eos-instance-test-ci
usr/sbin/eos-accounting-test
usr/sbin/eos-lru-test
usr/sbin/eos-io-test
usr/sbin/eos-io-tool
usr/sbin/eos-oc-test
Expand Down
1 change: 1 addition & 0 deletions eos.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ Contains an instance and fuse test script and some test executables and test arc
%{_sbindir}/eos-instance-test
%{_sbindir}/eos-instance-test-ci
%{_sbindir}/eos-accounting-test
%{_sbindir}/eos-lru-test
%{_sbindir}/eos-rain-test
%{_sbindir}/eos-drain-test
%{_sbindir}/eos-balance-test
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ install(TARGETS xrdstress.exe xrdcpabort xrdcprandom xrdcppgread

install(PROGRAMS xrdstress eos-instance-test eos-instance-test-ci
fuse/eos-fuse-test eos-rain-test eoscp-rain-test eos-io-test eos-accounting-test
eos-oc-test eos-drain-test eos-groupdrain-test eos-mq-tests
eos-lru-test eos-oc-test eos-drain-test eos-groupdrain-test eos-mq-tests
eos-http-upload-test eos-https-functional-test eos-token-test
eos-fst-close-test eos-rename-test eos-grpc-test eos-fsck-test
eos-squash-test eos-backup eos-backup-browser eos-test-utils
Expand Down
16 changes: 14 additions & 2 deletions test/eos-instance-test
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,11 @@ eos_squash() {
}

eos_accounting() {
echo eos-accounting-test $1 $EOS_TEST_REDIRECTOR; eval eos-accounting-test $1 $EOS_TEST_REDIRECTOR >> $EOSCERTLOG 2>&1
echo eos-accounting-test $1 ; eval eos-accounting-test $1 ${EOS_TEST_REDIRECTOR} >> $EOSCERTLOG 2>&1
}

eos_lru() {
echo eos-lru-test $1 ; eval eos-lru-test $1 ${EOS_TEST_REDIRECTOR} >> $EOSCERTLOG 2>&1
}

shell() {
Expand Down Expand Up @@ -2326,7 +2330,15 @@ runtest "### eos-grpc " unix 0 "" eos_grpc "/eos/$EOS_TEST_INSTANCE/test/instan
# ------------------------------------------------------------------------------
categorie="accounting"
# ------------------------------------------------------------------------------
runtest "### eos-accounting" unix 0 "" eos_accounting "/eos/$EOS_TEST_INSTANCE/test/instancetest/accounting_test"
runtest "### eos-accounting " unix 0 "" eos_accounting "/eos/$EOS_TEST_INSTANCE/test/instancetest/accounting_test"

################################################################################
# lru tests
################################################################################
# ------------------------------------------------------------------------------
categorie="lru"
# ------------------------------------------------------------------------------
runtest "### eos-lru " unix 0 "" eos_lru "/eos/$EOS_TEST_INSTANCE/test/instancetest/lru_test"

################################################################################
# Token tests
Expand Down
81 changes: 81 additions & 0 deletions test/eos-lru-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

prefix=$1
host=${2-"localhost"}
url=root://$host
EOS_LRU_DIR=$prefix
watermarkLruDir="$EOS_LRU_DIR/watermarkLruDir"


cleanup() {
eos quota rmnode --really-want "$watermarkLruDir/"
eos rm -rF --no-confirmation "$EOS_LRU_DIR/"
}

# $1 is expected value, $2 is provided value, $3 is the context of the test to print the error message
assert_eq() {
if [[ "$1" != "$2" ]];
then
echo "error: $3, expected value is $1 but received $2"
exit 1
fi
}

cleanup

# Prepare the instance for the tests
eos convert clear
eos space config default space.lru=on
eos space config default space.lru.interval=5

# Test the LRU expire empty directory
eos mkdir -p "$EOS_LRU_DIR/" && eos touch "$EOS_LRU_DIR/file.touched"
eos attr set sys.lru.expire.empty=5 "$EOS_LRU_DIR/"
eos attr ls "$EOS_LRU_DIR/"
emptyDir="$EOS_LRU_DIR/empty_dir"
eos mkdir -p "$emptyDir"
sleep 10
assert_eq 0 "$(eos ls "$EOS_LRU_DIR" | grep -c 'empty_dir')" "empty_dir test: $emptyDir should be removed"

# Test the deletion of files not accessed since some time
accessTimeLruDir="$EOS_LRU_DIR/accessTimeLruDir"
eos mkdir -p "$accessTimeLruDir"
eos attr set 'sys.lru.expire.match=touched*:5s' "$accessTimeLruDir"
seq 1 100 | xargs -P 30 -I{} eos touch "$accessTimeLruDir/touched{}"
eos touch "$accessTimeLruDir/should_not_be_deleted"
assert_eq 101 "$(eos ls "$accessTimeLruDir" | wc -l)" "access time LRU test: $accessTimeLruDir does not have the correct amount of files"
sleep 10
# Only one file should remain: the `should_not_be_deleted` one
assert_eq 1 "$(eos ls "$accessTimeLruDir" | grep -c 'should_not_be_deleted')" "access time LRU test: $accessTimeLruDir should only contain the should_not_be_deleted file"

# Test the conversion LRU
convertLruDir="$EOS_LRU_DIR/convertLruDir"
eos mkdir -p "$convertLruDir"
oneKBFile="/tmp/1KB"
threeKBFile="/tmp/3KB"
head -c 1k < /dev/urandom > "$oneKBFile"
head -c 3k < /dev/urandom > "$threeKBFile"
# Raid 4+2 layout just for testing...
eos attr set 'sys.conversion.*=20640542' "$convertLruDir"
# All 2KB files should be queued in the converter once LRU will run
eos attr set 'sys.lru.convert.match=*:4s:>2k' "$convertLruDir"
seq 1 100 | xargs -I{} -P 30 eos cp $oneKBFile "$url/$convertLruDir/1KB{}"
seq 1 100 | xargs -I{} -P 30 eos cp $threeKBFile "$url/$convertLruDir/3KB{}"
sleep 15
assert_eq 100 "$(eos convert list | grep -c '#')" "convert LRU test: conversion list size mismatch"

# Test the low/high watermark
watermarkLruDir="$EOS_LRU_DIR/watermarkLruDir"
eos mkdir -p "$watermarkLruDir"
eos quota set -p "$watermarkLruDir" -v 11G -i 1M -g 99
eos quota ls -p "$watermarkLruDir"
eos attr set 'sys.lru.lowwatermark=1' "$watermarkLruDir"
eos attr set 'sys.lru.highwatermark=2' "$watermarkLruDir"
watermarkFileToDelete="/tmp/will-be-deleted"
head -c 250M < /dev/urandom > "$watermarkFileToDelete"
eos cp "$watermarkFileToDelete" "$url/$watermarkLruDir/will-be-deleted"
sleep 10
assert_eq 0 "$(eos ls -alhrt "$watermarkLruDir" | grep -c 'will-be-deleted')"
cleanup
echo "ALL LRU TESTS PASSED"
exit 0

0 comments on commit 71d8ddf

Please sign in to comment.