Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(description='catapult bench runner')
    parser.add_argument('--exe-path', help='path to executables', required=True)
    parser.add_argument('--out-dir', help='directory in which to store bench output files', required=True)
    parser.add_argument('--dry-run', help='outputs desired commands without runing them', action='store_true')
    args = parser.parse_args()

    process_manager = ProcessManager(args.dry_run)
    environment_manager = EnvironmentManager(args.dry_run)

    for filepath in environment_manager.find_glob(args.exe_path, 'bench*'):
        output_filepath = Path(args.out_dir) / (filepath.name + '.json')
        process_manager.dispatch_subprocess([filepath, '--benchmark_out=' + str(output_filepath)])
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description='catapult tests runner')
    parser.add_argument('--image', help='docker tests image', required=True)
    parser.add_argument('--compiler-configuration',
                        help='path to compiler configuration yaml',
                        required=True)
    parser.add_argument('--user', help='docker user', required=True)
    parser.add_argument('--mode',
                        help='test mode',
                        choices=('bench', 'test', 'lint'),
                        required=True)
    parser.add_argument('--verbosity', help='verbosity level', default='max')
    parser.add_argument('--dry-run',
                        help='outputs desired commands without running them',
                        action='store_true')
    args = parser.parse_args()

    process_manager = ProcessManager(args.dry_run)

    compose_template_directory = Path(__file__).parent / 'templates'
    compose_template_filepath = compose_template_directory / 'Run{}.yaml'.format(
        args.mode.capitalize())
    print('processing template from {}'.format(compose_template_filepath))
    prepare_replacements = {
        'image_name': args.image,
        'compiler_configuration': args.compiler_configuration,
        'user': args.user,
        'verbosity': args.verbosity
    }
    prepare_docker_compose_file(compose_template_filepath,
                                prepare_replacements, sys.stdout)

    if not args.dry_run:
        with open('docker-compose.yaml', 'wt') as outfile:
            prepare_docker_compose_file(compose_template_filepath,
                                        prepare_replacements, outfile)

    environment_manager = EnvironmentManager(args.dry_run)
    environment_manager.set_env_var('COMPOSE_HTTP_TIMEOUT', '200')
    environment_manager.mkdirs(OUTPUT_DIR / 'logs', exist_ok=True)
    environment_manager.mkdirs(OUTPUT_DIR / 'workdir', exist_ok=True)

    if 'test' == args.mode:
        environment_manager.mkdirs(MONGO_DIR / get_image_label(args.image))

    docker_compose_args = create_docker_compose_command(args.mode)
    if process_manager.dispatch_subprocess(docker_compose_args,
                                           handle_error=False):
        print('tests failed')
        sys.exit(1)

    print('tests succeeded')
Beispiel #3
0
def main():
    parser = argparse.ArgumentParser(description='catapult project build generator')
    parser.add_argument('--compiler-configuration', help='path to compiler configuration yaml', required=True)
    parser.add_argument('--build-configuration', help='path to build configuration yaml', required=True)
    parser.add_argument('--operating-system', help='operating system', required=True)
    parser.add_argument('--user', help='docker user', required=True)
    parser.add_argument('--destination-image-label', help='docker destination image label', required=True)
    parser.add_argument('--dry-run', help='outputs desired commands without runing them', action='store_true')
    parser.add_argument('--base-image-names-only', help='only output the base image names', action='store_true')
    args = parser.parse_args()

    options = OptionsManager(args)

    if args.base_image_names_only:
        print(options.build_base_image_name)
        print(options.prepare_base_image_name)
        return

    docker_run = create_docker_run_command(options, args.compiler_configuration, args.build_configuration, args.user)

    environment_manager = EnvironmentManager(args.dry_run)
    environment_manager.rmtree(OUTPUT_DIR)
    environment_manager.mkdirs(BINARIES_DIR)
    environment_manager.mkdirs(options.ccache_path / 'tmp', exist_ok=True)
    environment_manager.mkdirs(options.conan_path, exist_ok=True)

    print('building project')

    process_manager = ProcessManager(args.dry_run)

    return_code = process_manager.dispatch_subprocess(docker_run)
    if return_code:
        sys.exit(return_code)

    print('copying files')

    environment_manager.chdir(OUTPUT_DIR)

    for folder_name in ['scripts', 'seed', 'resources']:
        environment_manager.copy_tree_with_symlinks(SRC_DIR / folder_name, folder_name)

    environment_manager.chdir(SRC_DIR)

    print('building docker image')

    container_id = '<dry_run_container_id>' if args.dry_run else None
    prepare_docker_image(process_manager, container_id, {
        'base_image_name': options.prepare_base_image_name,
        'destination_image_label': args.destination_image_label,
        'build_disposition': options.build_disposition
    })
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser(
        description='catapult project build generator')
    parser.add_argument('--disposition',
                        help='type of image to create',
                        choices=('tests', 'private', 'public'),
                        required=True)
    parser.add_argument('--dry-run',
                        help='outputs desired commands without running them',
                        action='store_true')
    args = parser.parse_args()

    print('preparing {} image'.format(args.disposition))

    process_manager = ProcessManager(args.dry_run)
    environment_manager = EnvironmentManager(args.dry_run)

    is_dev_build = 'tests' == args.disposition
    if is_dev_build:
        for name in ['seed', 'scripts', 'resources']:
            environment_manager.copy_tree_with_symlinks(
                DATA_VOLUME / name, USER_HOME / name)

    bin_folder_names = ['bin', 'deps', 'lib']
    if is_dev_build:
        bin_folder_names.append('tests')

    for name in bin_folder_names:
        environment_manager.copy_tree_with_symlinks(
            DATA_VOLUME / 'binaries' / name, USER_HOME / name)

    # LD_LIBRARY_PATH is not passed when llvm-symbolizer is started via asan, so move libs to system location
    if is_dev_build:
        system_bin_path = environment_manager.system_bin_path
        environment_manager.move_glob_with_symlinks(USER_HOME / 'deps',
                                                    'libLLVM*',
                                                    system_bin_path)
        process_manager.dispatch_subprocess(['ls', '-laF', system_bin_path])

    process_manager.dispatch_subprocess(['ls', '-laF', USER_HOME])

    ls_folder_names = ['bin', 'deps', 'lib']
    if is_dev_build:
        ls_folder_names.extend(['seed', 'scripts', 'resources', 'tests'])

    for name in ls_folder_names:
        process_manager.dispatch_subprocess(['ls', '-laF', USER_HOME / name])
Beispiel #5
0
def main():
    parser = argparse.ArgumentParser(description='catapult test runner')
    parser.add_argument('--compiler-configuration',
                        help='path to compiler configuration yaml',
                        required=True)
    parser.add_argument('--exe-path',
                        help='path to executables',
                        required=True)
    parser.add_argument('--out-dir',
                        help='directory in which to store test output files',
                        required=True)
    parser.add_argument('--verbosity',
                        help='output verbosity',
                        choices=('suite', 'test', 'max'),
                        default='max')
    parser.add_argument('--dry-run',
                        help='outputs desired commands without runing them',
                        action='store_true')
    args = parser.parse_args()

    process_manager = ProcessManager(args.dry_run)
    environment_manager = EnvironmentManager(args.dry_run)

    compiler_configuration = load_compiler_configuration(
        args.compiler_configuration)
    sanitizer_environment = SanitizerEnvironment(
        environment_manager, compiler_configuration.sanitizers)
    sanitizer_environment.prepare()

    prepare_tests(environment_manager)

    process_manager.dispatch_subprocess(['ls', '-laF', '.'])
    process_manager.dispatch_subprocess(['ls', '-laF', '/catapult-data'])
    process_manager.dispatch_subprocess(['ls', '-laF', '/catapult-src'])

    failed_test_suites = []
    for test_exe_filepath in environment_manager.find_glob(
            args.exe_path, 'tests*'):
        base_output_filepath = Path(args.out_dir) / test_exe_filepath.name

        output_filepath = '{}.xml'.format(base_output_filepath)
        test_args = [
            test_exe_filepath, '--gtest_output=xml:{}'.format(output_filepath),
            Path(args.exe_path) / '..' / 'lib'
        ]

        if process_manager.dispatch_test_subprocess(test_args, args.verbosity):
            for core_path in Path('.').glob('core*'):
                handle_core_file(process_manager, core_path, test_exe_filepath,
                                 base_output_filepath)

            failed_test_suites.append(test_exe_filepath)

        process_sanitizer_logs_all(environment_manager, Path(args.out_dir),
                                   test_exe_filepath.name)

    if failed_test_suites:
        print('test failures detected')
        for test_suite in sorted(failed_test_suites):
            print('[*] {}'.format(test_suite))

        sys.exit(len(failed_test_suites))
    else:
        print('all tests succeeded')