Add test for mount state after takeover

Summary: Ensure that an EdenMount is RUNNING after it takes over an EdenMount from another process.

Reviewed By: simpkins

Differential Revision: D14178500

fbshipit-source-id: 2813b024b6815dc5d31f3e3bf89cffa98ad0f1c3
This commit is contained in:
Matt Glazar 2019-03-05 17:24:50 -08:00 committed by Facebook Github Bot
parent 77e312595c
commit 51857c47dd

View File

@ -13,6 +13,7 @@
#include <folly/Range.h>
#include <folly/ScopeGuard.h>
#include <folly/chrono/Conv.h>
#include <folly/executors/ManualExecutor.h>
#include <folly/futures/Promise.h>
#include <folly/test/TestUtils.h>
#include <gtest/gtest.h>
@ -681,6 +682,27 @@ TEST(EdenMountState, mountIsRunningAfterFuseInitializationCompletes) {
EXPECT_EQ(testMount.getEdenMount()->getState(), EdenMount::State::RUNNING);
}
TEST(EdenMountState, newMountIsRunningAndOldMountIsShutDownAfterFuseTakeover) {
auto oldTestMount = TestMount{FakeTreeBuilder{}};
auto& oldMount = *oldTestMount.getEdenMount();
auto newTestMount = TestMount{FakeTreeBuilder{}};
auto& newMount = *newTestMount.getEdenMount();
auto fuse = std::make_shared<FakeFuse>();
oldTestMount.startFuseAndWait(fuse);
oldMount.getFuseChannel()->takeoverStop();
TakeoverData::MountInfo takeoverData =
oldMount.getFuseCompletionFuture().within(kTimeout).getVia(
oldTestMount.getServerExecutor().get());
oldMount.shutdown(/*doTakeover=*/true).get(kTimeout);
newMount.takeoverFuse(FuseChannelData{std::move(takeoverData.fuseFD), {}});
EXPECT_EQ(oldMount.getState(), EdenMount::State::SHUT_DOWN);
EXPECT_EQ(newMount.getState(), EdenMount::State::RUNNING);
}
TEST(EdenMountState, mountIsFuseErrorAfterMountFails) {
auto testMount = TestMount{FakeTreeBuilder{}};
auto& mount = *testMount.getEdenMount();