Make test_0202_app_launch_apply_update_dirlocked.js as similar as possible to test_0202_app_launch_apply_update_dirlocked_svc.js - Bug 909489 - Intermittent test_0202_app_launch_apply_update_dirlocked.js | Test timed out | test failed (with xpcshell return code: 1). r=bbondy

This commit is contained in:
Robert Strong 2013-09-05 12:19:33 -07:00
Родитель 18abd9b1af
Коммит c6db33c01c
9 изменённых файлов: 70 добавлений и 94 удалений

Просмотреть файл

@ -111,6 +111,12 @@ var gDisableReplaceFallback = false;
// Time to wait for the test helper process before continuing the test
const TEST_HELPER_TIMEOUT = 100;
// Time to wait for a check in the test before continuing the test
const TEST_CHECK_TIMEOUT = 100;
// How many of TEST_CHECK_TIMEOUT to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Use a copy of the main application executable for the test to avoid main
// executable in use errors.
const FILE_WIN_TEST_EXE = "_aus_test_app.exe";
@ -1597,6 +1603,9 @@ function removeUpdater() {
return;
}
}
else {
logTestInfo("updater doesn't exist, path: " + updater.path);
}
}
logTestInfo("calling do_test_finished");
do_test_finished();
@ -1628,7 +1637,7 @@ function waitForFilesInUse() {
logTestInfo("file is not in use. path: " + file.path);
}
catch (e) {
logTestInfo("file in use, will try again after " + CHECK_TIMEOUT_MILLI +
logTestInfo("file in use, will try again after " + TEST_CHECK_TIMEOUT +
" ms, path: " + file.path + ", exception: " + e);
try {
if (fileBak.exists()) {
@ -1639,7 +1648,7 @@ function waitForFilesInUse() {
logTestInfo("unable to remove file, this should never happen! " +
"path: " + fileBak.path + ", exception: " + e);
}
do_timeout(CHECK_TIMEOUT_MILLI, waitForFilesInUse);
do_timeout(TEST_CHECK_TIMEOUT, waitForFilesInUse);
return;
}
}
@ -2305,7 +2314,7 @@ let gProcessObserver = {
if (topic != "process-finished" || gProcess.exitValue != 0) {
do_throw("Failed to launch application");
}
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
},
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
};

Просмотреть файл

@ -15,12 +15,6 @@ const TEST_ID = "0200";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 120000;
@ -235,7 +229,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates log to " +
"be created at " + log.path);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -246,7 +240,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates status " +
"to not be pending or applying, current status is: " + status);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -263,7 +257,7 @@ function checkUpdateFinished() {
"rename " + FILE_UPDATE_LOG + " to " + FILE_UPDATE_LOG +
".bak. Path: " + log.path);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -293,7 +287,7 @@ function restoreLogFile() {
"rename " + FILE_UPDATE_LOG + ".bak back to " + FILE_UPDATE_LOG +
". Path: " + log.path);
else
do_timeout(CHECK_TIMEOUT_MILLI, restoreLogFile);
do_timeout(TEST_CHECK_TIMEOUT, restoreLogFile);
return;
}
@ -350,7 +344,7 @@ function checkLogRenameFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update log to " +
"be renamed to last-update.log at " + log.path);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkLogRenameFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkLogRenameFinished);
return;
}

Просмотреть файл

@ -18,12 +18,6 @@ const TEST_ID = "0201";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 120000;
@ -230,7 +224,7 @@ function checkUpdateApplied() {
"applied, current state is: " +
gUpdateManager.activeUpdate.state);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -255,7 +249,7 @@ function checkUpdateApplied() {
}
log.append(FILE_LAST_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -353,7 +347,7 @@ function checkUpdateApplied() {
do_check_false(updatesDir.exists());
// Now, switch the updated version of the app
do_timeout(CHECK_TIMEOUT_MILLI, switchApp);
do_timeout(TEST_CHECK_TIMEOUT, switchApp);
}
/**
@ -370,7 +364,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for state to " +
"change to succeeded, current status: " + status);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
} catch (e) {
@ -387,7 +381,7 @@ function checkUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);
@ -406,7 +400,7 @@ function checkUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for update dir to not exist");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}

Просмотреть файл

@ -24,10 +24,8 @@ const TEST_ID = "0202";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
let gActiveUpdate;
let gTimeoutRuns = 0;
function run_test() {
if (APP_BIN_NAME == "xulrunner") {
@ -109,10 +107,6 @@ function run_test() {
let mar = do_get_file("data/simple.mar");
mar.copyTo(updatesPatchDir, FILE_UPDATE_ARCHIVE);
reloadUpdateManagerData();
gActiveUpdate = gUpdateManager.activeUpdate;
do_check_true(!!gActiveUpdate);
// Backup the updater.ini file if it exists by moving it. This prevents the
// post update executable from being launched if it is specified.
let updaterIni = processDir.clone();
@ -131,28 +125,27 @@ function run_test() {
updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
reloadUpdateManagerData();
gActiveUpdate = gUpdateManager.activeUpdate;
do_check_true(!!gActiveUpdate);
setEnvironment();
// Initiate a background update.
logTestInfo("update preparation completed - calling processUpdate");
AUS_Cc["@mozilla.org/updates/update-processor;1"].
createInstance(AUS_Ci.nsIUpdateProcessor).
processUpdate(gActiveUpdate);
resetEnvironment();
logTestInfo("processUpdate completed - calling checkUpdateApplied");
checkUpdateApplied();
}
function end_test() {
logTestInfo("start - test cleanup");
// Remove the files added by the update.
let updateTestDir = getUpdateTestDir();
try {
logTestInfo("removing update test directory " + updateTestDir.path);
removeDirRecursive(updateTestDir);
}
catch (e) {
logTestInfo("unable to remove directory - path: " + updateTestDir.path +
", exception: " + e);
}
resetEnvironment();
let processDir = getAppDir();
// Restore the backup of the updater.ini if it exists.
@ -169,6 +162,17 @@ function end_test() {
updateSettingsIni.moveTo(processDir, FILE_UPDATE_SETTINGS_INI);
}
// Remove the files added by the update.
let updateTestDir = getUpdateTestDir();
try {
logTestInfo("removing update test directory " + updateTestDir.path);
removeDirRecursive(updateTestDir);
}
catch (e) {
logTestInfo("unable to remove directory - path: " + updateTestDir.path +
", exception: " + e);
}
if (IS_UNIX) {
// This will delete the launch script if it exists.
getLaunchScript();
@ -207,12 +211,17 @@ function getUpdateTestDir() {
function checkUpdateApplied() {
// Don't proceed until the update has failed, and reset to pending.
if (gUpdateManager.activeUpdate.state != STATE_PENDING) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for pending state to finish");
else
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
logTestInfo("update state equals " + gUpdateManager.activeUpdate.state);
do_timeout(TEST_CHECK_TIMEOUT, finishTest);
}
function finishTest() {
// Don't proceed until the update status is pending.
let status = readStatusFile();
do_check_eq(status, STATE_PENDING);

Просмотреть файл

@ -24,12 +24,6 @@ const TEST_ID = "0203";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 120000;
@ -258,7 +252,7 @@ function checkUpdateApplied() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update to be " +
"applied, current state is: " + gUpdateManager.activeUpdate.state);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -283,7 +277,7 @@ function checkUpdateApplied() {
}
log.append(FILE_LAST_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -381,7 +375,7 @@ function checkUpdateApplied() {
do_check_false(updatesDir.exists());
// Now, switch the updated version of the app
do_timeout(CHECK_TIMEOUT_MILLI, switchApp);
do_timeout(TEST_CHECK_TIMEOUT, switchApp);
}
/**
@ -398,7 +392,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for state to " +
"change to succeeded, current status: " + status);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
} catch (e) {
@ -415,7 +409,7 @@ function checkUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);
@ -431,7 +425,7 @@ function checkUpdateFinished() {
updatedDir.append(UPDATED_DIR_SUFFIX.replace("/", ""));
logTestInfo("testing " + updatedDir.path + " shouldn't exist");
if (updatedDir.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}

Просмотреть файл

@ -15,12 +15,6 @@ const TEST_ID = "0200_svc";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
let gTimeoutRuns = 0;
function run_test() {
@ -191,7 +185,7 @@ function checkUpdateFinished() {
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates log to be created at " + log.path);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}

Просмотреть файл

@ -18,12 +18,6 @@ const TEST_ID = "0201_svc";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 120000;
@ -236,7 +230,7 @@ function checkUpdateApplied() {
"applied, current state is: " +
gUpdateManager.activeUpdate.state);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -255,7 +249,7 @@ function checkUpdateApplied() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update log to " +
"be created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -334,7 +328,7 @@ function checkUpdateApplied() {
do_check_false(updatesDir.exists());
// Now, switch the updated version of the app
do_timeout(CHECK_TIMEOUT_MILLI, switchApp);
do_timeout(TEST_CHECK_TIMEOUT, switchApp);
}
/**
@ -351,7 +345,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for state to " +
"change to succeeded, current status: " + status);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
} catch (e) {
@ -368,7 +362,7 @@ function checkUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);

Просмотреть файл

@ -24,12 +24,6 @@ const TEST_ID = "0202_svc";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
let gActiveUpdate;
let gTimeoutRuns = 0;
@ -202,11 +196,11 @@ function checkUpdateApplied() {
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for pending state to finish");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
do_timeout(CHECK_TIMEOUT_MILLI, finishTest);
do_timeout(TEST_CHECK_TIMEOUT, finishTest);
}
function finishTest() {

Просмотреть файл

@ -24,12 +24,6 @@ const TEST_ID = "0203_svc";
// launching a post update executable.
const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 120000;
@ -261,7 +255,7 @@ function checkUpdateApplied() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update to be " +
"applied, current state is: " + gUpdateManager.activeUpdate.state);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -280,7 +274,7 @@ function checkUpdateApplied() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for update log to be " +
"created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -359,7 +353,7 @@ function checkUpdateApplied() {
do_check_false(updatesDir.exists());
// Now, switch the updated version of the app
do_timeout(CHECK_TIMEOUT_MILLI, switchApp);
do_timeout(TEST_CHECK_TIMEOUT, switchApp);
}
/**
@ -376,7 +370,7 @@ function checkUpdateFinished() {
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for state to " +
"change to succeeded, current status: " + status);
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
} catch (e) {
@ -394,7 +388,7 @@ function checkUpdateFinished() {
else
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);