Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit c368ef3

Browse files
committed
Resolve flaky system test for counting image-rewrites on bursts of
requests by allowing 1 or 2 rewrites, instead of requiring 1. Put in comment explaining that this is due to 'best effort' locks.
1 parent b905d75 commit c368ef3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pagespeed/system/system_test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,12 @@ if [ $statistics_enabled = "1" ]; then
528528
URL=""
529529
AUTH=""
530530

531-
start_test A burst of image requests should yield only one rewrite.
531+
# Ideally the system should only rewrite an image once when when it gets
532+
# a burst of requests. A bug was fixed where we were not obeying a
533+
# failed lock and were rewriting it potentially many times. It still
534+
# happens fairly often that we rewrite the image twice. I am not sure
535+
# why that is, except to observe that our locks are 'best effort'.
536+
start_test A burst of image requests should yield only one two rewrites.
532537
URL="$EXAMPLE_ROOT/images/Puzzle.jpg?a=$RANDOM"
533538
start_image_rewrites=$(scrape_stat image_rewrites)
534539
echo Running burst of 20x: \"wget -q -O - $URL '|' wc -c\"
@@ -537,8 +542,8 @@ if [ $statistics_enabled = "1" ]; then
537542
done
538543
echo "... done"
539544
sleep 1
540-
end_image_rewrites=$(scrape_stat image_rewrites)
541-
check [ $end_image_rewrites = $((start_image_rewrites + 1)) ]
545+
num_image_rewrites=$(($(scrape_stat image_rewrites) - start_image_rewrites))
546+
check [ $num_image_rewrites = 1 -o $num_image_rewrites = 2 ]
542547
URL=""
543548
fi
544549

0 commit comments

Comments
 (0)