From ce4482f794657329502d182efd29a6283824db23 Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Wed, 6 Mar 2024 14:18:52 -0800 Subject: [PATCH] make ttl test more explicit --- tests/job-cache/basic-ttl/pass.sh | 18 ++++++++++++++++++ tests/job-cache/basic-ttl/stdout | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/job-cache/basic-ttl/stdout diff --git a/tests/job-cache/basic-ttl/pass.sh b/tests/job-cache/basic-ttl/pass.sh index 90c0f56fe..2d3d41136 100755 --- a/tests/job-cache/basic-ttl/pass.sh +++ b/tests/job-cache/basic-ttl/pass.sh @@ -2,6 +2,9 @@ set -e WAKE="${1:+$1/wake}" + +echo "Cleaning up stale artifacts" + rm wake.db 2> /dev/null || true rm -rf .cache-hit 2> /dev/null || true rm -rf .cache-misses 2> /dev/null || true @@ -10,20 +13,27 @@ rm one.txt 2> /dev/null || true rm two.txt 2> /dev/null || true rm three.txt 2> /dev/null || true rm four.txt 2> /dev/null || true + +echo "Running test one to fill the cache" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test one rm wake.db rm -rf .cache-misses sleep 1 + +echo "Running test two to fill the cache" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test two rm wake.db rm -rf .cache-misses sleep 1 + +echo "Running test three to fill the cache" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test three rm wake.db rm -rf .cache-misses sleep 1 # We should still be under the limit here. This is to ensure we mark test one as used +echo "Running test one again. Should be a cache hit" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test one rm wake.db rm -rf .cache-misses @@ -34,11 +44,14 @@ fi sleep 4 # Now we're going to go over. Hopefully dropping two and three, but keeping one and four +echo "Going over. Expecting two and three to be dropped" +echo "Running test one again. Should be a cache hit" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test one rm wake.db rm -rf .cache-misses # Now make sure we still get a hit on 1 +echo "Running test three again. Should be a cache hit" rm -rf .cache-hit 2> /dev/null || true WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test three rm wake.db @@ -54,6 +67,7 @@ sleep 1 # And check that we get misses on four and three +echo "Running test two again. Should be a cache miss" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test two rm wake.db if [ -z "$(ls -A .cache-misses)" ]; then @@ -64,6 +78,7 @@ rm -rf .cache-misses sleep 1 +echo "Running test one again. Should be a cache hit" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test one rm wake.db if [ -d ".cache-misses" ]; then @@ -72,6 +87,7 @@ if [ -d ".cache-misses" ]; then fi rm -rf .cache-hit +echo "Running test four again. Should be a cache miss" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test four rm wake.db if [ -z "$(ls -A .cache-misses)" ]; then @@ -81,6 +97,7 @@ fi rm -rf .cache-misses +echo "Running test two again. Should be a cache hit" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test two rm wake.db if [ -d ".cache-misses" ]; then @@ -89,6 +106,7 @@ if [ -d ".cache-misses" ]; then fi rm -rf .cache-hit +echo "Running test four again. Should be a cache hit" WAKE_SHARED_CACHE_FAST_CLOSE=1 DEBUG_WAKE_SHARED_CACHE=1 WAKE_LOCAL_JOB_CACHE=.job-cache "${WAKE:-wake}" test four rm wake.db if [ -z "$(ls -A .cache-hit)" ]; then diff --git a/tests/job-cache/basic-ttl/stdout b/tests/job-cache/basic-ttl/stdout new file mode 100644 index 000000000..f6f459733 --- /dev/null +++ b/tests/job-cache/basic-ttl/stdout @@ -0,0 +1,24 @@ +Cleaning up stale artifacts +Running test one to fill the cache +Pass ("one.txt", Nil) +Running test two to fill the cache +Pass ("two.txt", Nil) +Running test three to fill the cache +Pass ("three.txt", Nil) +Running test one again. Should be a cache hit +Pass ("one.txt", Nil) +Going over. Expecting two and three to be dropped +Running test one again. Should be a cache hit +Pass ("one.txt", Nil) +Running test three again. Should be a cache hit +Pass ("three.txt", Nil) +Running test two again. Should be a cache miss +Pass ("two.txt", Nil) +Running test one again. Should be a cache hit +Pass ("one.txt", Nil) +Running test four again. Should be a cache miss +Pass ("four.txt", Nil) +Running test two again. Should be a cache hit +Pass ("two.txt", Nil) +Running test four again. Should be a cache hit +Pass ("four.txt", Nil)