Delete Archived Test Result

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.

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.

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]strpos($testPath, ‘relay’) !== false[/php] 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]if( strpos($testPath, ‘results’) !== false
&& strpos($testPath, ‘relay’) !== false
&& strpos($testPath, ‘…’) === false
&& is_dir($testPath) ) [/php]

Thanks

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.