Skip to content

Commit a85d2e9

Browse files
committed
added workload log run parse param validation for PK mode
1 parent a7bf9f2 commit a85d2e9

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

ydb/library/workload/abstract/workload_query_generator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/value/value.h>
77
#include <ydb/library/accessor/accessor.h>
88
#include <library/cpp/getopt/last_getopt.h>
9+
#include <ydb/public/lib/ydb_cli/common/command.h>
910

1011
#include <list>
1112
#include <string>
@@ -172,6 +173,7 @@ class TWorkloadParams {
172173
virtual ~TWorkloadParams() = default;
173174
virtual void ConfigureOpts(NLastGetopt::TOpts& /*opts*/, const ECommandType /*commandType*/, int /*workloadType*/) {
174175
};
176+
virtual void Parse(NYdb::NConsoleClient::TClientCommand::TConfig& /*config*/) {};
175177
virtual THolder<IWorkloadQueryGenerator> CreateGenerator() const = 0;
176178
virtual TWorkloadDataInitializer::TList CreateDataInitializers() const {
177179
return {};

ydb/library/workload/log/log.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ void TLogWorkloadParams::ConfigureOpts(NLastGetopt::TOpts& opts, const ECommandT
429429
// .DefaultValue(TimestampStandardDeviationMinutes)
430430
.Optional()
431431
.StoreResult(&TimestampStandardDeviationMinutes);
432+
// TODO: maybe it shoudn't be optional
432433

433434
opts.AddLongOption("date-from", "Left boundary of the interval to generate "
434435
"timestamp uniformly from specified interval. Presents as seconds since epoch. Once this option passed, 'date-to' "
@@ -472,6 +473,21 @@ void TLogWorkloadParams::ConfigureOpts(NLastGetopt::TOpts& opts, const ECommandT
472473
}
473474
}
474475

476+
void TLogWorkloadParams::Parse(NYdb::NConsoleClient::TClientCommand::TConfig& config) {
477+
// TODO: should I check if it's a specific command type: run ?
478+
auto timestamp_dev_passed = config.ParseResult->Has("timestamp_deviation");
479+
auto date_from_passed = config.ParseResult->Has("date-from");
480+
auto date_to_passed = config.ParseResult->Has("date-to");
481+
482+
if (timestamp_dev_passed && (date_from_passed || date_to_passed)) {
483+
throw yexception() << "timestamp_deviation and date_from, date_to are mutually exclusive and shouldn't be passed at once";
484+
}
485+
486+
if ((date_from_passed && !date_to_passed) || (!date_from_passed && date_to_passed)) {
487+
throw yexception() << "The `date_from` and `date_to` parameters must be provided together to specify the interval for uniform PK generation";
488+
}
489+
}
490+
475491
THolder<IWorkloadQueryGenerator> TLogWorkloadParams::CreateGenerator() const {
476492
return MakeHolder<TLogGenerator>(this);
477493
}

ydb/library/workload/log/log.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TLogWorkloadParams : public TWorkloadParams {
1414
};
1515

1616
void ConfigureOpts(NLastGetopt::TOpts& opts, const ECommandType commandType, int workloadType) override;
17+
void Parse(NYdb::NConsoleClient::TClientCommand::TConfig& config) override;
1718
THolder<IWorkloadQueryGenerator> CreateGenerator() const override;
1819
TString GetWorkloadName() const override;
1920
ui64 MinPartitions = 40;

ydb/public/lib/ydb_cli/commands/ydb_workload.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ void TWorkloadCommandBase::Config(TConfig& config) {
374374
Params.ConfigureOpts(config.Opts->GetOpts(), CommandType, Type);
375375
}
376376

377+
void TWorkloadCommandBase::Parse(TConfig& config) {
378+
Params.Parse(config);
379+
}
380+
377381
int TWorkloadCommandBase::Run(TConfig& config) {
378382
Driver = MakeHolder<NYdb::TDriver>(CreateDriver(config));
379383
if (!DryRun) {

ydb/public/lib/ydb_cli/commands/ydb_workload.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class TWorkloadCommandBase: public TYdbCommand {
8989
const TString& description = TString(),
9090
int type = 0);
9191
virtual void Config(TConfig& config) override;
92+
virtual void Parse(TConfig& config) override;
9293
virtual int Run(TConfig& config) override final;
9394

9495
protected:

0 commit comments

Comments
 (0)