eden/fs/inodes/test/CheckoutTest.cpp
// Test performing a checkout with a modified file where the ObjectStore data is
// not immediately ready in the LocalStore even though the inode is loaded.
Test performing a checkout with a modified file where the ObjectStore data is
not immediately ready in the LocalStore even though the inode is loaded.
Test performing a checkout with a modified file where the ObjectStore data is not immediately ready in the LocalStore even though the inode is loaded .
TEST(Checkout, modifyLoadedButNotReadyFileWithConflict) {
  TestMount mount;
  auto backingStore = mount.getBackingStore();
  auto builder1 = FakeTreeBuilder();
  StringPiece contents1 = "test contents\n";
  builder1.setFile("a/test.txt", contents1);
  auto builder2 = builder1.clone();
  StringPiece contents2 = "updated contents\n";
  builder2.replaceFile("a/test.txt", contents2);
  builder2.finalize(backingStore, true);
  auto commit2Hash = makeTestHash("2");
  auto commit2 = backingStore->putCommit(commit2Hash, builder2);
  commit2->setReady();
  auto builder3 = builder1.clone();
  builder3.replaceFile("a/test.txt", "original conflicting contents\n");
  builder3.finalize(backingStore, true);
  auto commit3Hash = makeTestHash("3");
  auto commit3 = backingStore->putCommit(commit3Hash, builder3);
  commit3->setReady();
  mount.initialize(builder1, false);
  auto blob1 = builder1.getStoredBlob("a/test.txt"_relpath);
  builder1.setReady("a");
  blob1->setReady();
  auto preInode = mount.getFileInode("a/test.txt");
  blob1->notReady();
  mount.getEdenMount()->resetParent(commit3Hash);
  auto checkoutFuture = mount.getEdenMount()->checkout(commit2Hash);
  for (int n = 0; n < 5; ++n) {
    blob1->trigger();
  }
  builder1.setAllReady();
  ASSERT_TRUE(checkoutFuture.isReady());
  auto results = std::move(checkoutFuture).get(10ms);
  EXPECT_THAT(
      results,
      UnorderedElementsAre(
          makeConflict(ConflictType::MODIFIED_MODIFIED, "a/test.txt")));
  auto postInode = mount.getFileInode("a/test.txt");
  EXPECT_FILE_INODE(postInode, contents1, 0644);
}
TEST ( Checkout , modifyLoadedButNotReadyFileWithConflict ) { TestMount mount ; auto backingStore = mount . getBackingStore ( ) ; auto builder1 = FakeTreeBuilder ( ) ; StringPiece contents1 = " \n " ; builder1 . setFile ( " " , contents1 ) ; auto builder2 = builder1 . clone ( ) ; StringPiece contents2 = " \n " ; builder2 . replaceFile ( " " , contents2 ) ; builder2 . finalize ( backingStore , true ) ; auto commit2Hash = makeTestHash ( " " ) ; auto commit2 = backingStore -> putCommit ( commit2Hash , builder2 ) ; commit2 -> setReady ( ) ; auto builder3 = builder1 . clone ( ) ; builder3 . replaceFile ( " " , " \n " ) ; builder3 . finalize ( backingStore , true ) ; auto commit3Hash = makeTestHash ( " " ) ; auto commit3 = backingStore -> putCommit ( commit3Hash , builder3 ) ; commit3 -> setReady ( ) ; mount . initialize ( builder1 , false ) ; auto blob1 = builder1 . getStoredBlob ( " " _relpath ) ; builder1 . setReady ( " " ) ; blob1 -> setReady ( ) ; auto preInode = mount . getFileInode ( " " ) ; blob1 -> notReady ( ) ; mount . getEdenMount ( ) -> resetParent ( commit3Hash ) ; auto checkoutFuture = mount . getEdenMount ( ) -> checkout ( commit2Hash ) ; for ( int n = 0 ; n < 5 ; ++ n ) { blob1 -> trigger ( ) ; } builder1 . setAllReady ( ) ; ASSERT_TRUE ( checkoutFuture . isReady ( ) ) ; auto results = std :: move ( checkoutFuture ) . get ( 10 ms ) ; EXPECT_THAT ( results , UnorderedElementsAre ( makeConflict ( ConflictType :: MODIFIED_MODIFIED , " " ) ) ) ; auto postInode = mount . getFileInode ( " " ) ; EXPECT_FILE_INODE ( postInode , contents1 , 0644 ) ; }
Test performing a checkout with a modified file where the ObjectStore data is
not immediately ready in the LocalStore even though the inode is loaded.
Test performing a checkout with a modified file where the ObjectStore data is not immediately ready in the LocalStore even though the inode is loaded .
/*setReady=*/ /*setReady=*/ // Initialize the mount with the tree data from builder1 /*startReady=*/ // Load a/test.txt // Mark its blob as not ready again after loading it // Call resetParent() to make the mount point at commit3, even though // the file state is from commit1.  This will cause a conflict in a // non-materialized file. // Perform the checkout. // Trigger blob1 several times to allow the checkout to make forward progress // if it needs to access this blob, without necessarily completing all at // once. // Mark builder1 as ready and confirm that the checkout completes // Verify that the inode was not updated