Ejemplo n.º 1
0
def get_server_command(kind_bench, section_name):
    server_config_file = ''

    server_config_file = server_utils.get_server_cfg_path(kind_bench)
    if server_config_file != '':
        server_config, server_sections = \
                server_utils.read_config_file(server_config_file)
        if section_name in server_sections:
            command = server_config.get(section_name, 'command')
            logging.debug("command is %s" % command)
            return command
        else:
            return None
    else:
        return None
Ejemplo n.º 2
0
def get_server_command(kind_bench, section_name):
    server_config_file = ''

    server_config_file = server_utils.get_server_cfg_path(kind_bench)
    if server_config_file != '':
        server_config, server_sections = \
                server_utils.read_config_file(server_config_file)
        if section_name in server_sections:
            command = server_config.get(section_name, 'command')
            logging.debug("command is %s" % command)
            return command
        else:
            return None
    else:
        return None
Ejemplo n.º 3
0
def build_each_tool(dirname, section_name, des_build_file, arch='x86_86'):
    """
    generate build.sh file for each benchmark tool and run the build.sh
    """

    os.chmod(des_build_file, stat.S_IRWXO + stat.S_IRWXU + stat.S_IRWXG)
    logging.info("=" * 55)
    logging.info("Building %s" % section_name)

    log_name = "%s.log" % section_name
    log_file = os.path.join(TMP_DIR, log_name)
    start_time = datetime.datetime.now()
    try:
        # Fixme : Using shell=True can be a security hazard.
        # See the warning under
        # https://docs.python.org/2/library/subprocess.html?highlight=subprocess.call#frequently-used-arguments.
        result = subprocess.call("echo '$$ %s BUILD START: %s' >> %s"
                                    % (section_name, str(start_time)[:19],
                                        FOLDER.caliper_log_file), shell=True)
        result = subprocess.call("%s %s %s %s >> %s 2>&1"
                                    % (des_build_file, arch,
                                        CALIPER_DIR, TMP_DIR, log_file),
                                        shell=True)
    except Exception:
        logging.info('There is exception when building the benchmarks')
        raise
    else:
        end_time = datetime.datetime.now()
        subprocess.call("echo '$$ %s BUILD STOP: %s' >> %s"
                         % (section_name, str(end_time)[:19],
                             FOLDER.caliper_log_file), shell=True)
        subprocess.call("echo '$$ %s BUILD DURATION: %s Seconds' >> %s"
                              % (section_name, (end_time - start_time).seconds,
                                  FOLDER.caliper_log_file), shell=True)
        if result:
            logging.info("Building Failed")
            logging.info("=" * 55)
            record_log(log_file, arch, 0)
        else:
            logging.info("Building Successful")
            logging.info("=" * 55)
            record_log(log_file, arch, 1)
    server_config = server_utils.get_server_cfg_path(
                                    os.path.join(dirname, section_name))
    # Not sure the server_config related section to be retained...
    if (server_config != ''):
        local_arch = server_utils.get_local_machine_arch()
        if (local_arch != arch):
            result = subprocess.call("%s %s %s %s> %s 2>&1"
                                    % (des_build_file, local_arch,
                                        CALIPER_DIR, TMP_DIR, log_file),
                                        shell=True)
            end_time = datetime.datetime.now()
            subprocess.call("echo '$$ %s BUILD STOP: %s' >> %s"
                            % (section_name, str(end_time)[:19],
                                FOLDER.caliper_log_file), shell=True)
            subprocess.call("echo '$$ %s BUILD DURATION %s Seconds' >> %s"
                            % (section_name, (end_time-start_time).seconds,
                                FOLDER.caliper_log_file), shell=True)
            if result:
                record_log(log_file, local_arch, 0)
            else:
                record_log(log_file, local_arch, 1)
            logging.debug("There is exception when building the benchmarks\
                        for localhost")
    return result
Ejemplo n.º 4
0
def build_each_tool(dirname, section_name, des_build_file, arch='x86_86'):
    """
    generate build.sh file for each benchmark tool and run the build.sh
    """

    os.chmod(des_build_file, stat.S_IRWXO + stat.S_IRWXU + stat.S_IRWXG)
    logging.info("=" * 55)
    logging.info("Building %s" % section_name)

    log_name = "%s.log" % section_name
    log_file = os.path.join(TMP_DIR, log_name)
    start_time = datetime.datetime.now()

    if os.path.exists(FOLDER.caliper_log_file):
        sections = section_name + " BUILD"
        fp = open(FOLDER.caliper_log_file,"r")
        f = fp.readlines()
        fp.close()
        op = open(FOLDER.caliper_log_file,"w")
        for line in f:
            if not(sections in line):
                op.write(line)
        op.close()
    try:
        # Fixme : Using shell=True can be a security hazard.
        # See the warning under
        # https://docs.python.org/2/library/subprocess.html?highlight=subprocess.call#frequently-used-arguments.
        result = subprocess.call("echo '$$ %s BUILD START: %s' >> %s"
                                    % (section_name, str(start_time)[:19],
                                        FOLDER.caliper_log_file), shell=True)
        result = subprocess.call("%s %s %s %s %s >> %s 2>&1"
                                    % (des_build_file, arch,
                                        CALIPER_DIR, TMP_DIR, "/".join(WS_GEN_DIR.split('/')[-2:]), log_file),
                                        shell=True)
    except Exception:
        logging.info('There is exception when building the benchmarks')
        raise
    else:
        end_time = datetime.datetime.now()
        subprocess.call("echo '$$ %s BUILD STOP: %s' >> %s"
                         % (section_name, str(end_time)[:19],
                             FOLDER.caliper_log_file), shell=True)
        subprocess.call("echo '$$ %s BUILD DURATION: %s Seconds' >> %s"
                              % (section_name, (end_time - start_time).seconds,
                                  FOLDER.caliper_log_file), shell=True)
        if result:
            logging.info("Building Failed")
            logging.info("=" * 55)
            record_log(log_file, arch, 0)
        else:
            logging.info("Building Successful")
            logging.info("=" * 55)
            record_log(log_file, arch, 1)
    server_config = server_utils.get_server_cfg_path(
                                    os.path.join(dirname, section_name))
    # Not sure the server_config related section to be retained...
    if (server_config != ''):
        local_arch = server_utils.get_local_machine_arch()
        if (local_arch != arch):
            result = subprocess.call("%s %s %s %s> %s 2>&1"
                                    % (des_build_file, local_arch,
                                        CALIPER_DIR, TMP_DIR, log_file),
                                        shell=True)
            end_time = datetime.datetime.now()
            subprocess.call("echo '$$ %s BUILD STOP: %s' >> %s"
                            % (section_name, str(end_time)[:19],
                                FOLDER.caliper_log_file), shell=True)
            subprocess.call("echo '$$ %s BUILD DURATION %s Seconds' >> %s"
                            % (section_name, (end_time-start_time).seconds,
                                FOLDER.caliper_log_file), shell=True)
            if result:
                record_log(log_file, local_arch, 0)
            else:
                record_log(log_file, local_arch, 1)
            logging.debug("There is exception when building the benchmarks\
                        for localhost")
    return result