def test_olddir(self):
        empty_dir = 'mc/new/empty/0002'
        path = os.path.join(TMP_DIR, empty_dir)
        os.makedirs(path)
        os.utime(path, (1000000000, 1000000000))

        listing = datatypes.DirectoryInfo('/store',
                                          to_merge=[datatypes.create_dirinfo('', subdir, my_ls) for
                                                    subdir in ['mc', 'data']])

        LOG.info('='*40)
        LOG.info('Doing the hash')
        LOG.info('='*40)

        listing.setup_hash()

        LOG.info('='*40)
        LOG.info('Doing the comparison')
        LOG.info('='*40)

        LOG.info(listing.displays())
        LOG.info('='*40)
        LOG.info(self.listing.displays())

        file_list, dir_list, _ = listing.compare(self.listing)

        self.assertEqual(len(dir_list), 1)
        self.assertTrue(os.path.join('/store', empty_dir).startswith(dir_list[0]))

        for file_name, _ in self.file_list:
            self.assertFalse(file_name.startswith(dir_list[0]))
Exemple #2
0
    def test_olddir(self):
        empty_dir = 'mc/new/empty/0002'
        path = os.path.join(TMP_DIR, empty_dir)
        os.makedirs(path)
        os.utime(path, (1000000000, 1000000000))

        listing = datatypes.DirectoryInfo('/store',
                                          to_merge=[
                                              datatypes.create_dirinfo(
                                                  '', subdir, my_ls)
                                              for subdir in ['mc', 'data']
                                          ])

        LOG.info('=' * 40)
        LOG.info('Doing the hash')
        LOG.info('=' * 40)

        listing.setup_hash()

        LOG.info('=' * 40)
        LOG.info('Doing the comparison')
        LOG.info('=' * 40)

        LOG.info(listing.displays())
        LOG.info('=' * 40)
        LOG.info(self.listing.displays())

        file_list, dir_list, _ = listing.compare(self.listing)

        self.assertEqual(len(dir_list), 1)
        self.assertTrue(
            os.path.join('/store', empty_dir).startswith(dir_list[0]))

        for file_name, _ in self.file_list:
            self.assertFalse(file_name.startswith(dir_list[0]))
    def do_more_setup(self):
        for name, size in self.file_list + self.orphan:
            path = os.path.join(TMP_DIR, name[7:])
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            out = open(path, 'w')
            out.write('\0' * size)
            out.close()

            os.utime(path, (1000000000, 1000000000))

        self.tree.add_file_list(self.missing)

        for name, size in self.new_file:
            path = os.path.join(TMP_DIR, name[7:])
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            out = open(path, 'w')
            out.write('\0' * size)
            out.close()

        self.listing = datatypes.DirectoryInfo(
            '/store', to_merge=[datatypes.create_dirinfo('', subdir, my_ls) \
                                    for subdir in ['mc', 'data']])

        self.tree.setup_hash()
        self.listing.setup_hash()
Exemple #4
0
    def do_more_setup(self):
        for name, size in self.file_list + self.orphan:
            path = os.path.join(TMP_DIR, name[7:])
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            out = open(path, 'w')
            out.write('\0' * size)
            out.close()

            os.utime(path, (1000000000, 1000000000))

        self.tree.add_file_list(self.missing)

        for name, size in self.new_file:
            path = os.path.join(TMP_DIR, name[7:])
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            out = open(path, 'w')
            out.write('\0' * size)
            out.close()

        self.listing = datatypes.DirectoryInfo(
            '/store', to_merge=[datatypes.create_dirinfo('', subdir, my_ls) \
                                    for subdir in ['mc', 'data']])

        self.tree.setup_hash()
        self.listing.setup_hash()
    def test_ls_vs_list(self):

        dirinfos = [datatypes.create_dirinfo('', subdir, my_ls) \
                        for subdir in ['mc', 'data']]

        master_dirinfo = datatypes.DirectoryInfo('/store', to_merge=dirinfos)

        self.check_equal(self.tree, master_dirinfo)
        self.assertEqual(self.tree.count_nodes(), master_dirinfo.count_nodes())
Exemple #6
0
    def test_ls_vs_list(self):

        dirinfos = [datatypes.create_dirinfo('', subdir, my_ls) \
                        for subdir in ['mc', 'data']]

        master_dirinfo = datatypes.DirectoryInfo('/store', to_merge=dirinfos)

        self.check_equal(self.tree, master_dirinfo)
        self.assertEqual(self.tree.count_nodes(), master_dirinfo.count_nodes())
    def test_newdir(self):
        empty_dir = 'mc/new/empty/0002'

        os.makedirs(os.path.join(TMP_DIR, empty_dir))

        dirinfos = [datatypes.create_dirinfo('', subdir, my_ls) \
                        for subdir in ['mc', 'data']]

        master_dirinfo = datatypes.DirectoryInfo('/store', to_merge=dirinfos)

        self.check_equal(self.tree, master_dirinfo)
        self.assertFalse(master_dirinfo.get_node(os.path.join(empty_dir, 'not_there'), False))
        self.assertTrue(master_dirinfo.get_node(empty_dir, False))
        self.assertFalse(master_dirinfo.get_node(empty_dir, False).can_compare)
Exemple #8
0
    def test_newdir(self):
        empty_dir = 'mc/new/empty/0002'

        os.makedirs(os.path.join(TMP_DIR, empty_dir))

        dirinfos = [datatypes.create_dirinfo('', subdir, my_ls) \
                        for subdir in ['mc', 'data']]

        master_dirinfo = datatypes.DirectoryInfo('/store', to_merge=dirinfos)

        self.check_equal(self.tree, master_dirinfo)
        self.assertFalse(
            master_dirinfo.get_node(os.path.join(empty_dir, 'not_there'),
                                    False))
        self.assertTrue(master_dirinfo.get_node(empty_dir, False))
        self.assertFalse(master_dirinfo.get_node(empty_dir, False).can_compare)
    def test_xrd_on_t3(self):

        remote_tree = getsitecontents.get_site_tree('T3_US_MIT')

        local_listing = datatypes.DirectoryInfo(
            '/store', to_merge=[
                datatypes.create_dirinfo('', subdir, my_ls) for \
                    subdir in config.config_dict().get('DirectoryList', [])
                ])

        local_listing.setup_hash()

        print '='*30
        local_listing.display()
        print '='*30
        remote_tree.display()

        self.assertEqual(local_listing.hash, remote_tree.hash)
Exemple #10
0
    def test_xrd_on_t3(self):

        remote_tree = getsitecontents.get_site_tree('T3_US_MIT')

        local_listing = datatypes.DirectoryInfo(
            '/store', to_merge=[
                datatypes.create_dirinfo('', subdir, my_ls) for \
                    subdir in config.config_dict().get('DirectoryList', [])
                ])

        local_listing.setup_hash()

        print '=' * 30
        local_listing.display()
        print '=' * 30
        remote_tree.display()

        self.assertEqual(local_listing.hash, remote_tree.hash)