|
1 | 1 | #include <ydb/core/kqp/gateway/behaviour/resource_pool_classifier/fetcher.h>
|
2 | 2 | #include <ydb/core/kqp/ut/common/kqp_ut_common.h>
|
3 | 3 | #include <ydb/core/kqp/ut/common/columnshard.h>
|
| 4 | +#include <ydb/core/kqp/workload_service/ut/common/kqp_workload_service_ut_common.h> |
4 | 5 | #include <ydb/core/tx/columnshard/hooks/testing/controller.h>
|
5 | 6 | #include <ydb/core/formats/arrow/arrow_helpers.h>
|
6 | 7 | #include <ydb/core/tx/tx_proxy/proxy.h>
|
@@ -6225,6 +6226,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
|
6225 | 6226 | "Path does not exist");
|
6226 | 6227 | }
|
6227 | 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 | + |
6228 | 6280 | Y_UNIT_TEST(ResourcePoolsValidation) {
|
6229 | 6281 | NKikimrConfig::TAppConfig config;
|
6230 | 6282 | config.MutableFeatureFlags()->SetEnableResourcePools(true);
|
@@ -6494,6 +6546,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
|
6494 | 6546 | "Classifier with name MyResourcePoolClassifier not found in database /Root");
|
6495 | 6547 | }
|
6496 | 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 | + |
6497 | 6600 | Y_UNIT_TEST(ResourcePoolClassifiersValidation) {
|
6498 | 6601 | NKikimrConfig::TAppConfig config;
|
6499 | 6602 | config.MutableFeatureFlags()->SetEnableResourcePools(true);
|
@@ -6782,6 +6885,46 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
|
6782 | 6885 | UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString());
|
6783 | 6886 | UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Classifier with name MyResourcePoolClassifier not found in database /Root");
|
6784 | 6887 | }
|
| 6888 | + |
| 6889 | + Y_UNIT_TEST(DisableMetadataObjectsOnServerless) { |
| 6890 | + auto ydb = NWorkload::TYdbSetupSettings() |
| 6891 | + .CreateSampleTenants(true) |
| 6892 | + .EnableMetadataObjectsOnServerless(false) |
| 6893 | + .Create(); |
| 6894 | + |
| 6895 | + auto checkDisabled = [](const auto& result) { |
| 6896 | + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR, result.GetIssues().ToString()); |
| 6897 | + UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Objects SECRET are disabled for serverless domains. Please contact your system administrator to enable it"); |
| 6898 | + }; |
| 6899 | + |
| 6900 | + const auto& createSql = "CREATE OBJECT MySecretObject (TYPE SECRET) WITH (value=\"qwerty\");"; |
| 6901 | + const auto& alterSql = "ALTER OBJECT MySecretObject (TYPE SECRET) SET value = \"abcde\";"; |
| 6902 | + const auto& upsertSql = "UPSERT OBJECT MySecretObject (TYPE SECRET) WITH value = \"edcba\";"; |
| 6903 | + const auto& dropSql = "DROP OBJECT MySecretObject (TYPE SECRET);"; |
| 6904 | + |
| 6905 | + auto settings = NWorkload::TQueryRunnerSettings().PoolId(""); |
| 6906 | + |
| 6907 | + // Dedicated, enabled |
| 6908 | + settings.Database(ydb->GetSettings().GetDedicatedTenantName()).NodeIndex(1); |
| 6909 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings)); |
| 6910 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings)); |
| 6911 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(upsertSql, settings)); |
| 6912 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings)); |
| 6913 | + |
| 6914 | + // Shared, enabled |
| 6915 | + settings.Database(ydb->GetSettings().GetSharedTenantName()).NodeIndex(2); |
| 6916 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings)); |
| 6917 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings)); |
| 6918 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(upsertSql, settings)); |
| 6919 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings)); |
| 6920 | + |
| 6921 | + // Serverless, disabled |
| 6922 | + settings.Database(ydb->GetSettings().GetServerlessTenantName()).NodeIndex(2); |
| 6923 | + checkDisabled(ydb->ExecuteQuery(createSql, settings)); |
| 6924 | + checkDisabled(ydb->ExecuteQuery(alterSql, settings)); |
| 6925 | + checkDisabled(ydb->ExecuteQuery(upsertSql, settings)); |
| 6926 | + NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings)); |
| 6927 | + } |
6785 | 6928 | }
|
6786 | 6929 |
|
6787 | 6930 | Y_UNIT_TEST_SUITE(KqpOlapScheme) {
|
|
0 commit comments