summaryrefslogtreecommitdiff
path: root/lib/backupstore
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2019-05-28 07:20:50 -0400
committerReinhard Tartler <siretart@tauware.de>2019-05-28 07:20:50 -0400
commit6017757bc079f4446aa77bc5c0855c52741280f4 (patch)
tree41bfcfc2aab37312ef73bf9b30867a235c8117f3 /lib/backupstore
parent1b839d11810d6202f9b6f41db8f0ec3197e6a867 (diff)
New upstream version 0.13~~git20190527.g039c4a1
Diffstat (limited to 'lib/backupstore')
-rw-r--r--lib/backupstore/BackupStoreCheck.cpp10
-rw-r--r--lib/backupstore/BackupStoreCheck2.cpp2
-rw-r--r--lib/backupstore/BackupStoreRefCountDatabase.cpp11
-rw-r--r--lib/backupstore/BackupStoreRefCountDatabase.h3
-rw-r--r--lib/backupstore/StoreTestUtils.cpp55
-rw-r--r--lib/backupstore/StoreTestUtils.h11
6 files changed, 75 insertions, 17 deletions
diff --git a/lib/backupstore/BackupStoreCheck.cpp b/lib/backupstore/BackupStoreCheck.cpp
index b53ebf6d..37e45b03 100644
--- a/lib/backupstore/BackupStoreCheck.cpp
+++ b/lib/backupstore/BackupStoreCheck.cpp
@@ -174,9 +174,17 @@ void BackupStoreCheck::Check()
try
{
+ // We should be able to load a reference to the old refcount database
+ // (read-only) at the same time that we have a reference to the new one
+ // (temporary) open but not yet committed.
std::auto_ptr<BackupStoreRefCountDatabase> apOldRefs =
BackupStoreRefCountDatabase::Load(account, false);
- mNumberErrorsFound += mapNewRefs->ReportChangesTo(*apOldRefs);
+
+ // If we have created a new lost+found directory (and thus allocated it a nonzero
+ // object ID) then it's not surprising that the previous refcount DB did not have
+ // a reference to this directory, and not an error, so ignore it.
+ mNumberErrorsFound += mapNewRefs->ReportChangesTo(*apOldRefs,
+ mLostAndFoundDirectoryID); // ignore_object_id
}
catch(BoxException &e)
{
diff --git a/lib/backupstore/BackupStoreCheck2.cpp b/lib/backupstore/BackupStoreCheck2.cpp
index 13831a09..3775cc4a 100644
--- a/lib/backupstore/BackupStoreCheck2.cpp
+++ b/lib/backupstore/BackupStoreCheck2.cpp
@@ -429,7 +429,7 @@ int64_t BackupStoreCheck::GetLostAndFoundDirID()
if(!mFixErrors)
{
// The result will never be used anyway if errors aren't being fixed
- return 1;
+ return 0;
}
// Load up the root directory
diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp
index b2ea1abd..86da0943 100644
--- a/lib/backupstore/BackupStoreRefCountDatabase.cpp
+++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp
@@ -347,17 +347,22 @@ bool BackupStoreRefCountDatabase::RemoveReference(int64_t ObjectID)
return (refcount > 0);
}
-int BackupStoreRefCountDatabase::ReportChangesTo(BackupStoreRefCountDatabase& rOldRefs)
+int BackupStoreRefCountDatabase::ReportChangesTo(BackupStoreRefCountDatabase& rOldRefs,
+ int64_t ignore_object_id)
{
int ErrorCount = 0;
int64_t MaxOldObjectId = rOldRefs.GetLastObjectIDUsed();
int64_t MaxNewObjectId = GetLastObjectIDUsed();
for (int64_t ObjectID = BACKUPSTORE_ROOT_DIRECTORY_ID;
- ObjectID < std::max(MaxOldObjectId, MaxNewObjectId);
+ ObjectID <= std::max(MaxOldObjectId, MaxNewObjectId);
ObjectID++)
{
- typedef BackupStoreRefCountDatabase::refcount_t refcount_t;
+ if(ObjectID == ignore_object_id)
+ {
+ continue;
+ }
+
refcount_t OldRefs = (ObjectID <= MaxOldObjectId) ?
rOldRefs.GetRefCount(ObjectID) : 0;
refcount_t NewRefs = (ObjectID <= MaxNewObjectId) ?
diff --git a/lib/backupstore/BackupStoreRefCountDatabase.h b/lib/backupstore/BackupStoreRefCountDatabase.h
index 915653a4..6c16516e 100644
--- a/lib/backupstore/BackupStoreRefCountDatabase.h
+++ b/lib/backupstore/BackupStoreRefCountDatabase.h
@@ -87,7 +87,8 @@ public:
void AddReference(int64_t ObjectID);
// RemoveReference returns false if refcount drops to zero
bool RemoveReference(int64_t ObjectID);
- int ReportChangesTo(BackupStoreRefCountDatabase& rOldRefs);
+ int ReportChangesTo(BackupStoreRefCountDatabase& rOldRefs,
+ int64_t ignore_object_id = 0);
private:
static std::string GetFilename(const BackupStoreAccountDatabase::Entry&
diff --git a/lib/backupstore/StoreTestUtils.cpp b/lib/backupstore/StoreTestUtils.cpp
index 2b773cb1..902552d5 100644
--- a/lib/backupstore/StoreTestUtils.cpp
+++ b/lib/backupstore/StoreTestUtils.cpp
@@ -54,7 +54,7 @@ bool delete_account()
}
std::vector<uint32_t> ExpectedRefCounts;
-int bbstored_pid = 0, bbackupd_pid = 0;
+int bbstored_pid = 0, bbackupd_pid = 0, s3simulator_pid = 0;
void set_refcount(int64_t ObjectID, uint32_t RefCount)
{
@@ -266,11 +266,11 @@ bool check_reference_counts()
return counts_ok;
}
-bool StartServer()
+bool StartServer(const std::string& daemon_args)
{
- bbstored_pid = StartDaemon(bbstored_pid,
- BBSTORED " " + bbstored_args + " testfiles/bbstored.conf",
- "testfiles/bbstored.pid");
+ const std::string& daemon_args_final(daemon_args.size() ? daemon_args : bbstored_args);
+ bbstored_pid = StartDaemon(bbstored_pid, BBSTORED " " + daemon_args_final +
+ " testfiles/bbstored.conf", "testfiles/bbstored.pid");
return bbstored_pid != 0;
}
@@ -282,11 +282,11 @@ bool StopServer(bool wait_for_process)
return result;
}
-bool StartClient(const std::string& bbackupd_conf_file)
+bool StartClient(const std::string& bbackupd_conf_file, const std::string& daemon_args)
{
- bbackupd_pid = StartDaemon(bbackupd_pid,
- BBACKUPD " " + bbackupd_args + " " + bbackupd_conf_file,
- "testfiles/bbackupd.pid");
+ const std::string& daemon_args_final(daemon_args.size() ? daemon_args : bbackupd_args);
+ bbackupd_pid = StartDaemon(bbackupd_pid, BBACKUPD " " + daemon_args_final + " -c " +
+ bbackupd_conf_file, "testfiles/bbackupd.pid");
return bbackupd_pid != 0;
}
@@ -298,3 +298,40 @@ bool StopClient(bool wait_for_process)
return result;
}
+bool StartSimulator()
+{
+ s3simulator_pid = StartDaemon(s3simulator_pid,
+ "../../bin/s3simulator/s3simulator " + bbstored_args +
+ " testfiles/s3simulator.conf", "testfiles/s3simulator.pid");
+ return s3simulator_pid != 0;
+}
+
+bool StopSimulator()
+{
+ bool result = StopDaemon(s3simulator_pid, "testfiles/s3simulator.pid",
+ "s3simulator.memleaks", true);
+ s3simulator_pid = 0;
+ return result;
+}
+
+bool kill_running_daemons()
+{
+ bool success = true;
+
+ if(FileExists("testfiles/bbstored.pid"))
+ {
+ TEST_THAT_OR(KillServer("testfiles/bbstored.pid", true), success = false);
+ }
+
+ if(FileExists("testfiles/bbackupd.pid"))
+ {
+ TEST_THAT_OR(KillServer("testfiles/bbackupd.pid", true), success = false);
+ }
+
+ if(FileExists("testfiles/s3simulator.pid"))
+ {
+ TEST_THAT_OR(KillServer("testfiles/s3simulator.pid", true), success = false);
+ }
+
+ return success;
+}
diff --git a/lib/backupstore/StoreTestUtils.h b/lib/backupstore/StoreTestUtils.h
index b3faebb5..794fbd44 100644
--- a/lib/backupstore/StoreTestUtils.h
+++ b/lib/backupstore/StoreTestUtils.h
@@ -66,17 +66,24 @@ bool run_housekeeping_and_check_account();
bool check_reference_counts();
//! Starts the bbstored test server running, which must not already be running.
-bool StartServer();
+bool StartServer(const std::string& daemon_args = "");
//! Stops the currently running bbstored test server.
bool StopServer(bool wait_for_process = false);
//! Starts the bbackupd client running, which must not already be running.
-bool StartClient(const std::string& bbackupd_conf_file = "testfiles/bbackupd.conf");
+bool StartClient(const std::string& bbackupd_conf_file = "testfiles/bbackupd.conf",
+ const std::string& daemon_args = "");
//! Stops the currently running bbackupd client.
bool StopClient(bool wait_for_process = false);
+bool StartSimulator();
+
+bool StopSimulator();
+
+bool kill_running_daemons();
+
//! Creates the standard test account, for example after delete_account().
bool create_account(int soft, int hard);