From 71d8ddfac482e3e6739b7895541b564adb6727d9 Mon Sep 17 00:00:00 2001 From: Cedric Caffy Date: Thu, 28 Nov 2024 17:24:52 +0100 Subject: [PATCH] TEST: eos-instance-test - Added LRU system tests --- debian/eos-test.install | 1 + eos.spec.in | 1 + test/CMakeLists.txt | 2 +- test/eos-instance-test | 16 +++++++- test/eos-lru-test | 81 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 test/eos-lru-test diff --git a/debian/eos-test.install b/debian/eos-test.install index 679fa8035..8f366e8dd 100644 --- a/debian/eos-test.install +++ b/debian/eos-test.install @@ -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 diff --git a/eos.spec.in b/eos.spec.in index 806da6ae3..a8a192126 100644 --- a/eos.spec.in +++ b/eos.spec.in @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f28442a4e..9bb909d87 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 diff --git a/test/eos-instance-test b/test/eos-instance-test index 1449d412e..e2b6a832b 100755 --- a/test/eos-instance-test +++ b/test/eos-instance-test @@ -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() { @@ -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 diff --git a/test/eos-lru-test b/test/eos-lru-test new file mode 100644 index 000000000..1fd3cccf1 --- /dev/null +++ b/test/eos-lru-test @@ -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 \ No newline at end of file