def test_container_rebuilder_output(self):
     self.checker.check(Target(self.account, container=self.container),
                        recurse=DEFAULT_DEPTH)
     for _ in self.checker.run():
         pass
     self.checker.fd.flush()
     self._verify_rebuilder_input()
Exemple #2
0
 def take_action(self, parsed_args):
     super(ChunkCheck, self).take_action(parsed_args)
     checker = self.build_checker(parsed_args)
     for chunk in parsed_args.chunks:
         target = Target(self.app.options.account, chunk=chunk)
         checker.check(target, parsed_args.depth)
     return self.format_results(checker)
Exemple #3
0
 def take_action(self, parsed_args):
     super(ContainerCheck, self).take_action(parsed_args)
     checker = self.build_checker(parsed_args)
     for ct in parsed_args.containers:
         target = Target(self.app.options.account, ct)
         checker.check(target, parsed_args.depth)
     return self.format_results(checker)
Exemple #4
0
 def check_chunks(self, service, chunks, checker):
     url = 'http://' + service
     for chunk in chunks:
         checker.check(Target(self.app.options.account,
                              chunk=url + '/' + chunk[2],
                              content_id=chunk[1], cid=chunk[0]))
         for res in self._format_results(checker):
             yield res
Exemple #5
0
 def take_action(self, parsed_args):
     super(AccountCheck, self).take_action(parsed_args)
     checker = self.build_checker(parsed_args)
     if not parsed_args.accounts:
         parsed_args.accounts = [self.app.options.account]
     for acct in parsed_args.accounts:
         target = Target(acct)
         checker.check(target, parsed_args.depth)
     return self.format_results(checker)
Exemple #6
0
 def take_action(self, parsed_args):
     super(ObjectCheck, self).take_action(parsed_args)
     checker = self.build_checker(parsed_args)
     for obj in parsed_args.objects:
         target = Target(self.app.options.account,
                         parsed_args.container,
                         obj,
                         version=parsed_args.object_version)
         checker.check(target, parsed_args.depth)
     return self.format_results(checker)
Exemple #7
0
    def _convert_and_check(self,
                           chunk_volume,
                           chunk_path,
                           chunk_id_info,
                           expected_raw_meta=None,
                           expected_errors=0):
        conf = self.conf
        conf['volume'] = self.rawx_volumes[chunk_volume]
        converter = BlobConverter(conf, logger=self.logger)
        converter.safe_convert_chunk(chunk_path)
        self.assertEqual(1, converter.total_chunks_processed)
        self.assertEqual(1, converter.passes)
        self.assertEqual(expected_errors, converter.errors)

        checker = Checker(self.ns)
        for chunk_id, info in chunk_id_info.items():
            account, container, path, version, content_id = info
            fullpath = encode_fullpath(account, container, path, version,
                                       content_id)
            cid = cid_from_name(account, container)
            meta, raw_meta = read_chunk_metadata(chunk_path, chunk_id)

            self.assertEqual(meta.get('chunk_id'), chunk_id)
            self.assertEqual(meta.get('container_id'), cid)
            self.assertEqual(meta.get('content_path'), path)
            self.assertEqual(meta.get('content_version'), version)
            self.assertEqual(meta.get('content_id'), content_id)
            self.assertEqual(meta.get('full_path'), fullpath)

            checker.check(
                Target(account,
                       container=container,
                       obj=path,
                       chunk='http://' + converter.volume_id + '/' + chunk_id))
            for _ in checker.run():
                pass
            self.assertTrue(checker.report())

            if expected_raw_meta:
                self.assertDictEqual(expected_raw_meta, raw_meta)
                continue

            self.assertNotIn(CHUNK_XATTR_KEYS['chunk_id'], raw_meta)
            self.assertNotIn(CHUNK_XATTR_KEYS['container_id'], raw_meta)
            self.assertNotIn(CHUNK_XATTR_KEYS['content_path'], raw_meta)
            self.assertNotIn(CHUNK_XATTR_KEYS['content_version'], raw_meta)
            self.assertNotIn(CHUNK_XATTR_KEYS['content_id'], raw_meta)
            self.assertIn(CHUNK_XATTR_CONTENT_FULLPATH_PREFIX + chunk_id,
                          raw_meta)
            for k in raw_meta.keys():
                if k.startswith('oio:'):
                    self.fail('old fullpath always existing')
            self.assertEqual(raw_meta[CHUNK_XATTR_KEYS['oio_version']],
                             OIO_VERSION)
    def test_object_rebuilder_output_with_confirmations(self):
        """
        Check that chunk targets showing errors are reported only after
        the right number of confirmations.
        """
        self.checker.required_confirmations = 2
        tgt = Target(self.account,
                     container=self.container,
                     obj=self.obj,
                     content_id=self.meta['id'],
                     version=self.meta['version'])
        self.checker.check(tgt, recurse=DEFAULT_DEPTH)
        for _ in self.checker.run():
            pass
        self.checker.fd.flush()
        # File is empty
        self.assertRaises(StopIteration, self._verify_rebuilder_input)
        self.assertIn(repr(tgt), self.checker.delayed_targets)

        # 1st confirmation
        for dtgt in self.checker.delayed_targets.values():
            self.checker.check(dtgt, recurse=DEFAULT_DEPTH)
        for _ in self.checker.run():
            pass
        self.checker.fd.flush()
        # File is empty
        self.assertRaises(StopIteration, self._verify_rebuilder_input)
        self.assertIn(repr(tgt), self.checker.delayed_targets)

        # 2nd confirmation
        for dtgt in self.checker.delayed_targets.values():
            self.checker.check(dtgt, recurse=DEFAULT_DEPTH)
        for _ in self.checker.run():
            pass
        self.checker.fd.flush()
        # File is NOT empty
        self._verify_rebuilder_input()
        self.assertNotIn(repr(tgt), self.checker.delayed_targets)
Exemple #9
0
 def _take_action(self, parsed_args):
     for chunk in parsed_args.chunks:
         target = Target(self.app.options.account, chunk=chunk)
         self.checker.check(target)
     return self._format_results()
Exemple #10
0
 def _take_action(self, parsed_args):
     account, _, objects = self.resolve_objects(self.app, parsed_args)
     for container, obj_name, version in objects:
         target = Target(account, container, obj_name, version=version)
         self.checker.check(target, parsed_args.depth)
     return self._format_results()
Exemple #11
0
 def _take_action(self, parsed_args):
     containers = self.resolve_containers(self.app, parsed_args, no_id=True)
     for account, container_name, _ in containers:
         target = Target(account, container_name)
         self.checker.check(target, parsed_args.depth)
     return self._format_results()
Exemple #12
0
 def _take_action(self, parsed_args):
     for acct in parsed_args.accounts:
         target = Target(acct)
         self.checker.check(target, parsed_args.depth)
     return self._format_results()