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

Commit d1972f6

Browse files
jmarantzcrowell
authored andcommitted
Test purging of ipro-rewritten resources. This previously worked in (#1306)
Apache, but only today was fixed in ngx_pagespeed on 5/11/16, in apache/incubator-pagespeed-ngx#1193 To test a fix to this bug, I need to alter files in the htdocs directory during the test. This is source-controlled. We were doing this before with mod_pagespeed_test/cache_flush but somehow getting away with it (or just getting lucky with timing). But this is really a bad practice. So in this pull-request I also change the infrastructure to simply copy the cache_flush/ and purge/ subdirectories to htdocs/. The rest of the directories get symlinked. This must be committed alongside apache/incubator-pagespeed-ngx#1197 Use full paths in ln -s and in cp -r, rather than using the cd-command-chain. (#1309) More Makefile.tests changes that didn't make it into the last git commit. setup the doc root before running vm_system_tests. (#1310)
1 parent 1ff43e1 commit d1972f6

File tree

4 files changed

+56
-15
lines changed

4 files changed

+56
-15
lines changed

install/Makefile.tests

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export APACHE_DEBUG_PAGESPEED_CONF
3939
export APACHE_LOG
4040
export MOD_PAGESPEED_CACHE
4141

42-
apache_vm_system_tests :
42+
apache_vm_system_tests : setup_doc_root
4343
$(MAKE) FAST_RESTART=1 apache_debug_smoke_test
4444
$(MAKE) FAST_RESTART=1 apache_debug_downstream_caching_test
4545
$(MAKE) FAST_RESTART=1 apache_debug_per_vhost_stats_test
@@ -454,3 +454,22 @@ apache_debug_unplugged_test : apache_install_conf apache_debug_restart
454454
mv $(APACHE_DEBUG_PAGESPEED_CONF).save $(APACHE_DEBUG_PAGESPEED_CONF)
455455
$(MAKE) apache_debug_stop
456456
@echo PASS
457+
458+
# Target used to populate the docroot for a webserver, including the
459+
# read-only mod_pagespeed_example, mod_pagespeed_test, and do_not_modify,
460+
# plus the read/write areas for cache purging and flush tests. The
461+
# read-only directories are symlinked in for speed, and the read/write
462+
# directories are deep-copied, but they are small.
463+
setup_doc_root :
464+
mkdir -p $(APACHE_DOC_ROOT)
465+
ln -Tsf "$(realpath $(INSTALL_DATA_DIR))/mod_pagespeed_example" \
466+
$(APACHE_DOC_ROOT)/mod_pagespeed_example
467+
ln -Tsf "$(realpath $(INSTALL_DATA_DIR))/mod_pagespeed_test" \
468+
$(APACHE_DOC_ROOT)/mod_pagespeed_test
469+
ln -Tsf "$(realpath $(INSTALL_DATA_DIR))/do_not_modify" \
470+
$(APACHE_DOC_ROOT)/do_not_modify
471+
rm -rf "$(APACHE_DOC_ROOT)/cache_flush"
472+
cp -r "$(INSTALL_DATA_DIR)/mod_pagespeed_test/cache_flush" \
473+
$(APACHE_DOC_ROOT)
474+
rm -rf "$(APACHE_DOC_ROOT)/purge"
475+
cp -r "$(INSTALL_DATA_DIR)/mod_pagespeed_test/purge" $(APACHE_DOC_ROOT)

install/debug.conf.template

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ ModPagespeedCompressMetadataCache true
430430

431431
# Make a non-empty subdirectory config to make sure that
432432
# cache.flush updates get transmitted to nested configurations.
433-
<Directory "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/cache_flush/" >
433+
<Directory "@@APACHE_DOC_ROOT@@/cache_flush/" >
434434
ModPagespeedRewriteLevel PassThrough
435435
ModPagespeedEnableFilters inline_css
436436
ModPagespeedDisableFilters add_instrumentation
@@ -479,7 +479,7 @@ NameVirtualHost localhost:@@APACHE_SECONDARY_PORT@@
479479

480480
# Make a non-empty subdirectory config to make sure that
481481
# cache.flush updates get transmitted to nested configurations.
482-
<Directory "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/cache_flush/" >
482+
<Directory "@@APACHE_DOC_ROOT@@/cache_flush/" >
483483
ModPagespeedRewriteLevel PassThrough
484484
ModPagespeedEnableFilters inline_css
485485
ModPagespeedDisableFilters add_instrumentation
@@ -1284,7 +1284,7 @@ ModPagespeedCreateSharedMemoryMetadataCache "@@MOD_PAGESPEED_CACHE@@_noned_shmm"
12841284
ModPagespeedEnableCachePurge on
12851285

12861286
ModPagespeedPurgeMethod PURGE
1287-
DocumentRoot "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/purge"
1287+
DocumentRoot "@@APACHE_DOC_ROOT@@/purge"
12881288
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_purge"
12891289
ModPagespeedDisableFilters add_instrumentation
12901290
ModPagespeedRewriteLevel PassThrough
@@ -1295,15 +1295,15 @@ ModPagespeedCreateSharedMemoryMetadataCache "@@MOD_PAGESPEED_CACHE@@_noned_shmm"
12951295
# back on.
12961296
<VirtualHost localhost:@@APACHE_SECONDARY_PORT@@>
12971297
ServerName psoff-dir-on.example.com
1298-
DocumentRoot "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/purge"
1298+
DocumentRoot "@@APACHE_DOC_ROOT@@/purge"
12991299
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_mpsoff_dir_on"
13001300
ModPagespeed off
13011301
ModPagespeedEnableCachePurge on
13021302
ModPagespeedPurgeMethod PURGE
13031303
ModPagespeedDisableFilters add_instrumentation
13041304
ModPagespeedRewriteLevel PassThrough
13051305
ModPagespeedEnableFilters rewrite_css
1306-
<Directory "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/purge">
1306+
<Directory "@@APACHE_DOC_ROOT@@/purge">
13071307
ModPagespeed on
13081308
</Directory>
13091309
</VirtualHost>
@@ -1312,15 +1312,15 @@ ModPagespeedCreateSharedMemoryMetadataCache "@@MOD_PAGESPEED_CACHE@@_noned_shmm"
13121312
# back on.
13131313
<VirtualHost localhost:@@APACHE_SECONDARY_PORT@@>
13141314
ServerName psoff-htaccess-on.example.com
1315-
DocumentRoot "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/purge"
1315+
DocumentRoot "@@APACHE_DOC_ROOT@@/purge"
13161316
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_mpsoff_htaccess_on"
13171317
ModPagespeed off
13181318
ModPagespeedEnableCachePurge on
13191319
ModPagespeedPurgeMethod PURGE
13201320
ModPagespeedDisableFilters add_instrumentation
13211321
ModPagespeedRewriteLevel PassThrough
13221322
ModPagespeedEnableFilters rewrite_css
1323-
<Directory "@@APACHE_DOC_ROOT@@/mod_pagespeed_test/purge">
1323+
<Directory "@@APACHE_DOC_ROOT@@/purge">
13241324
AllowOverride All
13251325
</Directory>
13261326
</VirtualHost>

pagespeed/apache/system_test.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ if [ "$CACHE_FLUSH_TEST" = "on" ]; then
5353

5454
# To fetch from the secondary test root, we must set
5555
# http_proxy=${SECONDARY_HOSTNAME} during fetches.
56-
SECONDARY_TEST_ROOT=http://secondary.example.com/mod_pagespeed_test
56+
SECONDARY_ROOT="http://secondary.example.com"
57+
SECONDARY_TEST_ROOT="$SECONDARY_ROOT/mod_pagespeed_test"
5758
else
5859
# Force the variable to be set albeit blank so tests don't fail.
5960
: ${SECONDARY_HOSTNAME:=}
@@ -392,8 +393,8 @@ if [ "$CACHE_FLUSH_TEST" = "on" ]; then
392393
echo http_proxy=$SECONDARY_HOSTNAME $WGET -O $WGET_OUTPUT $URL
393394
http_proxy=$SECONDARY_HOSTNAME $WGET -O $WGET_OUTPUT $URL
394395
check [ $(grep -o "<script" $WGET_OUTPUT|wc -l) = 3 ]
395-
check [ $(grep -c "pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'beforeunload', '', 'http://secondary.example.com/mod_pagespeed_test/add_instrumentation.html');" $WGET_OUTPUT) = 1 ]
396-
check [ $(grep -c "pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'load', '', 'http://secondary.example.com/mod_pagespeed_test/add_instrumentation.html');" $WGET_OUTPUT) = 1 ]
396+
check [ $(grep -c "pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'beforeunload', '', '$SECONDARY_TEST_ROOT/add_instrumentation.html');" $WGET_OUTPUT) = 1 ]
397+
check [ $(grep -c "pagespeed.addInstrumentationInit('/$BEACON_HANDLER', 'load', '', '$SECONDARY_TEST_ROOT/add_instrumentation.html');" $WGET_OUTPUT) = 1 ]
397398

398399
if [ "$NO_VHOST_MERGE" = "on" ]; then
399400
start_test When ModPagespeedMaxHtmlParseBytes is not set, we do not insert \
@@ -426,7 +427,7 @@ if [ "$CACHE_FLUSH_TEST" = "on" ]; then
426427
$SUDO touch ${MOD_PAGESPEED_CACHE}_ipro_for_browser/cache.flush
427428
sleep 1
428429

429-
CACHE_TESTING_DIR="$APACHE_DOC_ROOT/mod_pagespeed_test/cache_flush/"
430+
CACHE_TESTING_DIR="$APACHE_DOC_ROOT/cache_flush"
430431
CACHE_TESTING_TMPDIR="$CACHE_TESTING_DIR/$$"
431432
echo $SUDO mkdir "$CACHE_TESTING_TMPDIR"
432433
$SUDO mkdir "$CACHE_TESTING_TMPDIR"
@@ -435,7 +436,7 @@ if [ "$CACHE_FLUSH_TEST" = "on" ]; then
435436
$SUDO cp "$CACHE_TESTING_DIR/cache_flush_test.html" "$CACHE_TESTING_TMPDIR/"
436437
CSS_FILE="$CACHE_TESTING_TMPDIR/update.css"
437438
URL_PATH=cache_flush/$$/cache_flush_test.html
438-
URL=$TEST_ROOT/$URL_PATH
439+
URL="$PRIMARY_SERVER/$URL_PATH"
439440
TMP_CSS_FILE=$TESTTMP/update.css
440441

441442
# First, write color 0 into the css file and make sure it gets inlined into
@@ -448,7 +449,7 @@ if [ "$CACHE_FLUSH_TEST" = "on" ]; then
448449

449450
# Also do the same experiment using a different VirtualHost. It points
450451
# to the same htdocs, but uses a separate cache directory.
451-
SECONDARY_URL=$SECONDARY_TEST_ROOT/$URL_PATH
452+
SECONDARY_URL="$SECONDARY_ROOT/$URL_PATH"
452453
http_proxy=$SECONDARY_HOSTNAME fetch_until $SECONDARY_URL "grep -c $COLOR0" 1
453454

454455
# Track how many flushes were noticed by Apache processes up till
@@ -1004,7 +1005,7 @@ check_from "$OUT" fgrep -q "$CONTENTS"
10041005

10051006
function scrape_secondary_stat {
10061007
http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
1007-
http://secondary.example.com/mod_pagespeed_statistics/ | \
1008+
"$SECONDARY_ROOT/mod_pagespeed_statistics/" | \
10081009
scrape_pipe_stat "$1"
10091010
}
10101011

pagespeed/system/system_test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ mkdir -p $OUTDIR
4747
# NO_VHOST_MERGE to "on".
4848
NO_VHOST_MERGE="${NO_VHOST_MERGE:-off}"
4949

50+
SUDO=${SUDO:-}
51+
5052
start_test Check for correct default pagespeed header format.
5153
# This will be X-Page-Speed in nginx and X-ModPagespeed in apache. Accept both.
5254
OUT=$($WGET_DUMP $EXAMPLE_ROOT/combine_css.html)
@@ -2162,6 +2164,7 @@ function cache_purge_test() {
21622164
echo $CURL --request PURGE --proxy $SECONDARY_HOSTNAME "$PURGE_URL"
21632165
check $CURL --request PURGE --proxy $SECONDARY_HOSTNAME "$PURGE_URL"
21642166
fi
2167+
echo ""
21652168
if [ $statistics_enabled -eq "0" ]; then
21662169
# Without statistics, we have no mechanism to transmit state-changes
21672170
# from one Apache child process to another, and so each process must
@@ -2186,13 +2189,30 @@ function cache_purge_test() {
21862189
yellow_css=$(grep yellow.css $FETCH_UNTIL_OUTFILE | cut -d\" -f6)
21872190
blue_css=$(grep blue.css $FETCH_UNTIL_OUTFILE | cut -d\" -f6)
21882191

2192+
purple_path="styles/$$"
2193+
purple_url="$PURGE_ROOT/$purple_path/purple.css"
2194+
purple_dir="$APACHE_DOC_ROOT/purge/$purple_path"
2195+
ls -ld $APACHE_DOC_ROOT $APACHE_DOC_ROOT/purge
2196+
echo $SUDO mkdir -p "$purple_dir"
2197+
$SUDO mkdir -p "$purple_dir"
2198+
purple_file="$purple_dir/purple.css"
2199+
21892200
for method in $CACHE_PURGE_METHODS; do
21902201
echo Individual URL Cache Purging with $method
21912202
check_from "$(read_metadata_cache $yellow_css)" fgrep -q cache_ok:true
21922203
check_from "$(read_metadata_cache $blue_css)" fgrep -q cache_ok:true
2204+
echo 'body { background: MediumPurple; }' > "/tmp/purple.$$"
2205+
$SUDO mv "/tmp/purple.$$" "$purple_file"
2206+
http_proxy=$SECONDARY_HOSTNAME fetch_until "$purple_url" 'fgrep -c 9370db' 1
2207+
echo 'body { background: black; }' > "/tmp/purple.$$"
2208+
$SUDO mv "/tmp/purple.$$" "$purple_file"
2209+
21932210
cache_purge $method "*"
2211+
21942212
check_from "$(read_metadata_cache $yellow_css)" fgrep -q cache_ok:false
21952213
check_from "$(read_metadata_cache $blue_css)" fgrep -q cache_ok:false
2214+
http_proxy=$SECONDARY_HOSTNAME fetch_until "$purple_url" 'fgrep -c #000' 1
2215+
cache_purge "$method" "$purple_path/purple.css"
21962216

21972217
sleep 1
21982218
STATS=$OUTDIR/purge.stats
@@ -2224,6 +2244,7 @@ function cache_purge_test() {
22242244
http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $PURGE_STATS_URL > $STATS.3
22252245
check_stat $STATS.2 $STATS.3 num_resource_fetch_successes 1
22262246
done
2247+
$SUDO rm -rf "$purple_dir"
22272248
}
22282249

22292250
if [ "$CACHE_FLUSH_TEST" = "on" ]; then

0 commit comments

Comments
 (0)