From 67ff1cdce3f04e49d7b70b0e2d7eb01ee8ab748c Mon Sep 17 00:00:00 2001 From: Matija Santl Date: Mon, 14 Jan 2019 14:41:48 +0100 Subject: [PATCH] Add distributed snapshot recovery test Summary: Test to check that the recovery works even if the snapshot is corrupted in distributed. Depends on D1930 Reviewers: vkasljevic, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1950 --- tests/unit/distributed_durability.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/unit/distributed_durability.cpp b/tests/unit/distributed_durability.cpp index 138425b2f..b148bf919 100644 --- a/tests/unit/distributed_durability.cpp +++ b/tests/unit/distributed_durability.cpp @@ -3,9 +3,10 @@ #include "distributed_common.hpp" #include "database/distributed/graph_db_accessor.hpp" +#include "durability/distributed/paths.hpp" #include "durability/distributed/snapshooter.hpp" #include "durability/distributed/version.hpp" -#include "durability/distributed/paths.hpp" +#include "utils/file.hpp" #include "utils/string.hpp" std::vector DirFiles(fs::path dir) { @@ -196,6 +197,27 @@ TEST_F(DistributedDurability, RecoveryFailure) { EXPECT_DEATH(RestartWithRecovery(), "worker failed to recover"); } +TEST_F(DistributedDurability, InvalidSnapshotRecovery) { + { + auto dba = master().Access(); + // Make sure we first create a valid snapshot to ensure valid dir structure. + master().MakeSnapshot(*dba); + + auto path = durability::MakeSnapshotPath( + GetDurabilityDirectory(0), master().WorkerId(), dba->transaction_id()); + + // Create a fake snapshot. + utils::LogFile snapshot; + snapshot.Open(path); + snapshot.Write("This is not the snapshot you're looking for"); + snapshot.Sync(); + } + // We expect that the db doesn't crash on the next line. + RestartWithRecovery(); + // Make sure we didn't recover anything from the corrupted snapshot. + CheckVertices(0); +} + TEST_F(DistributedDurability, WalWrite) { { CleanDurability();