def writeScript(self, script):
        """Write the FunkLoad test script."""
        from pkg_resources import resource_string

        tpl_name = 'data/ScriptTestCase.tpl'
        trace('Creating script: %s.\n' % self.script_path)
        tpl = resource_string('collective.funkload', tpl_name)
        content = tpl % {'script': script,
                         'test_name': self.test_name,
                         'class_name': self.class_name}

        if os.path.exists(self.script_path):
            trace("Error file %s already exists.\n" % self.script_path)
            return
        f = open(self.script_path, 'w')
        f.write(content)
        f.close()
Example #2
0
    def _generate_trend(self, result_files, title):
        # building single reports
        reports = []
        target = get_report_dir(self.reports_dir, title)
        os.mkdir(target)

        for index, result in enumerate(result_files):
            loc = os.path.join(target, '_%d' % index)
            reports.append(os.path.dirname(generate_report(result, loc)))

        # next, let's build the trend report
        options = _Options(report_dir=target)
        try:
            html_path = RenderTrend(reports, options)
            print(html_path)   # weird
        except (Exception, RuntimeError),  e:
            trace(str(e))
            res = u'Failed to generate the report'
Example #3
0
    def _generate_diff(self, result_files, title):
        if len(result_files) != 2:
            self._redirect(warning=u'You need to select 2 files.')
        # building single reports
        reports = []
        target = get_report_dir(self.reports_dir, title)
        os.mkdir(target)
        for index, result in enumerate(result_files):
            loc = os.path.join(target, '_%d' % index)
            reports.append(os.path.dirname(generate_report(result, loc)))

        options = _Options(report_dir=target)

        try:
            html_path = RenderDiff(reports[0], reports[1], options)
            print(html_path)  # weird
        except (Exception, RuntimeError),  e:
            trace(str(e))
            res = u'Failed to generate the report'
Example #4
0
def build_diff_report(options, directory_1, directory_2):
    """Build a differential report for the given HTML report directories"""
    utils.trace("Creating diff report ...")
    output_dir = options.output_dir
    html_path = ReportRenderDiff.RenderDiff(
        directory_1, directory_2, options)
    utils.trace("done: \n")
    utils.trace("%s\n" % html_path)
    return os.path.dirname(str(html_path))
Example #5
0
def build_index(directory, x_labels, y_labels,
                reverse=report.reverse_option.default,
                title=title_option.default,
                sub_title=sub_title_option.default,
                input_=input_option.default):
    utils.trace("Creating report index ...")
    html_path = os.path.join(directory, 'index.html')
    template = pagetemplatefile.PageTemplateFile('label.pt')
    open(html_path, 'w').write(
        template(x_labels=x_labels, y_labels=y_labels, reverse=reverse,
                title=title, sub_title=sub_title, input_=input_.read()))
    utils.trace("done: \n")
    utils.trace("file://%s\n" % html_path)
    return html_path
Example #6
0
def build_html_report(options, xml_file):
    """Build a HTML report for the given XML bench results file"""
    options.xml_file = xml_file
    options.html = True
    xml_parser = ReportBuilder.FunkLoadXmlParser()
    xml_parser.parse(xml_file)
    utils.trace("Creating html report ...")
    html_path = ReportRenderHtml.RenderHtml(
        xml_parser.config, xml_parser.stats,
        xml_parser.error, xml_parser.monitor,
        options)()
    report = os.path.dirname(html_path)
    os.rename(xml_file[:-4] + '.log',
              os.path.join(report, 'funkload.log'))
    assert os.path.isfile(os.path.join(report, 'funkload.xml'))
    os.remove(xml_file)
    utils.trace("done: \n")
    utils.trace("file://%s\n" % html_path)
    return report
Example #7
0
def build_diff(options, report_dir1, report_dir2):
    utils.trace("Creating diff report ...")
    html_path = ReportRenderDiff.RenderDiff(
        report_dir1, report_dir2, options)
    utils.trace("done: \n")
    utils.trace("file://%s\n" % html_path)