diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep clone files and oversized responses out of the cache
The dumb transport reads files that already sit on the disk, so a pack
copied into a slot cost that disk twice and the request a second write
of every byte. A snapshot took a slot whatever its size, so a visitor
naming distinct refs and ids could fill the cache root with archives.
`cache-max-slot-size`, 64 MB unless set, now serves a larger response
from the lock file and drops it, along with any expired copy it would
have replaced.
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0003-cache.sh | 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 43 insertions, 0 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index d3e448f..3e2a971 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -169,4 +169,47 @@ test_expect_success 'an error page leaves no slot behind' ' test_line_count = 0 error.slots ' +# The dumb transport serves files that already sit on the disk, so a copy in +# a slot would only double the disk they take. +test_expect_success 'a clone file leaves no slot behind' ' + rm -rf cache3 && mkdir cache3 && + CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/info/refs" cgit >clone.out && + grep "refs/heads/master" clone.out && + CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/objects/info/packs" cgit >packs.out && + grep "^Status: 200" packs.out && + ls cache3 >clone.slots && + test_line_count = 0 clone.slots +' + +# A response past cache-max-slot-size is served whole but kept nowhere, both +# on a first fill and when it would have replaced an expired slot, which is +# dropped along with it. The summary page stays under the limit set here +# while the big blob page is well past it. +test_expect_success 'a response over cache-max-slot-size is served but not kept' ' + rm -rf cache3 && mkdir cache3 && + { + echo "cache-max-slot-size=32" && + cat bigkeyrc + } >slotsizerc && + CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.unkept && + tail -c 200 big.unkept | grep "</html>" && + ls cache3 >unkept.slots && + test_line_count = 0 unkept.slots && + CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/" cgit >/dev/null && + ls cache3 >kept.slots && + test_line_count = 1 kept.slots +' + +test_expect_success 'an expired slot is dropped when its refill is too large' ' + rm -rf cache3 && mkdir cache3 && + CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >/dev/null && + ls cache3 >filled.slots && + test_line_count = 1 filled.slots && + touch -t 200001010000 cache3/* && + CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.refill && + tail -c 200 big.refill | grep "</html>" && + ls cache3 >refill.slots && + test_line_count = 0 refill.slots +' + test_done |
