Example #1
0
    def run(self):
        handlers = []
        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        getLogger().addHandler(ch)
        handlers.append(ch)
        # if enabled realtime logger will also update the log entry at regualr intervals.
        if self.args.rt_logging:
            dbh = DBLogUpdateHandler(self.db, self.job["id"],
                                     self.args.rt_logging_interval)
            dbh.setLevel(logging.DEBUG)
            getLogger().addHandler(dbh)
            handlers.append(dbh)
            getLogger().info(
                "Realtime logging enabled with {}s updates.".format(
                    self.args.rt_logging_interval))
        try:
            self._setFramework()
            with LOCK:
                self._downloadFiles()
            raw_args = self._getRawArgs()
            app = BenchmarkDriver(raw_args=raw_args,
                                  usb_controller=self.usb_controller)
            getLogger().debug(
                f"Running BenchmarkDriver for benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = app.run()
        except DownloadException:
            getLogger().exception(
                f"An error occurred while running benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = HARNESS_ERROR
        except BenchmarkArgParseException:
            getLogger().exception(
                f"An error occurred while running benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = USER_ERROR
        except Exception:
            getLogger().exception(
                f"An error occurred while running benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = HARNESS_ERROR
        finally:
            output = log_capture_string.getvalue()
            log_capture_string.close()
            for handler in handlers:
                handler.close()
                getLogger().handlers.remove(handler)
            del handlers
            self._setStatusOutput(status, output)
            self._submitDone()
            self._removeBenchmarkFiles()
            time.sleep(1)

        return {"device": self.device, "job": self.job}
Example #2
0
 def test_run(self):
     with patch("harness.parseKnown",
                return_value=(argparse.Namespace(), [])), patch(
                    "harness.getArgs", return_value=self.args), patch(
                        "harness.BenchmarkCollector.collectBenchmarks",
                        return_value=[]), patch("harness.getPlatforms",
                                                return_value=[]):
         app = BenchmarkDriver()
         app.run()
         status = app.status
         self.assertEqual(status, 0)
Example #3
0
 def _runOneBenchmarkSuite(self, repo_info):
     raw_args = self._getRawArgs(repo_info)
     if not _runIndividual(self.args.interval, self.args.regression,
                           self.args.ab_testing):
         # always sleep 10 seconds to make the phone in a more
         # consistent state
         time.sleep(10)
     # cannot use subprocess because it conflicts with requests
     app = BenchmarkDriver(raw_args=raw_args)
     app.run()
     ret = 0
     setRunStatus(ret >> 8)
     if self.args.commit_file and self.args.regression:
         with open(self.args.commit_file, 'w') as file:
             file.write(repo_info['treatment']['commit'])
     getLogger().info("One benchmark run {} for ".format(
         "successful" if ret == 0 else "failed") +
                      repo_info['treatment']['commit'])
Example #4
0
    def run(self, raw_args):
        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        getLogger().addHandler(ch)

        try:
            app = BenchmarkDriver(raw_args=raw_args)
            status = app.run()
        except Exception as e:
            getLogger().error(e)

        output = log_capture_string.getvalue()
        log_capture_string.close()
        getLogger().handlers.pop()
        getLogger().debug("RunBenchmark")

        return {"status": status, "output": output}
Example #5
0
    def run(self, raw_args):
        handlers = []
        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        getLogger().addHandler(ch)
        handlers.append(ch)
        # if enabled realtime logger will also update the log entry at regualr intervals.
        if self.args.rt_logging:
            dbh = DBLogUpdateHandler(self.db, self.job['identifier'],
                                     self.args.rt_logging_interval)
            dbh.setLevel(logging.DEBUG)
            getLogger().addHandler(dbh)
            handlers.append(dbh)
            getLogger().info(
                "Realtime logging enabled with {}s updates.".format(
                    self.args.rt_logging_interval))

        # verify download success before run
        if "download_error_log" in self.job:
            getLogger().error("Error downloading files for job. Skipping run.")
            status = USER_ERROR
            output = self.job["download_error_log"]
        else:
            try:
                app = BenchmarkDriver(raw_args=raw_args)
                getLogger().debug("RunBenchmark")
                status = app.run()
            except Exception as e:
                getLogger().error(e)
                #TODO: handle this exception and ensure that device is responsive
                status = HARNESS_ERROR

        output = log_capture_string.getvalue()
        log_capture_string.close()
        for handler in handlers:
            handler.close()
            getLogger().handlers.remove(handler)
        del (handlers)
        return {"status": status, "output": output}
Example #6
0
    def run(self, raw_args):
        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        getLogger().addHandler(ch)
        # verify download success before run
        if "download_error_log" in self.job:
            getLogger().error("Error downloading files for job. Skipping run.")
            status = USER_ERROR
            output = self.job["download_error_log"]
        else:
            try:
                app = BenchmarkDriver(raw_args=raw_args)
                getLogger().debug("RunBenchmark")
                status = app.run()
            except Exception as e:
                getLogger().error(e)
            finally:
                output = log_capture_string.getvalue()
                log_capture_string.close()
                getLogger().handlers.pop()

        return {"status": status, "output": output}