@@ -90,6 +90,20 @@ TTenantTestConfig DefaultConsoleTestConfig()
9090 return res;
9191}
9292
93+ TString DefaultDatabaseQuotas () {
94+ return R"(
95+ data_size_hard_quota: 3000
96+ storage_quotas {
97+ unit_kind: "hdd"
98+ data_size_hard_quota: 2000
99+ }
100+ storage_quotas {
101+ unit_kind: "hdd-1"
102+ data_size_hard_quota: 1000
103+ }
104+ )" ;
105+ }
106+
93107void CheckAlterTenantSlots (TTenantTestRuntime &runtime, const TString &path,
94108 ui64 generation, Ydb::StatusIds::StatusCode code,
95109 TVector<TSlotRequest> add,
@@ -2027,6 +2041,58 @@ Y_UNIT_TEST_SUITE(TConsoleTests) {
20272041 TTenantTestRuntime runtime (DefaultConsoleTestConfig (), {}, true );
20282042 RunTestAlterTenantTooManyStorageResourcesForRunning (runtime);
20292043 }
2044+
2045+ void RunTestDatabaseQuotas (TTenantTestRuntime& runtime, const TString& quotas, bool shared = false ) {
2046+ using EType = TCreateTenantRequest::EType;
2047+
2048+ CheckCreateTenant (runtime, Ydb::StatusIds::SUCCESS,
2049+ TCreateTenantRequest (TENANT1_1_NAME, shared ? EType::Shared : EType::Common)
2050+ .WithPools ({{" hdd" , 1 }, {" hdd-1" , 1 }})
2051+ .WithDatabaseQuotas (quotas)
2052+ );
2053+
2054+ RestartTenantPool (runtime);
2055+
2056+ CheckTenantStatus (runtime, TENANT1_1_NAME, shared, Ydb::StatusIds::SUCCESS,
2057+ Ydb::Cms::GetDatabaseStatusResult::RUNNING,
2058+ {{" hdd" , 1 , 1 }, {" hdd-1" , 1 , 1 }}, {});
2059+ }
2060+
2061+ Y_UNIT_TEST (TestDatabaseQuotas) {
2062+ TTenantTestRuntime runtime (DefaultConsoleTestConfig ());
2063+ RunTestDatabaseQuotas (runtime, DefaultDatabaseQuotas ());
2064+ }
2065+
2066+ Y_UNIT_TEST (TestDatabaseQuotasBadOverallQuota) {
2067+ TTenantTestRuntime runtime (DefaultConsoleTestConfig ());
2068+
2069+ CheckCreateTenant (runtime, Ydb::StatusIds::BAD_REQUEST,
2070+ TCreateTenantRequest (TENANT1_1_NAME, TCreateTenantRequest::EType::Common)
2071+ .WithPools ({{" hdd" , 1 }})
2072+ .WithDatabaseQuotas (R"(
2073+ data_size_hard_quota: 1
2074+ data_size_soft_quota: 1000
2075+ )"
2076+ )
2077+ );
2078+ }
2079+
2080+ Y_UNIT_TEST (TestDatabaseQuotasBadStorageQuota) {
2081+ TTenantTestRuntime runtime (DefaultConsoleTestConfig ());
2082+
2083+ CheckCreateTenant (runtime, Ydb::StatusIds::BAD_REQUEST,
2084+ TCreateTenantRequest (TENANT1_1_NAME, TCreateTenantRequest::EType::Common)
2085+ .WithPools ({{" hdd" , 1 }})
2086+ .WithDatabaseQuotas (R"(
2087+ storage_quotas {
2088+ unit_kind: "hdd"
2089+ data_size_hard_quota: 1
2090+ data_size_soft_quota: 1000
2091+ }
2092+ )"
2093+ )
2094+ );
2095+ }
20302096}
20312097
20322098} // namespace NKikimr
0 commit comments