Пример #1
0
    def add(self, results, counter_results=None):
        """
        accumulate one cycle of results
        - results : TalosResults instance or path to browser log
        - counter_results : counters accumulated for this cycle
        """

        # convert to a results class via parsing the browser log
        format_pagename = True
        if not self.test_config['format_pagename']:
            format_pagename = False

        browserLog = BrowserLogResults(results,
                                       format_pagename=format_pagename,
                                       counter_results=counter_results,
                                       global_counters=self.global_counters)
        results = browserLog.results()

        self.using_xperf = browserLog.using_xperf
        # ensure the results format matches previous results
        if self.results:
            if not results.format == self.results[0].format:
                raise utils.TalosError("Conflicting formats for results")
        else:
            self.format = results.format

        self.results.append(results)

        if counter_results:
            self.all_counter_results.append(counter_results)
Пример #2
0
    def __init__(self,
                 results_raw,
                 format_pagename=True,
                 counter_results=None,
                 global_counters=None):
        """
        - shutdown : whether to record shutdown results or not
        """

        self.counter_results = counter_results
        self.global_counters = global_counters
        self.format_pagename = format_pagename
        self.results_raw = results_raw

        # parse the results
        try:
            match = self.RESULTS_REGEX_FAIL.search(self.results_raw)
            if match:
                self.error(match.group(1))
                raise utils.TalosError(match.group(1))

            self.parse()
        except utils.TalosError:
            # TODO: consider investigating this further or adding additional
            # information
            raise  # reraise failing exception

        # accumulate counter results
        self.counters(self.counter_results, self.global_counters)
Пример #3
0
    def results(self):
        """return results instance appropriate to the format detected"""

        if self.format not in self.classes:
            raise utils.TalosError(
                "Unable to find a results class for format: %s" %
                repr(self.format))

        return self.classes[self.format](self.browser_results)
Пример #4
0
    def check_output_formats(self, output_formats):
        """check output formats"""

        # ensure formats are available
        formats = output_formats.keys()
        missing = self.check_formats_exist(formats)
        if missing:
            raise utils.TalosError("Output format(s) unknown: %s" %
                                   ','.join(missing))

        # perform per-format check
        for format, urls in output_formats.items():
            cls = output.formats[format]
            cls.check(urls)
Пример #5
0
    def xperf(self, counter_results):
        """record xperf counters in counter_results dictionary"""

        session_store_counter = 'time_to_session_store_window_restored_ms'

        counters = [
            'main_startup_fileio',
            'main_startup_netio',
            'main_normal_fileio',
            'main_normal_netio',
            'nonmain_startup_fileio',
            'nonmain_normal_fileio',
            'nonmain_normal_netio',
            session_store_counter,
        ]

        mainthread_counter_keys = [
            'readcount', 'readbytes', 'writecount', 'writebytes'
        ]
        mainthread_counters = [
            '_'.join(['mainthread', counter_key])
            for counter_key in mainthread_counter_keys
        ]

        self.mainthread_io(counter_results)

        if not set(counters).union(set(mainthread_counters)) \
                .intersection(counter_results.keys()):
            # no xperf counters to accumulate
            return

        filename = 'etl_output_thread_stats.csv'
        if not os.path.exists(filename):
            raise utils.TalosError(
                "Error: we are looking for xperf results file %s,"
                " and didn't find it" % filename)

        contents = open(filename).read()
        lines = contents.splitlines()
        reader = csv.reader(lines)
        header = None
        for row in reader:
            # Read CSV
            row = [i.strip() for i in row]
            if not header:
                # We are assuming the first row is the header and all other
                # data is counters
                header = row
                continue
            values = dict(zip(header, row))

            # Format for talos
            thread = values['thread']
            counter = values['counter'].rsplit('_io_bytes', 1)[0]
            counter_name = '%s_%s_%sio' % (thread, values['stage'], counter)
            value = float(values['value'])

            # Accrue counter
            if counter_name in counter_results:
                counter_results.setdefault(counter_name, []).append(value)
                self.using_xperf = True

        if (set(mainthread_counters).intersection(counter_results.keys())):
            filename = 'etl_output.csv'
            if not os.path.exists(filename):
                raise utils.TalosError(
                    "Error: we are looking for xperf results file"
                    " %s, and didn't find it" % filename)

            contents = open(filename).read()
            lines = contents.splitlines()
            reader = csv.reader(lines)
            header = None
            for row in reader:
                row = [i.strip() for i in row]
                if not header:
                    # We are assuming the first row is the header and all
                    # other data is counters
                    header = row
                    continue
                values = dict(zip(header, row))
                for i, mainthread_counter in enumerate(mainthread_counters):
                    if int(values[mainthread_counter_keys[i]]) > 0:
                        counter_results.setdefault(mainthread_counter, []) \
                            .append([int(values[mainthread_counter_keys[i]]),
                                     values['filename']])

        if session_store_counter in counter_results.keys():
            filename = 'etl_output_session_restore_stats.csv'
            # This file is a csv but it only contains one field, so we'll just
            # obtain the value by converting the second line in the file.
            with open(filename, 'r') as contents:
                lines = contents.read().splitlines()
                value = float(lines[1].strip())
                counter_results.setdefault(session_store_counter,
                                           []).append(value)
Пример #6
0
 def error(self, message):
     """raise a TalosError for bad parsing of the browser log"""
     raise utils.TalosError(message)