@@ -95,7 +95,7 @@ struct TExecutionOptions {
95
95
.TraceId = DefaultTraceId,
96
96
.PoolId = " " ,
97
97
.UserSID = BUILTIN_ACL_ROOT,
98
- .Database = " " ,
98
+ .Database = GetValue ( 0 , Databases, TString ()) ,
99
99
.Timeout = TDuration::Zero ()
100
100
};
101
101
}
@@ -135,15 +135,15 @@ struct TExecutionOptions {
135
135
136
136
private:
137
137
void ValidateOptionsSizes (const TRunnerOptions& runnerOptions) const {
138
- const auto checker = [numberQueries = ScriptQueries.size ()](size_t checkSize, const TString& optionName) {
139
- if (checkSize > numberQueries) {
138
+ const auto checker = [numberQueries = ScriptQueries.size ()](size_t checkSize, const TString& optionName, bool useInSchemeQuery = false ) {
139
+ if (checkSize > std::max ( numberQueries, static_cast < size_t >(useInSchemeQuery ? 1 : 0 )) ) {
140
140
ythrow yexception () << " Too many " << optionName << " . Specified " << checkSize << " , when number of script queries is " << numberQueries;
141
141
}
142
142
};
143
143
144
144
checker (ExecutionCases.size (), " execution cases" );
145
145
checker (ScriptQueryActions.size (), " script query actions" );
146
- checker (Databases.size (), " databases" );
146
+ checker (Databases.size (), " databases" , true );
147
147
checker (TraceIds.size (), " trace ids" );
148
148
checker (PoolIds.size (), " pool ids" );
149
149
checker (UserSIDs.size (), " user SIDs" );
@@ -257,7 +257,7 @@ struct TExecutionOptions {
257
257
258
258
static void ValidateStorageSettings (const TYdbSetupSettings& ydbSettings) {
259
259
if (ydbSettings.DisableDiskMock ) {
260
- if (ydbSettings.NodeCount + ydbSettings.SharedTenants . size () + ydbSettings. DedicatedTenants .size () > 1 ) {
260
+ if (ydbSettings.NodeCount + ydbSettings.Tenants .size () > 1 ) {
261
261
ythrow yexception () << " Disable disk mock cannot be used for multi node clusters (already disabled)" ;
262
262
} else if (ydbSettings.PDisksPath ) {
263
263
ythrow yexception () << " Disable disk mock cannot be used with real PDisks (already disabled)" ;
@@ -876,17 +876,50 @@ class TMain : public TMainClassArgs {
876
876
.DefaultValue (RunnerOptions.YdbSettings .DomainName )
877
877
.StoreResult (&RunnerOptions.YdbSettings .DomainName );
878
878
879
- options.AddLongOption (" dedicated" , " Dedicated tenant path, relative inside domain" )
879
+ const auto addTenant = [this ](const TString& type, TStorageMeta::TTenant::EType protoType, const NLastGetopt::TOptsParser* option) {
880
+ TStringBuf tenant;
881
+ TStringBuf nodesCountStr;
882
+ TStringBuf (option->CurVal ()).Split (' :' , tenant, nodesCountStr);
883
+ if (tenant.empty ()) {
884
+ ythrow yexception () << type << " tenant name should not be empty" ;
885
+ }
886
+
887
+ TStorageMeta::TTenant tenantInfo;
888
+ tenantInfo.SetType (protoType);
889
+ tenantInfo.SetNodesCount (nodesCountStr ? FromString<ui32>(nodesCountStr) : 1 );
890
+ if (tenantInfo.GetNodesCount () == 0 ) {
891
+ ythrow yexception () << type << " tenant should have at least one node" ;
892
+ }
893
+
894
+ if (!RunnerOptions.YdbSettings .Tenants .emplace (tenant, tenantInfo).second ) {
895
+ ythrow yexception () << " Got duplicated tenant name: " << tenant;
896
+ }
897
+ };
898
+ options.AddLongOption (" dedicated" , " Dedicated tenant path, relative inside domain (for node count use dedicated-name:node-count)" )
880
899
.RequiredArgument (" path" )
881
- .InsertTo (&RunnerOptions. YdbSettings . DedicatedTenants );
900
+ .Handler1 ( std::bind (addTenant, " Dedicated " , TStorageMeta::TTenant::DEDICATED, std::placeholders::_1) );
882
901
883
- options.AddLongOption (" shared" , " Shared tenant path, relative inside domain" )
902
+ options.AddLongOption (" shared" , " Shared tenant path, relative inside domain (for node count use dedicated-name:node-count) " )
884
903
.RequiredArgument (" path" )
885
- .InsertTo (&RunnerOptions. YdbSettings . SharedTenants );
904
+ .Handler1 ( std::bind (addTenant, " Shared " , TStorageMeta::TTenant::SHARED, std::placeholders::_1) );
886
905
887
906
options.AddLongOption (" serverless" , " Serverless tenant path, relative inside domain (use string serverless-name@shared-name to specify shared database)" )
888
907
.RequiredArgument (" path" )
889
- .InsertTo (&RunnerOptions.YdbSettings .ServerlessTenants );
908
+ .Handler1 ([this ](const NLastGetopt::TOptsParser* option) {
909
+ TStringBuf serverless;
910
+ TStringBuf shared;
911
+ TStringBuf (option->CurVal ()).Split (' @' , serverless, shared);
912
+ if (serverless.empty ()) {
913
+ ythrow yexception () << " Serverless tenant name should not be empty" ;
914
+ }
915
+
916
+ TStorageMeta::TTenant tenantInfo;
917
+ tenantInfo.SetType (TStorageMeta::TTenant::SERVERLESS);
918
+ tenantInfo.SetSharedTenant (TString (shared));
919
+ if (!RunnerOptions.YdbSettings .Tenants .emplace (serverless, tenantInfo).second ) {
920
+ ythrow yexception () << " Got duplicated tenant name: " << serverless;
921
+ }
922
+ });
890
923
891
924
options.AddLongOption (" storage-size" , TStringBuilder () << " Domain storage size in gigabytes (" << NKikimr::NBlobDepot::FormatByteSize (DEFAULT_STORAGE_SIZE) << " by default)" )
892
925
.RequiredArgument (" uint" )
0 commit comments