|
@@ -1,6 +1,7 @@
|
|
|
#include <ydb/core/kqp/gateway/behaviour/resource_pool_classifier/fetcher.h>
|
|
|
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
|
|
|
#include <ydb/core/kqp/ut/common/columnshard.h>
|
|
|
+#include <ydb/core/kqp/workload_service/ut/common/kqp_workload_service_ut_common.h>
|
|
|
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
|
|
|
#include <ydb/core/tx/columnshard/test_helper/controllers.h>
|
|
|
#include <ydb/core/formats/arrow/arrow_helpers.h>
|
|
@@ -6552,6 +6553,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
|
|
|
"Path does not exist");
|
|
|
}
|
|
|
|
|
|
+ Y_UNIT_TEST(DisableResourcePoolsOnServerless) {
|
|
|
+ auto ydb = NWorkload::TYdbSetupSettings()
|
|
|
+ .CreateSampleTenants(true)
|
|
|
+ .EnableResourcePoolsOnServerless(false)
|
|
|
+ .Create();
|
|
|
+
|
|
|
+ auto checkDisabled = [](const auto& result) {
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR, result.GetIssues().ToString());
|
|
|
+ UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Resource pools are disabled for serverless domains. Please contact your system administrator to enable it");
|
|
|
+ };
|
|
|
+
|
|
|
+ auto checkNotFound = [](const auto& result) {
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR, result.GetIssues().ToString());
|
|
|
+ UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Path does not exist");
|
|
|
+ };
|
|
|
+
|
|
|
+ const auto& createSql = R"(
|
|
|
+ CREATE RESOURCE POOL MyResourcePool WITH (
|
|
|
+ CONCURRENT_QUERY_LIMIT=20,
|
|
|
+ QUEUE_SIZE=1000
|
|
|
+ );)";
|
|
|
+
|
|
|
+ const auto& alterSql = R"(
|
|
|
+ ALTER RESOURCE POOL MyResourcePool
|
|
|
+ SET (CONCURRENT_QUERY_LIMIT = 30, QUEUE_SIZE = 100),
|
|
|
+ RESET (QUERY_MEMORY_LIMIT_PERCENT_PER_NODE);
|
|
|
+ )";
|
|
|
+
|
|
|
+ const auto& dropSql = "DROP RESOURCE POOL MyResourcePool;";
|
|
|
+
|
|
|
+ auto settings = NWorkload::TQueryRunnerSettings().PoolId("");
|
|
|
+
|
|
|
+ // Dedicated, enabled
|
|
|
+ settings.Database(ydb->GetSettings().GetDedicatedTenantName()).NodeIndex(1);
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+
|
|
|
+ // Shared, enabled
|
|
|
+ settings.Database(ydb->GetSettings().GetSharedTenantName()).NodeIndex(2);
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+
|
|
|
+ // Serverless, disabled
|
|
|
+ settings.Database(ydb->GetSettings().GetServerlessTenantName()).NodeIndex(2);
|
|
|
+ checkDisabled(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ checkNotFound(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ checkNotFound(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+ }
|
|
|
+
|
|
|
Y_UNIT_TEST(ResourcePoolsValidation) {
|
|
|
NKikimrConfig::TAppConfig config;
|
|
|
config.MutableFeatureFlags()->SetEnableResourcePools(true);
|
|
@@ -6821,6 +6873,57 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
|
|
|
"Classifier with name MyResourcePoolClassifier not found in database /Root");
|
|
|
}
|
|
|
|
|
|
+ Y_UNIT_TEST(DisableResourcePoolClassifiersOnServerless) {
|
|
|
+ auto ydb = NWorkload::TYdbSetupSettings()
|
|
|
+ .CreateSampleTenants(true)
|
|
|
+ .EnableResourcePoolsOnServerless(false)
|
|
|
+ .Create();
|
|
|
+
|
|
|
+ auto checkDisabled = [](const auto& result) {
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR, result.GetIssues().ToString());
|
|
|
+ UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Resource pool classifiers are disabled for serverless domains. Please contact your system administrator to enable it");
|
|
|
+ };
|
|
|
+
|
|
|
+ auto checkNotFound = [](const auto& result) {
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR, result.GetIssues().ToString());
|
|
|
+ UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Classifier with name MyResourcePoolClassifier not found in database");
|
|
|
+ };
|
|
|
+
|
|
|
+ const auto& createSql = R"(
|
|
|
+ CREATE RESOURCE POOL CLASSIFIER MyResourcePoolClassifier WITH (
|
|
|
+ RANK=20,
|
|
|
+ RESOURCE_POOL="test_pool"
|
|
|
+ );)";
|
|
|
+
|
|
|
+ const auto& alterSql = R"(
|
|
|
+ ALTER RESOURCE POOL CLASSIFIER MyResourcePoolClassifier
|
|
|
+ SET (RANK = 1, MEMBERNAME = "test@user"),
|
|
|
+ RESET (RESOURCE_POOL);
|
|
|
+ )";
|
|
|
+
|
|
|
+ const auto& dropSql = "DROP RESOURCE POOL CLASSIFIER MyResourcePoolClassifier;";
|
|
|
+
|
|
|
+ auto settings = NWorkload::TQueryRunnerSettings().PoolId("");
|
|
|
+
|
|
|
+ // Dedicated, enabled
|
|
|
+ settings.Database(ydb->GetSettings().GetDedicatedTenantName()).NodeIndex(1);
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+
|
|
|
+ // Shared, enabled
|
|
|
+ settings.Database(ydb->GetSettings().GetSharedTenantName()).NodeIndex(2);
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ NWorkload::TSampleQueries::CheckSuccess(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+
|
|
|
+ // Serverless, disabled
|
|
|
+ settings.Database(ydb->GetSettings().GetServerlessTenantName()).NodeIndex(2);
|
|
|
+ checkDisabled(ydb->ExecuteQuery(createSql, settings));
|
|
|
+ checkDisabled(ydb->ExecuteQuery(alterSql, settings));
|
|
|
+ checkNotFound(ydb->ExecuteQuery(dropSql, settings));
|
|
|
+ }
|
|
|
+
|
|
|
Y_UNIT_TEST(ResourcePoolClassifiersValidation) {
|
|
|
NKikimrConfig::TAppConfig config;
|
|
|
config.MutableFeatureFlags()->SetEnableResourcePools(true);
|