Beispiel #1
0
 def test_2(self):
     """This test is a little bit different. It waits until all the iterative
     backups are done and verify that they all have the right checksum.
     So this checks that later backup didn't change previous ones."""
     try:
         checksums = []
         bkps = BackupChain("Test2", self.source, self.backups)
         for i in range(10):
             # Make some changes to the data files
             self.sourceTree.make_random_changes(100)
             # get a checksum of the tree
             sum = self.sourceTree.checksum()
             # Make a backup
             bkp = bkps.make_backup()
             # make sure the source hasn't been modified
             self.assertEqual( self.sourceTree.checksum(), sum )
             checksums += [sum]
             # because rsync don't copy files that are < one second appart, 
             # we have to wait to make sure that the changes get detected.
             # (This shouldn't really be a problem in real application because no one
             # makes a backups every seconds or less...)
             sleep(1) 
         for b,s in zip(bkps.history, checksums):
             self.assertEqual(checksum(b.path, "source"), s)
     except AssertionError: # raised by TestCase.fail, called by all asserts
         raise
Beispiel #2
0
 def test_remove_deleted_file(self):
     """Check that rsyn does really delete files that have been
     deleted from the source directory."""
     fpath = os.path.join(self.source, "file.txt")
     with open(fpath,"a") as f:
         f.write("*"*100 + "\n")
     bkps = BackupChain("Test1", self.source, self.backups)
     b = bkps.make_backup()
     self.assertEqual(checksum(b.path, "source"), checksum(self.root, "source"))
     os.unlink(fpath)
     b = bkps.make_backup()
     self.assertEqual(checksum(b.path, "source"), checksum(self.root, "source"))
Beispiel #3
0
    def test_backup_truncated_file(self):
        """Subtile case where a file is truncated but keep the same size."""
        fpath = os.path.join(self.source, "file.txt")
        with open(fpath,"a") as f:
            f.write("*"*100 + "\n")
        bkps = BackupChain("Test1", self.source, self.backups)
        b = bkps.make_backup()
        self.assertEqual(checksum(b.path, "source"), checksum(self.root, "source"))

        with open(fpath,"a") as f:
            f.write("#"*100 + "\n")
        b = bkps.make_backup()
        self.assertEqual(checksum(b.path, "source"), checksum(self.root, "source"))
Beispiel #4
0
 def test_1(self):
     """This creates incremental backups of a directory tree by
     inserting random modifications and then creating a new backup a hundred times.
     It checks after each backup that the data is the same
     using the checksum function"""
     for i in range(10):
         # Make some changes to the data files
         self.sourceTree.make_random_changes(100)
         # get a checksum of the tree
         sum = self.sourceTree.checksum()
         logging.debug("data checmsum: %s" % sum)
         # Make a backup
         bkp = BackupChain("Test1", self.source, self.backups)
         b = bkp.make_backup()
         # make sure the source hasn't been modified
         self.assertEqual( self.sourceTree.checksum(), sum )
         # make sure that the cheksum s correct for this backup AND the old ones
         self.assertEqual(checksum(b.path, "source"), sum)
         # because rsync don't copy files that are < one second appart, 
         # we have to wait to make sure that the changes get detected.
         # (This shouldn't really be a problem in real application because no one
         # makes a backups every seconds or less...)
         sleep(1)