@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
86 lines (79 loc) • 3.38 kB
text/typescript
// SPDX-License-Identifier: Apache-2.0
import {inject, injectable} from 'tsyringe-neo';
import {InjectTokens} from '../../core/dependency-injection/inject-tokens.js';
import {patchInject} from '../../core/dependency-injection/container-helper.js';
import {BaseCommandDefinition} from './base-command-definition.js';
import {CommandBuilder, CommandGroup, Subcommand} from '../../core/command-path-builders/command-builder.js';
import {type CommandDefinition} from '../../types/index.js';
import {type SoloLogger} from '../../core/logging/solo-logger.js';
import * as constants from '../../core/constants.js';
import {RapidFireCommand} from '../rapid-fire.js';
()
export class RapidFireCommandDefinition extends BaseCommandDefinition {
public constructor(
(InjectTokens.SoloLogger) private readonly logger?: SoloLogger,
(InjectTokens.RapidFireCommand) public readonly rapidFireCommand?: RapidFireCommand,
) {
super();
this.rapidFireCommand = patchInject(rapidFireCommand, InjectTokens.RapidFireCommand, this.constructor.name);
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
}
public static override readonly COMMAND_NAME: string = 'rapid-fire';
public static readonly LOAD_SUBCOMMAND_NAME: string = 'load';
public static readonly DESTROY_SUBCOMMAND_NAME: string = 'destroy';
public static readonly START: string = 'start';
public static readonly STOP: string = 'stop';
public static readonly ALL: string = 'all';
public getCommandDefinition(): CommandDefinition {
return new CommandBuilder(
RapidFireCommandDefinition.COMMAND_NAME,
'Commands for performing load tests a Solo deployment',
this.logger,
)
.addCommandGroup(
new CommandGroup(
RapidFireCommandDefinition.LOAD_SUBCOMMAND_NAME,
'Run load tests using the network load generator with the selected class.',
)
.addSubcommand(
new Subcommand(
RapidFireCommandDefinition.START,
'Start a rapid-fire load test using the selected class.',
this.rapidFireCommand,
this.rapidFireCommand.start,
RapidFireCommand.START_FLAGS_LIST,
[...constants.BASE_DEPENDENCIES],
false,
),
)
.addSubcommand(
new Subcommand(
RapidFireCommandDefinition.STOP,
'Stop any running processes using the selected class.',
this.rapidFireCommand,
this.rapidFireCommand.stop,
RapidFireCommand.STOP_FLAGS_LIST,
[...constants.BASE_DEPENDENCIES],
false,
),
),
)
.addCommandGroup(
new CommandGroup(
RapidFireCommandDefinition.DESTROY_SUBCOMMAND_NAME,
'Uninstall the Network Load Generator Helm chart and clean up resources.',
).addSubcommand(
new Subcommand(
RapidFireCommandDefinition.ALL,
'Uninstall the Network Load Generator Helm chart and remove all related resources.',
this.rapidFireCommand,
this.rapidFireCommand.destroy,
RapidFireCommand.DESTROY_FLAGS_LIST,
[...constants.BASE_DEPENDENCIES],
false,
),
),
)
.build();
}
}