示例#1
0
    def test_create_full_snapshot(self):
        """Creation of snapshot including 'commit' i.e. writing to the disk.
        """
        # this is the list of files that should be stored in the created archive
        tar_list_result = "%s/\n%s" % (os.path.join(self.in_path_abs,
                                            "some_directory").lstrip(os.sep),
                            os.path.join(self.in_path_abs,
                            "some_directory/this is a testdoc").lstrip(os.sep))

        # creation of a new snapshot
        tdir = self.snappath_new
        snp = snapshot.Snapshot(tdir)

        # including and excluding some files
        snp.addToIncludeFlist(os.path.join(self.in_path_abs, "some_directory"))
        snp.addToIncludeFlist(os.path.join(self.in_path_abs, "some_directory",
                                        "another_directory/test.txt"))
        snp.addToExcludeFlist(os.path.join(self.in_path_abs,
                                        "some_directory/another_directory"))

        snp.commit()

        # evaluate test
        self.assertTrue(snp.isfull())
        self.assertTrue(os.path.exists(tdir))
        self.assertTrue(os.path.exists(os.path.join(tdir, "ver")))
        self.assertEqual(snp.getVersion(), self.version)

        # compare file lists
        tarcmd = ["tar", "-z", "--list",
                  "-f", "%s" % os.path.join(self.snappath_new, "files.tar.gz")]
        outp = subprocess.Popen(tarcmd, stdout = subprocess.PIPE).communicate()[0]
        self.assertEqual(outp.strip(), tar_list_result)
示例#2
0
    def setUp(self):
        LogFactory.getLogger(level = 10)

        self.snappath_ful = os.path.join(_TestSnapshotPaths.get_snp_path(), self.snp_ful_name)
        self.snappath_inc = os.path.join(_TestSnapshotPaths.get_snp_path(), self.snp_inc_name)

        self.in_path_abs = _TestSnapshotPaths.get_docinput_path()

#        print "ABSPATH TESTDIR: '%s'\nSNAPPATH FUL: '%s'\nSNAPPATH INC: '%s'"\
#              "\nSNAPPATH NEW: '%s'"\
#                % (self.abspath_testdir, self.snappath_ful,
#                   self.snappath_inc, self.snappath_new)

        self.__clean_dir()
        self.__untar_snapshots()

        # creation of snapshots
        self.snapshot_ful = snapshot.Snapshot(self.snappath_ful)
        self.snapshot_inc = snapshot.Snapshot(self.snappath_inc)
示例#3
0
    def test_constructor(self):
        """Creation of snapshot without commit.
        """
        val_names = self.__get_all_valid_names()
        for val_name in val_names:
            tdir = os.path.join(_TestSnapshotPaths.get_snp_path(), val_name)
#            print "VAL: %s" % tdir
            snp = snapshot.Snapshot(tdir)

            # evaluate test
            self.assertTrue(os.path.exists(tdir))
            self.assertFalse(os.path.exists(os.path.join(tdir, "ver")))
            del snp
示例#4
0
 def __create_inc_snapshot(self):
     val_name = self.snp_valid_inc_names[0]
     tdir = os.path.join(_TestSnapshotPaths.get_snp_path(), val_name)
     snp = snapshot.Snapshot(tdir)
     return snp