in benchmark/benchmark/remote.py [0:0]
def run(self, bench_parameters_dict, node_parameters_dict, debug=False):
assert isinstance(debug, bool)
Print.heading('Starting remote benchmark')
try:
bench_parameters = BenchParameters(bench_parameters_dict)
node_parameters = NodeParameters(node_parameters_dict)
except ConfigError as e:
raise BenchError('Invalid nodes or bench parameters', e)
# Select which hosts to use.
selected_hosts = self._select_hosts(bench_parameters)
if not selected_hosts:
Print.warn('There are not enough instances available')
return
# Update nodes.
try:
self._update(selected_hosts, bench_parameters.collocate)
except (GroupException, ExecutionError) as e:
e = FabricError(e) if isinstance(e, GroupException) else e
raise BenchError('Failed to update nodes', e)
# Upload all configuration files.
try:
committee = self._config(
selected_hosts, node_parameters, bench_parameters
)
except (subprocess.SubprocessError, GroupException) as e:
e = FabricError(e) if isinstance(e, GroupException) else e
raise BenchError('Failed to configure nodes', e)
# Run benchmarks.
for n in bench_parameters.nodes:
committee_copy = deepcopy(committee)
committee_copy.remove_nodes(committee.size() - n)
for r in bench_parameters.rate:
Print.heading(f'\nRunning {n} nodes (input rate: {r:,} tx/s)')
# Run the benchmark.
for i in range(bench_parameters.runs):
Print.heading(f'Run {i+1}/{bench_parameters.runs}')
try:
self._run_single(
r, committee_copy, bench_parameters, debug
)
faults = bench_parameters.faults
logger = self._logs(committee_copy, faults)
logger.print(PathMaker.result_file(
faults,
n,
bench_parameters.workers,
bench_parameters.collocate,
r,
bench_parameters.tx_size,
))
except (subprocess.SubprocessError, GroupException, ParseError) as e:
self.kill(hosts=selected_hosts)
if isinstance(e, GroupException):
e = FabricError(e)
Print.error(BenchError('Benchmark failed', e))
continue