Ejemplo n.º 1
0
    def _test_scan_file(self,
                        filelist,
                        probelist,
                        force=True,
                        mimetype_filtering=None,
                        resubmit_files=None,
                        timeout=SCAN_TIMEOUT_SEC):
        nb_probes = len(probelist)
        nb_files = len(filelist)
        nb_jobs = nb_probes * nb_files
        filenames = map(lambda f: os.path.basename(f), filelist)
        scan = scan_new(verbose=DEBUG)
        self.assertIsNot(scan.id, None)
        scanid = scan.id
        self.assertIsNot(scan.date, None)
        self.assertEqual(len(scan.results), 0)

        scan = scan_add(scan.id, filelist, verbose=DEBUG)
        self._check_results(scan.results, scanid, filenames, [0], [0],
                            True, True)

        scan = scan_launch(scan.id, force=force, probe=probelist,
                           mimetype_filtering=mimetype_filtering,
                           resubmit_files=resubmit_files,
                           verbose=DEBUG)
        start = time.time()
        while not scan.is_finished():
            self._check_results(scan.results, scanid, filenames,
                                range(nb_probes + 1), range(nb_jobs + 1),
                                True, True)
            time.sleep(BEFORE_NEXT_PROGRESS)
            now = time.time()
            self.assertLessEqual(now, start + timeout, "Results Timeout")
            scan = scan_get(scan.id)

        # Scan finished
        self._check_results(scan.results, scanid, filenames,
                            [scan.probes_total], [scan.probes_total],
                            True, True)
        res = {}
        for get_result in scan.results:
            file_result = scan_proberesults(get_result.result_id,
                                            formatted=True, verbose=DEBUG)
            self.assertIn(file_result.status, [-1, 0, 1])
            self.assertEqual(file_result.probes_finished,
                             file_result.probes_total)
            self.assertEqual(len(file_result.probe_results),
                             file_result.probes_total)
            res[get_result.name] = {}
            for pr in file_result.probe_results:
                res[get_result.name][pr.name] = pr
        return res
Ejemplo n.º 2
0
 def test_scan_launch(self):
     scan = scan_new()
     date = scan.date
     scanid = scan.id
     scan = scan_add(scan.id, FILEPATHS)
     force = False
     probes = probe_list()
     nb_jobs = len(FILENAMES) * len(probes)
     scan = scan_launch(scan.id, force, probes)
     self._check_scan(scan, scanid, ["ready", "uploaded",
                                     "launched", "finished"],
                      FILENAMES, range(nb_jobs + 1), range(nb_jobs + 1),
                      date, force, True, True)
Ejemplo n.º 3
0
 def test_resubmit_files(self):
     scan = scan_new()
     date = scan.date
     scanid = scan.id
     scan = scan_add(scan.id, FILEPATHS)
     force = True
     resubmit_files = False
     probes = probe_list()
     nb_jobs = len(FILENAMES) * len(probes)
     scan = scan_launch(scan.id, force, probe=probes,
                        resubmit_files=resubmit_files)
     self._check_scan(scan, scanid, ["ready", "uploaded", "launched"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      date, force, True, resubmit_files)
     scan = scan_cancel(scan.id)
     self._check_scan(scan, scanid, ["cancelled"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      date, force, True, resubmit_files)
Ejemplo n.º 4
0
 def test_mimetype_filtering(self):
     scan = scan_new()
     date = scan.date
     scanid = scan.id
     scan = scan_add(scan.id, FILEPATHS)
     force = True
     mimetype_filtering = False
     probes = probe_list()
     nb_jobs = len(FILENAMES) * len(probes)
     scan = scan_launch(scan.id, force, probes,
                        mimetype_filtering=mimetype_filtering)
     self._check_scan(scan, scanid, ["ready", "uploaded", "launched"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      date, force, mimetype_filtering, True)
     scan = scan_cancel(scan.id)
     self._check_scan(scan, scanid, ["cancelled"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      date, force, mimetype_filtering, True)