예제 #1
0
def summary():
    report = Report()
    report.vm = {}

    hostname = helper.get_hostname()

    summary_header = "SUMMARY @%s \n-- %s --\n %s\n" % (hostname, report.name,
                                                        report.timestamp)
    summary = "\n"
    failed = OrderedDict()
    failed_kind = OrderedDict()
    important_commands = []  # ["BUILD", "CHECK_STATIC"]
    for vm in report.c_received.keys():
        report.vm[vm] = []
        current_proc = None
        summary += "\n[ %s ]\n" % vm
        one_report = False
        for cmd in report.c_received[vm]:
            #cmd = Cmd(c)
            if cmd.name == "REPORT_KIND_END":
                current_proc, report_args = cmd.args
                report.vm[vm].append(current_proc)
                success = "SUCCESS" if cmd.success else "FAILED"
                if not cmd.success:
                    if vm not in failed:
                        failed[vm] = []
                    if current_proc not in failed_kind:
                        failed_kind[current_proc] = []
                    failed_kind[current_proc].append(vm)
                    failed[vm].append(current_proc)
                summary += "    %s: %s\n" % (current_proc, success)
                one_report = True
            else:
                if current_proc:
                    if cmd.success == False:
                        summary += "        %s\n" % (str(cmd))
                    elif cmd.name in important_commands and cmd.success:
                        #check = ['+ ERROR','+ FAILED']
                        #errors = any([ s in c for s in check ])
                        #if errors:
                        summary += "        %s\n" % (red(str(cmd), 80))
        if not one_report:
            if vm not in failed:
                failed[vm] = []
            failed[vm].append("NO REPORT")

    if failed:
        fail_err = "\nFAILED VM:\n"
        for vm, err in failed.items():
            fail_err += "%s %s\n" % (vm, err)
        summary = fail_err + summary

    if failed_kind:
        fail_err = "\nFAILED KIND:\n"
        for kind, err in failed_kind.items():
            fail_err += "%s %s\n" % (kind, err)
        summary = fail_err + summary
        append_retest(failed_kind)

    return summary_header + summary
예제 #2
0
파일: report.py 프로젝트: BwRy/test-av2
def summary():
    report = Report()
    report.vm = {}

    hostname = helper.get_hostname()

    summary_header = "SUMMARY @%s \n-- %s --\n %s\n" % (hostname, report.name, report.timestamp)
    summary = "\n"
    failed = OrderedDict()
    failed_kind = OrderedDict()
    important_commands = [] # ["BUILD", "CHECK_STATIC"]
    for vm in report.c_received.keys():
        report.vm[vm] = []
        current_proc = None
        summary += "\n[ %s ]\n" % vm
        one_report = False
        for cmd in report.c_received[vm]:
            #cmd = Cmd(c)
            if cmd.name == "REPORT_KIND_END":
                current_proc, report_args = cmd.args
                report.vm[vm].append(current_proc)
                success = "SUCCESS" if cmd.success else "FAILED"
                if not cmd.success:
                    if vm not in failed:
                        failed[vm] = []
                    if  current_proc not in failed_kind:
                        failed_kind[current_proc] = []
                    failed_kind[current_proc].append(vm)
                    failed[vm].append(current_proc)
                summary += "    %s: %s\n" % (current_proc, success)
                one_report = True
            else:
                if current_proc:
                    if cmd.success == False:
                        summary+="        %s\n" % (str(cmd))
                    elif cmd.name in important_commands and cmd.success:
                        #check = ['+ ERROR','+ FAILED']
                        #errors = any([ s in c for s in check ])
                        #if errors:
                        summary+="        %s\n" % (red(str(cmd), 80))
        if not one_report:
            if vm not in failed:
                failed[vm] = []
            failed[vm].append("NO REPORT")

    if failed:
        fail_err = "\nFAILED VM:\n"
        for vm, err in failed.items():
            fail_err += "%s %s\n" % (vm, err)
        summary = fail_err + summary

    if failed_kind:
        fail_err = "\nFAILED KIND:\n"
        for kind, err in failed_kind.items():
            fail_err += "%s %s\n" % (kind, err)
        summary = fail_err + summary
        append_retest(failed_kind)

    return summary_header + summary
예제 #3
0
def dump():
    report = Report()

    #f=open("%s/report.%s.%s.yaml" % (logger.logdir, report.timestamp, report.name), "w+")
    #f.write(yaml.dump(report, default_flow_style=False, indent=4))
    #f.close()

    report_name = "%s/report.%s.%s.log" % (logger.logdir, report.timestamp,
                                           report.name)
    sym_rep_name = "%s/last.report.%s.log" % (logger.logdir, report.name)

    f = open(report_name, "w+")
    for vm in report.c_received.keys():
        f.write("\n%s:\n" % vm)
        indent = ""
        for cmd in report.c_received[vm]:
            mark = "  "
            if cmd.name == "REPORT_KIND_END":
                indent = ""
            if cmd.success == False:
                mark = "- "
            f.write("%s    %s%s\n" % (indent, mark, red(str(cmd))))
            if cmd.name == "REPORT_KIND_INIT":
                indent = "    "
        f.write("   SENT: %s\n" % report.c_sent[vm])
    f.close()

    r = summary()
    summary_name = "%s/summary.%s.%s.log" % (logger.logdir, report.timestamp,
                                             report.name)
    sym_sum_name = "%s/last.summary.%s.log" % (logger.logdir, report.name)

    f = open(summary_name, "w+")
    f.write(r)
    f.close()

    return
    if os.path.exists(sym_rep_name):
        logging.debug("removing: %s" % sym_rep_name)
        os.remove(sym_rep_name)
    logging.debug("ln -s %s %s" % (report_name, sym_rep_name))
    os.symlink(report_name, sym_rep_name)

    if os.path.exists(sym_sum_name):
        logging.debug("removing: %s" % sym_sum_name)
        os.remove(sym_sum_name)
    logging.debug("ln -s %s %s" % (summary_name, sym_sum_name))
    os.symlink(summary_name, sym_sum_name)
예제 #4
0
파일: report.py 프로젝트: BwRy/test-av2
def dump():
    report = Report()

    #f=open("%s/report.%s.%s.yaml" % (logger.logdir, report.timestamp, report.name), "w+")
    #f.write(yaml.dump(report, default_flow_style=False, indent=4))
    #f.close()

    report_name = "%s/report.%s.%s.log" % (logger.logdir, report.timestamp, report.name)
    sym_rep_name = "%s/last.report.%s.log" % (logger.logdir, report.name)

    f = open(report_name, "w+")
    for vm in report.c_received.keys():
        f.write("\n%s:\n" % vm)
        indent = ""
        for cmd in report.c_received[vm]:
            mark = "  "
            if cmd.name == "REPORT_KIND_END":
                indent = ""
            if cmd.success == False:
                mark = "- "
            f.write("%s    %s%s\n" % (indent, mark, red(str(cmd))))
            if cmd.name == "REPORT_KIND_INIT":
                indent = "    "
        f.write("   SENT: %s\n" % report.c_sent[vm])
    f.close()

    r = summary()
    summary_name = "%s/summary.%s.%s.log" % (logger.logdir, report.timestamp, report.name)
    sym_sum_name = "%s/last.summary.%s.log" % (logger.logdir, report.name)

    f = open(summary_name, "w+")
    f.write(r)
    f.close()

    return
    if os.path.exists(sym_rep_name):
        logging.debug("removing: %s" % sym_rep_name)
        os.remove(sym_rep_name)
    logging.debug("ln -s %s %s" % (report_name, sym_rep_name))
    os.symlink(report_name, sym_rep_name)

    if os.path.exists(sym_sum_name):
        logging.debug("removing: %s" % sym_sum_name)
        os.remove(sym_sum_name)
    logging.debug("ln -s %s %s" % (summary_name, sym_sum_name))
    os.symlink(summary_name, sym_sum_name)
예제 #5
0
    def dispatch(self, procedure, pool=0):
        global received
        exit = False

        command.context = {}
        procedure.add_begin_end()

        #logging.debug("- SERVER len(procedure): %s" % len(procedure))
        self.num_commands = len(procedure)

        report.init(procedure.name)

        assert self.vms
        assert self.vms[0], "please specify at least one VM"
        logging.debug("self.vms: %s" % self.vms)
        av_machines = OrderedDict()
        p_id = 0
        for vm in self.vms:
            av_machines[vm] = Protocol(self, vm, procedure, id=p_id)
            p_id += 1

        if pool == 0:
            pool = len(self.vms)

        Protocol.pool = pool
        self.pool_start(av_machines.values(), pool)

        self.ended = set()
        answered = 0
        while not exit and len(self.ended) < len(self.vms):
            rec = self.mq.receive_server(blocking=True, timeout=self.timeout)
            if rec is not None:
                c, msg = rec
                try:
                    command_unserialize = command.unserialize(msg)
                except:
                    logging.exception("cannot unserialize: %s" % msg)
                    #exit = True
                    continue
                    #command_unserialize =

                logging.info("- RECEIVED %s, %s" %
                             (c, red(command_unserialize)))
                if c not in av_machines.keys():
                    logging.warn(
                        "A message for %s probably belongs to another test!" %
                        c)
                    continue

                p = av_machines[c]

                try:
                    answer = p.receive_answer(c, command_unserialize)
                except:
                    logging.exception("cannot receive: %s" %
                                      command_unserialize)
                    continue

                report.received(c, command_unserialize)

                if answer.success == None:
                    #logging.debug("- SERVER IGNORING")
                    continue

                answered += 1
                #logging.debug("- SERVER RECEIVED ANSWER: %s" % answer.success)
                if answer.name == "END":
                    self.end(c)
                    logging.info("- RECEIVE END: %s, %s" % (c, self.ended))
                    logging.debug("self.ended: (%s/%s) %s" %
                                  (len(self.ended), len(self.vms), self.ended))

                elif p.on_error != "DISABLED" and (answer.success or p.on_error
                                                   == "CONTINUE"):
                    r = p.send_next_command()
                    cmd = p.last_command

                    report.sent(p.vm, cmd)

                    logging.info("- SENT: %s, %s" % (c, red(cmd)))
                    if not r:
                        logging.info("- SENDING ERROR, ENDING: %s" % c)
                        self.end(c)
                        logging.debug(
                            "self.ended: (%s/%s) %s" %
                            (len(self.ended), len(self.vms), self.ended))

                else:
                    # answer.success == False
                    # deve skippare fino al command: END_PROC

                    if p.on_error == "SKIP":
                        logging.debug("on_error == %s" % p.on_error)
                        r = p.send_next_call()
                        cmd = p.last_command
                        if cmd:
                            report.sent(p.vm, cmd)
                        else:
                            logging.info("- RECEIVE ERROR, ENDING: %s" % c)
                            self.end(c)
                            logging.debug(
                                "self.ended: (%s/%s) %s" %
                                (len(self.ended), len(self.vms), self.ended))
                    elif p.on_error == "DISABLED":
                        logging.debug("on_error == DISABLED")
                        r = p.send_next_proc()
                        cmd = p.last_command
                        if cmd:
                            report.sent(p.vm, cmd)
                        else:
                            logging.info("- RECEIVE ERROR, ENDING: %s" % c)
                            self.end(c)
                            logging.debug(
                                "self.ended: (%s/%s) %s" %
                                (len(self.ended), len(self.vms), self.ended))
                    else:
                        assert p.on_error == "STOP"

                        logging.info("- RECEIVE ERROR, STOP: %s" % c)
                        self.end(c)
                        logging.debug(
                            "self.ended: (%s/%s) %s" %
                            (len(self.ended), len(self.vms), self.ended))

            else:
                logging.info("- SERVER RECEIVED empty")
                exit = True

        report.finish()

        logging.debug("answered: %s, ended: %s, num_commands: %s" %
                      (answered, len(self.ended), self.num_commands))
        assert len(self.ended) == len(
            self.vms), "answered: %s, ended: %s, num_commands: %s" % (
                answered, len(self.ended), len(self.vms))
        #assert answered >= (len(self.vms) * (self.num_commands)), "answered: %s, len(vms): %s, num_commands: %s" % (answered , len(self.vms), self.num_commands)
        return answered
예제 #6
0
파일: dispatcher.py 프로젝트: BwRy/test-av2
    def dispatch(self, procedure, pool=0 ):
        global received
        exit = False

        command.context = {}
        procedure.add_begin_end()

        #logging.debug("- SERVER len(procedure): %s" % len(procedure))
        self.num_commands = len(procedure)

        report.init(procedure.name)

        assert self.vms
        assert self.vms[0], "please specify at least one VM"
        logging.debug("self.vms: %s" % self.vms)
        av_machines = OrderedDict()
        p_id = 0
        for vm in self.vms:
            av_machines[vm] = Protocol(self, vm, procedure, id = p_id)
            p_id += 1

        if pool == 0:
            pool = len(self.vms)

        Protocol.pool = pool
        self.pool_start(av_machines.values(), pool)

        self.ended = set()
        answered = 0
        while not exit and len(self.ended) < len(self.vms):
            rec = self.mq.receive_server(blocking=True, timeout=self.timeout)
            if rec is not None:
                c, msg = rec
                try:
                    command_unserialize = command.unserialize(msg)
                except:
                    logging.exception("cannot unserialize: %s" % msg)
                    #exit = True
                    continue
                    #command_unserialize =

                logging.info("- RECEIVED %s, %s" % (c, red(command_unserialize)))
                if c not in av_machines.keys():
                    logging.warn("A message for %s probably belongs to another test!" % c)
                    continue

                p = av_machines[c]

                try:
                    answer = p.receive_answer(c, command_unserialize)
                except:
                    logging.exception("cannot receive: %s" % command_unserialize)
                    continue

                report.received(c, command_unserialize)

                if answer.success == None:
                    #logging.debug("- SERVER IGNORING")
                    continue

                answered += 1
                #logging.debug("- SERVER RECEIVED ANSWER: %s" % answer.success)
                if answer.name == "END":
                    self.end(c)
                    logging.info("- RECEIVE END: %s, %s" % (c, self.ended))
                    logging.debug("self.ended: (%s/%s) %s" % (len(self.ended), len(self.vms), self.ended))

                elif p.on_error != "DISABLED" and (answer.success or p.on_error == "CONTINUE"):
                    r = p.send_next_command()
                    cmd = p.last_command

                    report.sent(p.vm, cmd)

                    logging.info("- SENT: %s, %s" % (c, red(cmd)))
                    if not r:
                        logging.info("- SENDING ERROR, ENDING: %s" %c)
                        self.end(c)
                        logging.debug("self.ended: (%s/%s) %s" % (len(self.ended), len(self.vms), self.ended))

                else:
                    # answer.success == False
                    # deve skippare fino al command: END_PROC

                    if p.on_error == "SKIP":
                        logging.debug("on_error == %s" % p.on_error)
                        r = p.send_next_call()
                        cmd = p.last_command
                        if cmd:
                            report.sent(p.vm, cmd)
                        else:
                            logging.info("- RECEIVE ERROR, ENDING: %s" %c)
                            self.end(c)
                            logging.debug("self.ended: (%s/%s) %s" % (len(self.ended), len(self.vms), self.ended))
                    elif p.on_error == "DISABLED":
                        logging.debug("on_error == DISABLED")
                        r = p.send_next_proc()
                        cmd = p.last_command
                        if cmd:
                            report.sent(p.vm, cmd)
                        else:
                            logging.info("- RECEIVE ERROR, ENDING: %s" %c)
                            self.end(c)
                            logging.debug("self.ended: (%s/%s) %s" % (len(self.ended), len(self.vms), self.ended))
                    else:
                        assert p.on_error == "STOP"

                        logging.info("- RECEIVE ERROR, STOP: %s" %c)
                        self.end(c)
                        logging.debug("self.ended: (%s/%s) %s" % (len(self.ended), len(self.vms), self.ended))

            else:
                logging.info("- SERVER RECEIVED empty")
                exit = True

        report.finish()

        logging.debug("answered: %s, ended: %s, num_commands: %s" % ( answered, len(self.ended), self.num_commands))
        assert len(self.ended) == len(self.vms), "answered: %s, ended: %s, num_commands: %s" % ( answered, len(self.ended), len(self.vms))
        #assert answered >= (len(self.vms) * (self.num_commands)), "answered: %s, len(vms): %s, num_commands: %s" % (answered , len(self.vms), self.num_commands)
        return answered