@@ -6226,6 +6226,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
6226
6226
" Path does not exist" );
6227
6227
}
6228
6228
6229
+ Y_UNIT_TEST (DisableResourcePoolsOnServerless) {
6230
+ auto ydb = NWorkload::TYdbSetupSettings ()
6231
+ .CreateSampleTenants (true )
6232
+ .EnableResourcePoolsOnServerless (false )
6233
+ .Create ();
6234
+
6235
+ auto checkDisabled = [](const auto & result) {
6236
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::GENERIC_ERROR, result.GetIssues ().ToString ());
6237
+ UNIT_ASSERT_STRING_CONTAINS (result.GetIssues ().ToString (), " Resource pools are disabled for serverless domains. Please contact your system administrator to enable it" );
6238
+ };
6239
+
6240
+ auto checkNotFound = [](const auto & result) {
6241
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::GENERIC_ERROR, result.GetIssues ().ToString ());
6242
+ UNIT_ASSERT_STRING_CONTAINS (result.GetIssues ().ToString (), " Path does not exist" );
6243
+ };
6244
+
6245
+ const auto & createSql = R"(
6246
+ CREATE RESOURCE POOL MyResourcePool WITH (
6247
+ CONCURRENT_QUERY_LIMIT=20,
6248
+ QUEUE_SIZE=1000
6249
+ );)" ;
6250
+
6251
+ const auto & alterSql = R"(
6252
+ ALTER RESOURCE POOL MyResourcePool
6253
+ SET (CONCURRENT_QUERY_LIMIT = 30, QUEUE_SIZE = 100),
6254
+ RESET (QUERY_MEMORY_LIMIT_PERCENT_PER_NODE);
6255
+ )" ;
6256
+
6257
+ const auto & dropSql = " DROP RESOURCE POOL MyResourcePool;" ;
6258
+
6259
+ auto settings = NWorkload::TQueryRunnerSettings ().PoolId (" " );
6260
+
6261
+ // Dedicated, enabled
6262
+ settings.Database (ydb->GetSettings ().GetDedicatedTenantName ()).NodeIndex (1 );
6263
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (createSql, settings));
6264
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (alterSql, settings));
6265
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (dropSql, settings));
6266
+
6267
+ // Shared, enabled
6268
+ settings.Database (ydb->GetSettings ().GetSharedTenantName ()).NodeIndex (2 );
6269
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (createSql, settings));
6270
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (alterSql, settings));
6271
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (dropSql, settings));
6272
+
6273
+ // Serverless, disabled
6274
+ settings.Database (ydb->GetSettings ().GetServerlessTenantName ()).NodeIndex (2 );
6275
+ checkDisabled (ydb->ExecuteQuery (createSql, settings));
6276
+ checkNotFound (ydb->ExecuteQuery (alterSql, settings));
6277
+ checkNotFound (ydb->ExecuteQuery (dropSql, settings));
6278
+ }
6279
+
6229
6280
Y_UNIT_TEST (ResourcePoolsValidation) {
6230
6281
NKikimrConfig::TAppConfig config;
6231
6282
config.MutableFeatureFlags ()->SetEnableResourcePools (true );
@@ -6495,6 +6546,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
6495
6546
" Classifier with name MyResourcePoolClassifier not found in database /Root" );
6496
6547
}
6497
6548
6549
+ Y_UNIT_TEST (DisableResourcePoolClassifiersOnServerless) {
6550
+ auto ydb = NWorkload::TYdbSetupSettings ()
6551
+ .CreateSampleTenants (true )
6552
+ .EnableResourcePoolsOnServerless (false )
6553
+ .Create ();
6554
+
6555
+ auto checkDisabled = [](const auto & result) {
6556
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::GENERIC_ERROR, result.GetIssues ().ToString ());
6557
+ UNIT_ASSERT_STRING_CONTAINS (result.GetIssues ().ToString (), " Resource pool classifiers are disabled for serverless domains. Please contact your system administrator to enable it" );
6558
+ };
6559
+
6560
+ auto checkNotFound = [](const auto & result) {
6561
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::GENERIC_ERROR, result.GetIssues ().ToString ());
6562
+ UNIT_ASSERT_STRING_CONTAINS (result.GetIssues ().ToString (), " Classifier with name MyResourcePoolClassifier not found in database" );
6563
+ };
6564
+
6565
+ const auto & createSql = R"(
6566
+ CREATE RESOURCE POOL CLASSIFIER MyResourcePoolClassifier WITH (
6567
+ RANK=20,
6568
+ RESOURCE_POOL="test_pool"
6569
+ );)" ;
6570
+
6571
+ const auto & alterSql = R"(
6572
+ ALTER RESOURCE POOL CLASSIFIER MyResourcePoolClassifier
6573
+ SET (RANK = 1, MEMBERNAME = "test@user"),
6574
+ RESET (RESOURCE_POOL);
6575
+ )" ;
6576
+
6577
+ const auto & dropSql = " DROP RESOURCE POOL CLASSIFIER MyResourcePoolClassifier;" ;
6578
+
6579
+ auto settings = NWorkload::TQueryRunnerSettings ().PoolId (" " );
6580
+
6581
+ // Dedicated, enabled
6582
+ settings.Database (ydb->GetSettings ().GetDedicatedTenantName ()).NodeIndex (1 );
6583
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (createSql, settings));
6584
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (alterSql, settings));
6585
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (dropSql, settings));
6586
+
6587
+ // Shared, enabled
6588
+ settings.Database (ydb->GetSettings ().GetSharedTenantName ()).NodeIndex (2 );
6589
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (createSql, settings));
6590
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (alterSql, settings));
6591
+ NWorkload::TSampleQueries::CheckSuccess (ydb->ExecuteQuery (dropSql, settings));
6592
+
6593
+ // Serverless, disabled
6594
+ settings.Database (ydb->GetSettings ().GetServerlessTenantName ()).NodeIndex (2 );
6595
+ checkDisabled (ydb->ExecuteQuery (createSql, settings));
6596
+ checkDisabled (ydb->ExecuteQuery (alterSql, settings));
6597
+ checkNotFound (ydb->ExecuteQuery (dropSql, settings));
6598
+ }
6599
+
6498
6600
Y_UNIT_TEST (ResourcePoolClassifiersValidation) {
6499
6601
NKikimrConfig::TAppConfig config;
6500
6602
config.MutableFeatureFlags ()->SetEnableResourcePools (true );
0 commit comments