Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Test how an expired page slot is refreshed
No test showed a refresh serving and storing the page as it is now, and
the too-large refill could not tell a fresh render from the expired
copy, since nothing changed in between. A negative page ttl was proven
never to expire only for the scan list.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0003-cache.sh | 42 |
1 file changed, 39 insertions, 3 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index a65b3ce..c044a84 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -213,15 +213,51 @@ test_expect_success 'a response over cache-max-slot-size is served but not kept' test_expect_success 'an expired slot is dropped when its refill is too large' ' rm -rf cache3 && mkdir cache3 && - cgit_rc bigkeyrc "url=bigpage/tree/big.txt" >/dev/null && + cgit_ok bigkeyrc "url=bigpage/tree/big.txt" >/dev/null && ls cache3 >filled.slots && test_line_count = 1 filled.slots && + echo "the expired copy" >>"cache3/$(cat filled.slots)" && touch -t 200001010000 cache3/* && - cgit_rc slotsizerc "url=bigpage/tree/big.txt" >big.refill && - tail -c 200 big.refill | grep "</html>" && + cgit_ok slotsizerc "url=bigpage/tree/big.txt" >big.refill && + test_grep ! "the expired copy" big.refill && test_dir_is_empty cache3 ' +# A slot past its ttl is rendered again, and the new page is both what the +# request gets and what the slot keeps. The ttl is long enough that the copy +# is still served after the commit, which shows the slot is in use. +test_expect_success 'an expired slot is refreshed with the page as it is now' ' + rm -rf cache3 && mkdir cache3 && + mkrepo repos/fresh 1 && + cgitrc_repo freshrc fresh "cache-root=$PWD/cache3" cache-size=64 cache-dynamic-ttl=60 && + cgit_ok freshrc "url=fresh/log/" >/dev/null && + slot=$(ls cache3) && + git -C repos/fresh commit --allow-empty -q -m "a newer commit" && + cgit_ok freshrc "url=fresh/log/" >stale.out && + test_grep ! "a newer commit" stale.out && + touch -t 200001010000 "cache3/$slot" && + cgit_ok freshrc "url=fresh/log/" >fresh.out && + test_grep "a newer commit" fresh.out && + tr "\000" "\n" <"cache3/$slot" >slot.txt && + test_grep "a newer commit" slot.txt +' + +# A negative ttl never expires, however old the slot, which the line +# appended to it shows by being served. +test_expect_success 'a negative page ttl never expires the slot' ' + rm -rf cache3 && mkdir cache3 && + { + echo "cache-dynamic-ttl=-1" && + cat bigkeyrc + } >neverrc && + cgit_ok neverrc "url=bigpage/log/" >/dev/null && + slot=$(ls cache3) && + echo "the kept copy" >>"cache3/$slot" && + touch -t 200001010000 "cache3/$slot" && + cgit_ok neverrc "url=bigpage/log/" >never.out && + test_grep "the kept copy" never.out +' + # The summary page keeps a ttl of its own, while every other page that follows # a branch rather than a pinned id takes cache-dynamic-ttl, whether or not its # url names the branch. |
