コード例 #1
0
def run(build_directory, get_command, args):
    if args.fixed_seed:
        seed(getpass.getuser())

    hosts = args.nodes
    if not hosts:
        hosts = ["localhost"] * number_of_local_nodes()

    LOG.info("Starting nodes on {}".format(hosts))

    with infra.ccf.network(hosts,
                           args.build_dir,
                           args.debug_nodes,
                           args.perf_nodes,
                           pdb=args.pdb) as network:
        primary, backups = network.start_and_join(args)

        command_args = get_command_args(args, get_command)

        if args.network_only:
            run_client(args, primary, command_args)
        else:
            nodes = filter_nodes(primary, backups, args.send_tx_to)
            clients = []
            client_hosts = args.client_nodes or ["localhost"]
            for client_id, client_host in enumerate(client_hosts):
                node = nodes[client_id % len(nodes)]
                remote_client = configure_remote_client(
                    args, client_id, client_host, node, command_args)
                clients.append(remote_client)

            for remote_client in clients:
                remote_client.start()

            try:
                metrics = cimetrics.upload.Metrics()
                tx_rates = infra.rates.TxRates(primary)
                while True:
                    if not tx_rates.process_next():
                        for i, remote_client in enumerate(clients):
                            remote_client.wait()
                            remote_client.print_and_upload_result(
                                args.label, metrics)
                            remote_client.stop()
                        break
                    time.sleep(1)

                LOG.info(f"Rates: {tx_rates}")
                tx_rates.save_results(args.metrics_file)
                metrics.publish()

            except KeyboardInterrupt:
                for remote_client in clients:
                    remote_client.stop()
コード例 #2
0
ファイル: runner.py プロジェクト: tempbottle/CCF
def run(build_directory, get_command, args):
    if args.fixed_seed:
        seed(getpass.getuser())

    hosts = args.nodes
    if not hosts:
        hosts = ["localhost"] * number_of_local_nodes()

    LOG.info("Starting nodes on {}".format(hosts))

    with infra.ccf.network(hosts,
                           args.build_dir,
                           args.debug_nodes,
                           args.perf_nodes,
                           pdb=args.pdb) as network:
        primary, followers = network.start_and_join(args)

        command_args = get_command_args(args, get_command)

        if args.network_only:
            run_client(args, primary, command_args)
        else:
            nodes = filter_nodes(primary, followers, args.send_tx_to)
            clients = []
            client_hosts = args.client_nodes or ["localhost"]
            for client_id, client_host in enumerate(client_hosts):
                node = nodes[client_id % len(nodes)]
                remote_client = configure_remote_client(
                    args, client_id, client_host, node, command_args)
                clients.append(remote_client)

            for remote_client in clients:
                remote_client.start()

            try:
                tx_rates = infra.rates.TxRates(primary)
                while True:
                    if not tx_rates.process_next():
                        for i, remote_client in enumerate(clients):
                            remote_client.wait()
                            remote_client.print_result()
                            # TODO: For now, only retrieve perf csv for the first client
                            # as all files have the same name on all clients
                            remote_client.stop(i == 0)
                        break
                    time.sleep(1)

                LOG.info(f"Rates: {tx_rates}")
                tx_rates.save_results(args.metrics_file)

            except KeyboardInterrupt:
                for remote_client in clients:
                    remote_client.stop()