Beispiel #1
0
def main():
    try:
        args = parse_args(sys.argv)
        loop = asyncio.get_event_loop()

        os_manager = OSManager()
        os_type = os_manager._get_current_os()
        notifier = Notifier(os_type)
        process_manager = ProcessManager(notifier)

        plugin = Plugin(port=args['port'],
                        pluginUUID=args['pluginUUID'],
                        registerEvent=args['registerEvent'],
                        info=args['info'],
                        loop=loop,
                        process_manager=process_manager,
                        os_manager=os_manager)

        loop.run_until_complete(
            asyncio.gather(plugin.listen(), process_manager.process()))
        loop.run_forever()
        loop.stop()
        loop.close()
    except Exception as err:
        logging.critical(err)
        loop.stop()
        loop.close()
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 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 #4
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
    })
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('--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)

    builder = BuildManager(args, process_manager, environment_manager)
    env = LinuxEnvironment(builder.use_conan, process_manager,
                           environment_manager)
    env.prepare()

    if builder.use_conan:
        env.prepare_conan({
            'version': builder.compiler.version,
            'libcxx': builder.stl.lib
        })
        env.run_conan_install()

    builder.run_cmake()
    builder.build()
    builder.copy_files()
Beispiel #6
0
        def t_spawn_server(self, android_id, port):
            # TODO: Manage appium logfile

            transaction.begin
            if not self._check_socket(self.appium_config["appiumHost"], port) \
                    and not ProcessManager().get_process_port(port):
                self.lock.acquire()
                script = self._create_appium_bash_script(android_id, port)
                proc = subprocess32.Popen(script, shell=True)
                self._check_socket(self.appium_config["appiumHost"], port)
                pm = ProcessManager()
                pm.store(proc.pid, port)
                self.root.processList[android_id] = pm
                self.lock.release()
            else:
                transaction.abort
                exit(-1)

            transaction.commit()
            return proc.pid
Beispiel #7
0
class Operator(object):
    def __init__(self):
        self.pm = ProcessManager()

    def run(self):
        self.pm.load_config()
        self.pm.setup()
        self.pm.run()
Beispiel #8
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 #9
0
def main():
    parser = argparse.ArgumentParser(description='catapult lint runner')
    parser.add_argument('--out-dir', help='directory in which to store lint 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)
    environment_manager.set_env_var('HOME', '/tmp')

    run_cpp_linters(process_manager, args.out_dir)

    environment_manager.chdir('scripts')

    linter_runner = LinterRunner(process_manager, args.out_dir, args.dry_run)
    run_shell_linters(linter_runner, find_files_with_extension(environment_manager, '.sh'))
    run_python_linters(linter_runner, find_files_with_extension(environment_manager, '.py'))
def main():
    parser = argparse.ArgumentParser(
        description='download and install catapult dependencies locally')
    parser.add_argument('--target',
                        help='target dependencies directory',
                        required=True)
    parser.add_argument('--versions',
                        help='locked versions file',
                        required=True)
    parser.add_argument('--download',
                        help='download all dependencies',
                        action='store_true')
    parser.add_argument('--build',
                        help='build all dependencies',
                        action='store_true')
    parser.add_argument('--use-clang',
                        help='uses clang compiler instead of gcc',
                        action='store_true')
    parser.add_argument('--dry-run',
                        help='outputs desired commands without running them',
                        action='store_true')
    parser.add_argument('--force',
                        help='purges any existing files',
                        action='store_true')
    args = parser.parse_args()

    versions = load_versions_map(args.versions)

    environment_manager = EnvironmentManager(args.dry_run)
    if args.force:
        environment_manager.rmtree(args.target)

    target_directory = Path(args.target).absolute()

    source_directory = Path(args.target) / SOURCE_DIR_NAME
    environment_manager.mkdirs(source_directory, exist_ok=True)
    environment_manager.chdir(source_directory)

    process_manager = ProcessManager(args.dry_run)

    dependency_repositories = [('google', 'googletest'),
                               ('google', 'benchmark'),
                               ('mongodb', 'mongo-c-driver'),
                               ('mongodb', 'mongo-cxx-driver'),
                               ('zeromq', 'libzmq'), ('zeromq', 'cppzmq'),
                               ('facebook', 'rocksdb')]

    if args.download:
        print('[x] downloading all dependencies')
        downloader = Downloader(versions, process_manager)
        downloader.download_boost()

        for repository in dependency_repositories:
            downloader.download_git_dependency(repository[0], repository[1])

    if args.build:
        print('[x] building all dependencies')
        builder = Builder(target_directory, versions, process_manager,
                          environment_manager)
        if args.use_clang:
            builder.use_clang()

        builder.build_boost()

        for repository in dependency_repositories:
            builder.build_git_dependency(repository[0], repository[1])
Beispiel #11
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')
Beispiel #12
0
 def __init__(self):
     self.pm = ProcessManager()