Пример #1
0
    def _run_perf(self, test_case, inputs):
        _log.info('Running test case: %s', test_case)

        output_file = '%s/run-%s/result-%s.out' % \
          (self.args.out_dir, test_case.run_id, test_case.run_subid)
        _log.info('Writing to output file %s', output_file)

        header = '''### run_id {run_id}:{run_subid}
### date {now}
### settings {test_case}
'''.format(run_id=test_case.run_id,
           run_subid=test_case.run_subid,
           now=time.ctime(),
           test_case=json.dumps(test_case.to_yaml()))

        with open(output_file + '.raw', 'w') as fh:
            fh.write(header)
            cmdline = inputs.dnsperf_cmdline
            code, out, err = self._kubectl(
                *([None, 'exec', _client_podname, '--'] +
                  [str(x) for x in cmdline]))
            fh.write('%s\n' % add_prefix('out | ', out))
            fh.write('%s\n' % add_prefix('err | ', err))

            if code != 0:
                raise Exception('error running dnsperf')

        with open(output_file, 'w') as fh:
            results = {}
            results['params'] = test_case.to_yaml()
            results['code'] = code
            results['stdout'] = out.split('\n')
            results['stderr'] = err.split('\n')
            results['data'] = {}

            try:
                parser = Parser(out)
                parser.parse()

                _log.info('Test results parsed')

                results['data']['ok'] = True
                results['data']['msg'] = None

                for key, value in parser.results.items():
                    results['data'][key] = value
                results['data']['histogram'] = parser.histogram
            except Exception, exc:
                _log.error('Error parsing results: %s', exc)
                results['data']['ok'] = False
                results['data'][
                    'msg'] = 'parsing error:\n%s' % traceback.format_exc()

            fh.write(yaml.dump(results))

            if self.db is not None and results['data']['ok']:
                self.db.put(results)
Пример #2
0
def game_loop():
    game = build_game()
    parser = Parser(game)
    game.describe()

    while True:
        command = input(">").lower()
        if not (command == "quit" or command == "q"):
            end_game = parser.parse_command(command)
            if end_game:
                return
        else:
            return
 def on_actionSave_triggered(self):
     file_dialog = QFileDialog()
     file_dialog.setAcceptMode(QFileDialog.AcceptSave)
     file_dialog.setFileMode(QFileDialog.AnyFile)
     file_dialog.setNameFilter("XML(*.xml)")
     file_dialog.setDefaultSuffix("xml")
     if file_dialog.exec_():
         file_path = file_dialog.selectedFiles()[0]
         if file_path.endswith("xml"):
             file = open(file_path, "w+")
             file.write(Parser.parse_issues(self.issues))
             file.close()
             self.statusbar.showMessage("Dane zostały zapisane do pliku")
 def on_actionOpen_triggered(self):
     file_dialog = QFileDialog()
     file_dialog.setAcceptMode(QFileDialog.AcceptOpen)
     file_dialog.setFileMode(QFileDialog.ExistingFile)
     file_dialog.setNameFilter("XML(*.xml)")
     file_dialog.setDefaultSuffix("xml")
     if file_dialog.exec_():
         file_path = file_dialog.selectedFiles()[0]
         if file_path.endswith("xml"):
             self.optionModel.issue_selected = -1
             self.issues.clear()
             self.issues.extend(Parser.parse_file(file_path))
             self.issueModel.layoutChanged.emit()
             self.optionModel.layoutChanged.emit()
             self.rankingModel.layoutChanged.emit()
             self.chooseModel.layoutChanged.emit()
             self.statusbar.showMessage("Dane zostały wczytane z pliku")
 def test_parser(self):
     raw = open('fixtures/raw.txt').read()
     parser = Parser(raw)
     parser.parse()
     # Check a subset of fields
     self.assertEquals(1000, parser.results['queries_sent'])
Пример #6
0
  def _run_perf(self, test_case, inputs, podname):
    _log.info('Running test case: %s', test_case)

    output_file = '%s/run-%s/result-%s-%s.out' % \
      (self.args.out_dir, test_case.run_id, test_case.run_subid, test_case.pod_name)
    _log.info('Writing to output file %s', output_file)
    res_usage = queue.Queue()
    dt = threading.Thread(target=self._run_top,args=[res_usage])
    dt.start()
    header = '''### run_id {run_id}:{run_subid}
### date {now}
### settings {test_case}
'''.format(run_id=test_case.run_id,
           run_subid=test_case.run_subid,
           now=time.ctime(),
           test_case=json.dumps(test_case.to_yaml()))

    with open(output_file + '.raw', 'w') as fh:
      fh.write(header)
      cmdline = inputs.dnsperf_cmdline
      code, out, err = self._kubectl(
          *([None, 'exec', podname, '--'] + [str(x) for x in cmdline]))
      fh.write('%s\n' % add_prefix('out | ', out))
      fh.write('%s\n' % add_prefix('err | ', err))

      if code != 0:
        raise Exception('error running dnsperf - %s, podname %s', err, podname)

    dt.join()

    with open(output_file, 'w') as fh:
      results = {}
      results['params'] = test_case.to_yaml()
      results['code'] = code
      results['stdout'] = out.split('\n')
      results['stderr'] = err.split('\n')
      results['data'] = {}

      try:
        parser = Parser(out)
        parser.parse()

        _log.info('Test results parsed')

        results['data']['ok'] = True
        results['data']['msg'] = None

        for key, value in list(parser.results.items()):
          results['data'][key] = value
        results['data']['max_perfserver_cpu'] = res_usage.get()
        results['data']['max_perfserver_memory'] = res_usage.get()
        results['data']['max_kubedns_cpu'] = res_usage.get()
        results['data']['max_kubedns_memory'] = res_usage.get()
        results['data']['histogram'] = parser.histogram
      except Exception:
        _log.exception('Error parsing results.')
        results['data']['ok'] = False
        results['data']['msg'] = 'parsing error:\n%s' % traceback.format_exc()

      fh.write(yaml.dump(results))

      if self.db is not None and results['data']['ok']:
        self.db.put(results)