Esempio n. 1
0
  @Test
  public void deleteInodeTest() throws Exception {
    InodeTree.CreatePathResult createResult = mTree.createPath(NESTED_URI, sNestedDirectoryOptions);
    List<Inode> created = createResult.getCreated();

    // all inodes under root
    List<Inode> inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // /nested, /nested/test
    Assert.assertEquals(2, inodes.size());
    // delete the nested inode
    mTree.deleteInode(created.get(created.size() - 1));
    inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // only /nested left
    Assert.assertEquals(1, inodes.size());
  }
Esempio n. 2
0
  @Test
  public void addInodeFromJournalTest() throws Exception {
    mTree.createPath(NESTED_FILE_URI, sNestedFileOptions);
    mTree.createPath(new TachyonURI("/nested/test1/file1"), sNestedFileOptions);
    InodeDirectory root = mTree.getRoot();
    InodeDirectory nested = (InodeDirectory) root.getChild("nested");
    InodeDirectory test = (InodeDirectory) nested.getChild("test");
    Inode file = test.getChild("file");
    InodeDirectory test1 = (InodeDirectory) nested.getChild("test1");
    Inode file1 = test1.getChild("file1");

    // reset the tree
    mTree.addInodeFromJournal(root.toJournalEntry());

    // re-init the root since the tree was reset above
    root = mTree.getRoot();

    Assert.assertEquals(0, mTree.getInodeChildrenRecursive(root).size());
    mTree.addInodeFromJournal(nested.toJournalEntry());
    verifyChildrenNames(mTree, root, Sets.newHashSet("nested"));

    mTree.addInodeFromJournal(test.toJournalEntry());
    verifyChildrenNames(mTree, root, Sets.newHashSet("nested", "test"));

    mTree.addInodeFromJournal(test1.toJournalEntry());
    verifyChildrenNames(mTree, root, Sets.newHashSet("nested", "test", "test1"));

    mTree.addInodeFromJournal(file.toJournalEntry());
    verifyChildrenNames(mTree, root, Sets.newHashSet("nested", "test", "test1", "file"));

    mTree.addInodeFromJournal(file1.toJournalEntry());
    verifyChildrenNames(mTree, root, Sets.newHashSet("nested", "test", "test1", "file", "file1"));
  }
Esempio n. 3
0
 // verify that the tree has the given children
 private static void verifyChildrenNames(
     InodeTree tree, InodeDirectory root, Set<String> childNames) throws Exception {
   List<Inode> children = tree.getInodeChildrenRecursive(root);
   Assert.assertEquals(childNames.size(), children.size());
   for (Inode child : children) {
     Assert.assertTrue(childNames.contains(child.getName()));
   }
 }
Esempio n. 4
0
  @Test
  public void getInodeChildrenRecursiveTest() throws Exception {
    mTree.createPath(TEST_URI, sDirectoryOptions);
    mTree.createPath(NESTED_URI, sNestedDirectoryOptions);
    // add nested file
    mTree.createPath(NESTED_FILE_URI, sNestedFileOptions);

    // all inodes under root
    List<Inode> inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // /test, /nested, /nested/test, /nested/test/file
    Assert.assertEquals(4, inodes.size());
  }