diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Bound the search and cache key a request can ask
Diffstat (limited to 'tests/t0020-validate-cache.sh')
| -rwxr-xr-x | tests/t0020-validate-cache.sh | 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 21 insertions, 0 deletions
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh index 7e6334c..510e51c 100755 --- a/tests/t0020-validate-cache.sh +++ b/tests/t0020-validate-cache.sh @@ -124,4 +124,25 @@ test_expect_success 'the page ends where it should, so nothing was dropped' ' tail -c 200 big.second.body | grep "</html>" ' +# --- A key too long to read back must not claim a slot ---------------------- +# A slot stores its key ahead of the content and only the first few kilobytes +# are read back, so a longer key could never match. Such a request used to +# write a slot on every visit that no later request could ever use. +test_expect_success 'an over-long cache key leaves no slot behind' ' + rm -rf cache3 && mkdir cache3 && + sed -e "s|^cache-root=.*|cache-root=$PWD/cache3|" bigrc >bigkeyrc && + long=$(awk "BEGIN{s=\"\";for(i=0;i<6000;i++)s=s \"k\"; print s}") && + CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/&q=$long" cgit >key.out 2>key.err && + grep "</html>" key.out && + ls cache3 >key.slots && + test_line_count = 0 key.slots +' + +test_expect_success 'an ordinary key still fills a slot' ' + rm -rf cache3 && mkdir cache3 && + CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/" cgit >/dev/null && + ls cache3 >key.slots && + test_line_count = 1 key.slots +' + test_done |
