Esempio n. 1
0
    def testThatTrimmedBlobsAreRemovedFromDb(self):
        # aaa    47bce5c74f589f4867dbd57e9ca9f808
        # bbb    08f8e0260c64418510cefb2b06eee5cd
        # ccc    9df62e693988eb4e1e1444ece0578579
        # bbbccc 71d27475242f6b50db02ddf1476107ee

        write_file(self.workdir2, "bbbccc.txt", "bbbccc")

        # Make the checkin() go just almost all the way...
        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None
        self.wd2.checkin() # Will not complete

        # Now, make sure bbbccc exists as a recipe
        write_file(self.workdir1, "bbb.txt", "bbb")
        write_file(self.workdir1, "ccc.txt", "ccc")
        self.wd1.checkin()

        write_file(self.workdir1, "bbbccc.txt", "bbbccc")
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None) # Resume the commit

        #####################

        # Is deduplicated to bbbccc + X
        # If bbbccc is stored in the blocksdb, the commit will fail
        write_file(self.workdir1, "b.txt", "bbbcccX")
        self.wd1.checkin()

        self.assertEquals(set(), self.wd1.front.repo.get_orphan_blobs())
Esempio n. 2
0
    def testThatConcurrentlyAddedBlobsWork(self):
        write_file(self.workdir2, "aaa1.txt", "aaa")

        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None
        self.wd2.checkin()  # Will not complete

        write_file(self.workdir1, "aaa2.txt", "aaa")
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None)  # Resume the commit
Esempio n. 3
0
    def testThatConcurrentlyAddedBlobsWork(self):
        write_file(self.workdir2, "aaa1.txt", "aaa")

        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None
        self.wd2.checkin() # Will not complete

        write_file(self.workdir1, "aaa2.txt", "aaa")
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None) # Resume the commit
Esempio n. 4
0
    def testRedundantNewBlob(self):
        # aaa    47bce5c74f589f4867dbd57e9ca9f808
        # bbb    08f8e0260c64418510cefb2b06eee5cd
        # ccc    9df62e693988eb4e1e1444ece0578579
        # bbbccc 71d27475242f6b50db02ddf1476107ee

        write_file(self.workdir1, "a.txt", "aaa")
        self.wd1.checkin()

        write_file(self.workdir2, "b.txt", "aaabbbccc")
        # b.txt is deduplicated to aaa + bbbccc
        # Make the checkin() go just almost all the way...
        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None
        self.wd2.checkin() # Will not complete

        # Is deduplicated to aaa + bbb
        write_file(self.workdir1, "b.txt", "aaabbb")
        self.wd1.checkin()

        # Is deduplicated to aaa + bbb + ccc
        write_file(self.workdir1, "b.txt", "aaabbbccc")
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None) # Resume the commit
        self.assertEquals(set(), self.wd1.front.repo.get_orphan_blobs())
Esempio n. 5
0
    def testIdenticalBlocksOnlyAddedOnce(self):
        write_file(self.workdir1, "a.txt", "aaa")
        write_file(self.workdir2, "b.txt", "aaa")

        # Make the checkin() go just almost all the way...
        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None

        self.wd2.checkin() # Will not complete
        self.wd1.checkin()
        wd2_commit(u"TestSession2", None) # Resume the commit
        for blockdb in (self.wd1.front.repo.blocksdb, self.wd2.front.repo.blocksdb):
            self.assertEquals(blockdb.get_all_rolling(), [3298534883712])
            self.assertTrue(blockdb.has_block("47bce5c74f589f4867dbd57e9ca9f808"))
            block_locations = blockdb.get_block_locations("47bce5c74f589f4867dbd57e9ca9f808")
            self.assertEquals(list(block_locations), [('47bce5c74f589f4867dbd57e9ca9f808', 0)])
Esempio n. 6
0
    def testIdenticalNewBlob(self):
        write_file(self.workdir1, "a.txt", "aaa")
        write_file(self.workdir1, "b.txt", "bbb")
        self.wd1.checkin()

        write_file(self.workdir1, "c1.txt", "aaaccc")
        write_file(self.workdir2, "c2.txt", "bbbccc")

        # Make the checkin() go just almost all the way...
        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None

        self.wd2.checkin() # Will not complete
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None) # Resume the commit
        self.assertEquals("ccc", self.wd1.front.get_blob("9df62e693988eb4e1e1444ece0578579").read())
Esempio n. 7
0
    def testIdenticalCommits(self):
        write_file(self.workdir1, "a.txt", "aaa")
        self.wd1.checkin()

        write_file(self.workdir2, "b2.txt", "aaaaaa")
        write_file(self.workdir1, "b1.txt", "aaaaaa")

        # Make the checkin() go just almost all the way...
        wd2_commit = self.wd2.front.commit
        self.wd2.front.commit = lambda session_name, log_message, progress_callback: None

        self.wd2.checkin() # Will not complete
        self.wd1.checkin()

        wd2_commit(u"TestSession2", None) # Resume the commit