Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archive and delete old, hanging, tests to avoid filling up disc space #1567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions www/cli/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// found in the LICENSE.md file.
chdir('..');
$MIN_DAYS = 2;
$MAX_DAYS = null;

require_once('common.inc');
require_once('archive.inc');
Expand All @@ -28,10 +29,13 @@
}

if (GetSetting('archive_days')) {
$MIN_DAYS = GetSetting('archive_days');
$MIN_DAYS = GetSetting('archive_days');
}
$MIN_DAYS = max($MIN_DAYS,0.1);
$MAX_DAYS = 30;

if (GetSetting('max_days_before_archive')) {
$MAX_DAYS = GetSetting('max_days_before_archive');
}

$archive_dir = null;
if (GetSetting('archive_dir')) {
Expand Down Expand Up @@ -277,14 +281,26 @@ function CheckTest($testPath, $id, $elapsedDays, $forced_only) {
global $kept;
global $log;
global $MIN_DAYS;
global $MAX_DAYS;
global $is_cli;
$logLine = "$id ($elapsedDays): ";

if ($is_cli)
echo "\rArc:$archiveCount, Del:$deleted, Kept:$kept, Checking:" . str_pad($id,45);

$delete = false;
if (is_file("$testPath/test.waiting")) {

if (isset($MAX_DAYS) && ($elapsedDays > $MAX_DAYS)) {
if (!is_file("$testPath/testinfo.ini") &&
!is_file("$testPath/testinfo.json.gz") &&
!is_file("$testPath/testinfo.json")) {
$delete = true;
$logLine .= " Invalid old test";
} else {
$needs_archive = true;
$logLine .= " Archiving old test";
}
} elseif (is_file("$testPath/test.waiting")) {
// Skip tests that are still queued
} elseif (is_file("$testPath/test.running")) {
// Skip tests that are still running
Expand All @@ -307,14 +323,15 @@ function CheckTest($testPath, $id, $elapsedDays, $forced_only) {
}
}
}
if ($needs_archive) {
if (ArchiveTest($id) ) {
$archiveCount++;
$logLine .= " Archived";
$delete = true;
} else {
$logLine .= " Failed to archive";
}
}

if ($needs_archive) {
if (ArchiveTest($id) ) {
$archiveCount++;
$logLine .= " Archived";
$delete = true;
} else {
$logLine .= " Failed to archive";
}
}

Expand Down
3 changes: 3 additions & 0 deletions www/settings/settings.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ maxNavigateCount=20
;Number of days to keep tests locally before archiving
;archive_days=2

;Number of days to wait for tests to successfully complete before archiving or deleting
;max_days_before_archive=30

;Run archive script hourly automatically as agents poll for work
;cron_archive=1

Expand Down