WebPagetest Forums
Delete Archived Test Result - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Delete Archived Test Result (/showthread.php?tid=11999)

Delete Archived Test Result - timmckenzie - 01-22-2013 10:26 AM

Hi Patrick,

We are running a private WPT/WPT Monitor network. We run a lot of tests per day, and have been using Archive.php to reduce the number of files, and total disk space used.

We want to be able to delete/purge specific tests, based on which site they have been run against.
I have looked at ./cli/purge.php and ./delete.php, but can't seem to figure out how they work. Also, they don't seem to be aware of archived tests.

Any suggestions would be greatly appreciated.

RE: Delete Archived Test Result - pmeenan - 01-23-2013 02:29 AM

You'll probably have to hack something up because I don't have anything that deletes archived tests. The easiest way would probably be to parse the test logs in logs/*, get the test ID's for everything you want to delete and then go to the archive directories and delete them (there is a helper function that will get you the full path to any archived test by test ID).

Alternatively you can walk the archive directory directly, extract the testinfo.json.gz (or testinfo.ini) from the zip, decide if it is one you want to delete and delete it.

RE: Delete Archived Test Result - timmckenzie - 01-25-2013 04:34 AM

Thanks for the reply,

I have added a DeleteArchive function in archive.ini, which is working well.

One thing that I am confused about is in delete.php. The if statement which decides whether or not to delete, what does the line
PHP Code:
strpos($testPath'relay') !== false 
do. When I call that on my box the test is never deleted because the 'relay' check always fails. I removed that line and code path goes into the IF statement.

PHP Code:
if( strpos($testPath'results') !== false
&& strpos($testPath'relay') !== false
&& strpos($testPath'..') === false
&& is_dir($testPath) ) 


RE: Delete Archived Test Result - pmeenan - 01-29-2013 01:56 AM

Not sure if it helps any but I have some code that I just put together to clean up the archives on webpagetest.org: http://webpagetest.googlecode.com/svn/trunk/www/webpagetest/cli/prunearchive.php

You'd probably want to modify a few things because right now it only deletes archived tests if they were flagged with an archive.dat (stored on a 2nd-level archive in my case) but it crawls the archives and extracts the test information from within each archived test and then decides if it should be deleted.

If you remove the $info_file check in the main loop and then adjust the logic inside of PruneTests right after the "// for now, only delete tests that were not priority 0 or that used an api key" comment to use whatever criteria you want it should be able to clean up tests based on arbitrary rules.