From: Joel Rosdahl Date: Mon, 12 Jul 2021 11:51:50 +0000 (+0200) Subject: Add test for Redis storage with password X-Git-Tag: v4.4~133 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2f9993db6042de6e5f5b55dd8bb4dc5987cf210;p=thirdparty%2Fccache.git Add test for Redis storage with password --- diff --git a/test/suites/secondary_redis.bash b/test/suites/secondary_redis.bash index a84a69c3b..076f43619 100644 --- a/test/suites/secondary_redis.bash +++ b/test/suites/secondary_redis.bash @@ -11,6 +11,7 @@ SUITE_secondary_redis_PROBE() { start_redis_server() { local port="$1" + local password="${2:-}" redis-server --bind localhost --port "${port}" >/dev/null & # Wait for server start. @@ -19,6 +20,10 @@ start_redis_server() { sleep 0.1 i=$((i + 1)) done + + if [ -n "${password}" ]; then + redis-cli -p "${port}" config set requirepass "${password}" &>/dev/null + fi } SUITE_secondary_redis_SETUP() { @@ -32,7 +37,7 @@ expect_number_of_redis_cache_entries() { local url=$2 local actual - actual=$(redis-cli -u "$url" keys "ccache:*" | wc -l) + actual=$(redis-cli -u "$url" keys "ccache:*" 2>/dev/null | wc -l) if [ "$actual" -ne "$expected" ]; then test_failed_internal "Found $actual (expected $expected) entries in $url" fi @@ -69,4 +74,36 @@ SUITE_secondary_redis() { expect_stat 'cache miss' 1 expect_stat 'files in cache' 0 expect_number_of_redis_cache_entries 2 "$redis_url" # result + manifest + + # ------------------------------------------------------------------------- + TEST "Password" + + port=7777 + password=secret + redis_url="redis://${password}@localhost:${port}" + export CCACHE_SECONDARY_STORAGE="${redis_url}" + + start_redis_server "${port}" "${password}" + + $CCACHE_COMPILE -c test.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache miss' 1 + expect_stat 'files in cache' 2 + expect_number_of_redis_cache_entries 2 "$redis_url" # result + manifest + + $CCACHE_COMPILE -c test.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache miss' 1 + expect_stat 'files in cache' 2 + expect_number_of_redis_cache_entries 2 "$redis_url" # result + manifest + + $CCACHE -C >/dev/null + expect_stat 'files in cache' 0 + expect_number_of_redis_cache_entries 2 "$redis_url" # result + manifest + + $CCACHE_COMPILE -c test.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache miss' 1 + expect_stat 'files in cache' 0 + expect_number_of_redis_cache_entries 2 "$redis_url" # result + manifest }