Exemplo n.º 1
0
    def describe_results(self, results):
        """Pretty printer for results"""

        x = prettytable.PrettyTable(["Group", "Plugin", "Test", "Time Duration", "Status"])

        x.add_row([self.group_name, "", "", "", ""])
        for key in results.iterkeys():

            if results[key].get('major_crash') is not None:
                LOG.info("A major tool failure has been detected for plugin '%s'" % key)
                continue
            if not validate_section(results[key]):
                LOG.debug('Error: no results for %s' % key)
                continue

            test_success = results[key]['results']['test_success']
            test_failures = results[key]['results']['test_failures']
            test_not_found = results[key]['results']['test_not_found']
            time_of_tests = results[key]['results']['time_of_tests']

            msg = ""

            if test_success:
                msg += "SUCCESSFUL: " + str(len(test_success)) + ", "
            if test_failures:
                msg += "FAILED: " + str(len(test_failures)) + ", "
            if test_not_found:
                msg += "NOT FOUND: " + str(len(test_not_found)) + ", "
            msg = msg[:-2]

            x.add_row(["", key, msg, "", ""])

            time_of_test = lambda x: time_of_tests[x].get('duration', '0s') if time_of_tests.get(x, None) else '0s'

            for test in test_success:
                x.add_row(["", "", test, time_of_test(test), " OK "])
            for test in test_failures:
                x.add_row(["", "", test, time_of_test(test), " FAILED "])
            for test in test_not_found:
                x.add_row(["", "", test, time_of_test(test), " NOT FOUND "])
            x.add_row(["", "", "", "", ""])

        x.align = "l"
        print(x)
Exemplo n.º 2
0
    def update_config(self, results):
        with open(DEFAULT_CONFIG_FILE, 'r') as f:
            file_to_string = f.read()

        result = self._search_and_remove_group_failed(file_to_string)

        default_str = ""
        for key in results.iterkeys():
            if not validate_section(results[key], 'test_failures'):
                continue
            to_rerun = ",".join(results[key]["results"]["test_failures"])
            if to_rerun != "":
                default_str = (default_str + str(key) + '=' +
                               str(to_rerun) + '\n')
        if default_str != "":
            default_str = ("\n[custom_test_group_failed]\n" +
                           default_str + "# End of group failed. Don't remove"
                           + "this comment\n")

        with open(DEFAULT_CONFIG_FILE, 'w') as f:
            f.write(result + default_str)
Exemplo n.º 3
0
 def update_scenario(run_results):
     failed_test_section = 'failed'
     test_failures = 'test_failures'
     results = 'results'
     with open(CONF.basic.scenario, 'r+') as f:
         yaml = ruamel.yaml.load(f, ruamel.yaml.RoundTripLoader)
         yaml_copy = copy.deepcopy(yaml)
         if failed_test_section in yaml:
             del yaml[failed_test_section]
         group = {}
         for key, value in run_results.iteritems():
             if not validate_section(value, test_failures):
                 continue
             failures = value[results][test_failures]
             if failures:
                 group[key] = failures
         if group:
             yaml[failed_test_section] = group
         if yaml != yaml_copy:
             f.seek(0)
             ruamel.yaml.dump(yaml, f, ruamel.yaml.RoundTripDumper,
                              block_seq_indent=2)
             f.truncate()
Exemplo n.º 4
0
 def get_total_failures(self, results):
     t_failures = 0
     for key in results.iterkeys():
         if validate_section(results[key], 'test_failures'):
             t_failures += len(results[key]['results']['test_failures'])
     return t_failures
Exemplo n.º 5
0
    def describe_results(self, results):
        """Pretty printer for results"""

        def time_of_test(t):
            return time_of_tests.get(t, {}).get('duration', '0s')

        def get(item, default=None):
            return results[key].get('results', {}).get(item, default)

        res_table = prettytable.PrettyTable(
            ["Group", "Plugin", "Test", "Time Duration", "Status"])

        res_table.add_row([self.group_name, "", "", "", ""])
        for key in results.iterkeys():

            if results[key].get('major_crash') is not None:
                LOG.info(
                    "A major tool failure has been detected for plugin '%s'",
                    key)
                continue
            if not validate_section(results[key]):
                LOG.debug('Error: no results for %s', key)
                continue

            test_success = get('test_success', [])
            test_failures = get('test_failures', [])
            test_not_found = get('test_not_found', [])
            test_without_report = get('test_without_report', [])
            test_skipped = get('test_skipped', [])
            time_of_tests = get('time_of_tests', {})

            tempest_tests_details = get('tempest_tests_details', {})

            if tempest_tests_details:
                for suit, suit_results in tempest_tests_details.iteritems():
                    status = ("FAILED" if suit_results["test_failed"]
                              else "SUCCESS")
                    suit_res = TEMPEST_OUTPUT_TEMPLATE.format(**suit_results)
                    msg = "{suit}\n{res}".format(suit=suit,
                                                 res=suit_res)

                    res_table.add_row(
                        ["", key, msg, time_of_test(suit), status])
            else:
                msg_parts = []
                if test_success:
                    msg_parts.append("Successful: {}".format(
                        len(test_success)))
                if test_failures or test_without_report:
                    msg_parts.append("Failed: {}"
                                     .format(len(test_failures +
                                                 test_without_report)))
                if test_not_found:
                    msg_parts.append("Not found: {}"
                                     .format(len(test_not_found)))
                if test_skipped:
                    msg_parts.append("Skipped: {}"
                                     .format(len(test_skipped)))

                msg = ", ".join(msg_parts)

                res_table.add_row(["", key, msg, "", ""])

                for test in test_success:
                    res_table.add_row(
                        ["", "", test, time_of_test(test), " OK "])
                for test in (test_failures + test_without_report):
                    res_table.add_row(
                        ["", "", test, time_of_test(test), " FAILED "])
                for test in test_not_found:
                    res_table.add_row(
                        ["", "", test, time_of_test(test), " NOT FOUND "])
                for test in test_skipped:
                    res_table.add_row(
                        ["", "", test, time_of_test(test), " SKIPPED "])
            res_table.add_row(["", "", "", "", ""])

        res_table.align = "l"
        print(res_table)