diff options
Diffstat (limited to 'tests/t0003-cache.sh')
| -rwxr-xr-x | tests/t0003-cache.sh | 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 38 insertions, 0 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index bd186e7..06cdd99 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -79,6 +79,21 @@ test_expect_success 'set up a repo with a page larger than the output buffer' ' rm -rf cache2 && mkdir cache2 ' +# The second request lands while the first is inside its filter, which says +# so through a marker file, since a fresh binary can take a moment to start. +overlap_requests() { + n=0 + rm -f filter-running + CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/about/" cgit >first.out 2>first.err & + while ! test -f filter-running && test $n -lt 10 + do + sleep 1 + n=$((n + 1)) + done + CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/log/" cgit >second.out 2>second.err + wait +} + bigpage_query() { CGIT_CONFIG="$PWD/bigrc" QUERY_STRING="$1" cgit } @@ -243,4 +258,27 @@ test_expect_success 'a failed final write still delivers the page' ' ! grep "called many times" flush.err ' +# The fill writes the page into the lock file through stdout, and an exec +# filter puts its own pipe on stdout while it runs. The slot lock has to +# outlast that, or a second request on the slot rebuilds it under the first +# and the first visitor gets the two pages spliced together. +test_expect_success 'a slot stays locked while an exec filter runs' ' + rm -rf cache3 && mkdir cache3 && + write_script slow-filter.sh <<-EOF && + touch "$PWD/filter-running" + sleep 3 + cat + EOF + { + echo "cache-size=1" && + sed "/^cache-size=/d" bigkeyrc && + echo "repo.readme=:file-1" && + echo "repo.about-filter=exec:$PWD/slow-filter.sh" + } >lockrc && + overlap_requests && + test $(grep -c "^Status:" first.out) = 1 && + grep "id=.about." first.out && + ! grep "Unable to publish" first.err +' + test_done |
