Skip to content

Commit

Permalink
make ttl test more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
V-FEXrt committed Mar 8, 2024
1 parent 125a6ef commit 35539d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/job-cache/basic-ttl/pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/job-cache/basic-ttl/stdout
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 35539d8

Please sign in to comment.