diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-08-24 20:31:46 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-08-24 20:31:46 +0000 |
commit | 1f1d8355ad73eb9c0ab9aaeb069a21aecee78d6f (patch) | |
tree | 18894ab96968faa022dbd156c66ac1fb0df2e2ba | |
parent | 6f05cd831394335c32c6eebc4f4da7454302bbc9 (diff) |
Fix timing issue with bbackupd test for recovery after error.
For some reason the timing changed and the test was no longer waiting for the
same length of time as bbackupd, causing it to fail.
Merged back changes from the test refactor branch to reduce diffs.
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 10 | ||||
-rw-r--r-- | lib/backupstore/BackupConstants.h | 3 | ||||
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 28 |
3 files changed, 25 insertions, 16 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index bb022e44..0fca634c 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -61,6 +61,7 @@ #include "BackupClientFileAttributes.h" #include "BackupClientInodeToIDMap.h" #include "BackupClientMakeExcludeList.h" +#include "BackupConstants.h" #include "BackupDaemon.h" #include "BackupDaemonConfigVerify.h" #include "BackupStoreConstants.h" @@ -574,6 +575,7 @@ void BackupDaemon::Run2() box_time_t currentTime = GetCurrentBoxTime(); box_time_t requiredDelay = (mNextSyncTime < currentTime) ? (0) : (mNextSyncTime - currentTime); + mNextSyncTime = currentTime + requiredDelay; if (mDoSyncForcedByPreviousSyncError) { @@ -670,7 +672,7 @@ void BackupDaemon::Run2() if(d > 0) { // Script has asked for a delay - mNextSyncTime = GetCurrentBoxTime() + + mNextSyncTime = GetCurrentBoxTime() + SecondsToBoxTime(d); BOX_INFO("Impending backup stopped by " "SyncAllowScript, next attempt " @@ -779,9 +781,9 @@ void BackupDaemon::RunSyncNowWithExceptionHandling() " " << errorCode << "/" << errorSubCode << "), reset state and waiting to retry..."); ::sleep(10); - mNextSyncTime = mCurrentSyncStartTime + - SecondsToBoxTime(100) + - Random::RandomInt(mUpdateStoreInterval >> + mNextSyncTime = GetCurrentBoxTime() + + SecondsToBoxTime(BACKUP_ERROR_RETRY_SECONDS) + + Random::RandomInt(mUpdateStoreInterval >> SYNC_PERIOD_RANDOM_EXTRA_TIME_SHIFT_BY); } } diff --git a/lib/backupstore/BackupConstants.h b/lib/backupstore/BackupConstants.h index 19d06a15..195dc621 100644 --- a/lib/backupstore/BackupConstants.h +++ b/lib/backupstore/BackupConstants.h @@ -13,6 +13,9 @@ // 15 minutes to timeout (milliseconds) #define BACKUP_STORE_TIMEOUT (15*60*1000) +// Time to wait for retry after a backup error +#define BACKUP_ERROR_RETRY_SECONDS 100 + // Should the store daemon convert files to Raid immediately? #define BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY true diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 3927c74d..bd648957 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -2756,10 +2756,12 @@ int test_bbackupd() TEST_THAT(close(fd1) == 0); } - // bbackupd should pause for about 90 seconds from - // store_fixed_time, so check that it hasn't run after - // 85 seconds after store_fixed_time - wait_for_operation(85 - time(NULL) + store_fixed_time, + // bbackupd should pause for BACKUP_ERROR_RETRY_SECONDS (plus + // a random delay of up to mUpdateStoreInterval/64 or 0.05 + // extra seconds) from store_fixed_time, so check that it + // hasn't run just before this time + wait_for_operation(BACKUP_ERROR_RETRY_SECONDS + + (store_fixed_time - time(NULL)) - 1, "just before bbackupd recovers"); TEST_THAT(!TestFileExists("testfiles/" "notifyran.backup-start.wait-snapshot.1")); @@ -2767,8 +2769,8 @@ int test_bbackupd() // Should not have backed up, should still get errors TEST_COMPARE(Compare_Different); - // wait another 10 seconds, bbackup should have run - wait_for_operation(10, "bbackupd to recover"); + // wait another 2 seconds, bbackup should have run + wait_for_operation(2, "bbackupd to recover"); TEST_THAT(TestFileExists("testfiles/" "notifyran.backup-start.wait-snapshot.1")); @@ -2839,10 +2841,12 @@ int test_bbackupd() TEST_THAT(close(fd1) == 0); } - // bbackupd should pause for about 90 seconds from - // store_fixed_time, so check that it hasn't run after - // 85 seconds from store_fixed_time - wait_for_operation(85 - time(NULL) + store_fixed_time, + // bbackupd should pause for BACKUP_ERROR_RETRY_SECONDS (plus + // a random delay of up to mUpdateStoreInterval/64 or 0.05 + // extra seconds) from store_fixed_time, so check that it + // hasn't run just before this time + wait_for_operation(BACKUP_ERROR_RETRY_SECONDS + + (store_fixed_time - time(NULL)) - 1, "just before bbackupd recovers"); TEST_THAT(!TestFileExists("testfiles/" "notifyran.backup-start.wait-automatic.1")); @@ -2850,8 +2854,8 @@ int test_bbackupd() // Should not have backed up, should still get errors TEST_COMPARE(Compare_Different); - // wait another 10 seconds, bbackup should have run - wait_for_operation(10, "bbackupd to recover"); + // wait another 2 seconds, bbackup should have run + wait_for_operation(2, "bbackupd to recover"); TEST_THAT(TestFileExists("testfiles/" "notifyran.backup-start.wait-automatic.1")); |