|
| 1 | +#include <ydb/core/metering/metering.h> |
| 2 | +#include <ydb/core/testlib/actors/block_events.h> |
1 | 3 | #include <ydb/core/tx/schemeshard/ut_helpers/helpers.h>
|
2 | 4 | #include <ydb/core/tx/schemeshard/schemeshard_private.h>
|
3 | 5 |
|
4 |
| -#include <ydb/core/metering/metering.h> |
5 |
| - |
6 | 6 | using namespace NKikimr;
|
7 | 7 | using namespace NSchemeShard;
|
8 | 8 | using namespace NSchemeShardUT_Private;
|
@@ -263,6 +263,72 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
|
263 | 263 | }
|
264 | 264 | }
|
265 | 265 |
|
| 266 | + Y_UNIT_TEST(StorageBillingLabels) { |
| 267 | + TTestBasicRuntime runtime; |
| 268 | + TTestEnv env(runtime); |
| 269 | + ui64 txId = 100; |
| 270 | + |
| 271 | + SetAllowServerlessStorageBilling(&runtime, true); |
| 272 | + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 273 | + Name: "SharedDB" |
| 274 | + )"); |
| 275 | + env.TestWaitNotification(runtime, txId); |
| 276 | + |
| 277 | + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 278 | + Name: "SharedDB" |
| 279 | + StoragePools { |
| 280 | + Name: "pool-1" |
| 281 | + Kind: "pool-kind-1" |
| 282 | + } |
| 283 | + PlanResolution: 50 |
| 284 | + Coordinators: 1 |
| 285 | + Mediators: 1 |
| 286 | + TimeCastBucketsPerMediator: 2 |
| 287 | + ExternalSchemeShard: true |
| 288 | + )"); |
| 289 | + env.TestWaitNotification(runtime, txId); |
| 290 | + |
| 291 | + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( |
| 292 | + Name: "ServerlessDB" |
| 293 | + ResourcesDomainKey { |
| 294 | + SchemeShard: %lu |
| 295 | + PathId: 2 |
| 296 | + } |
| 297 | + )", TTestTxConfig::SchemeShard)); |
| 298 | + env.TestWaitNotification(runtime, txId); |
| 299 | + |
| 300 | + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 301 | + Name: "ServerlessDB" |
| 302 | + StoragePools { |
| 303 | + Name: "pool-1" |
| 304 | + Kind: "pool-kind-1" |
| 305 | + } |
| 306 | + PlanResolution: 50 |
| 307 | + Coordinators: 1 |
| 308 | + Mediators: 1 |
| 309 | + TimeCastBucketsPerMediator: 2 |
| 310 | + ExternalSchemeShard: true |
| 311 | + ExternalHive: false |
| 312 | + )"); |
| 313 | + env.TestWaitNotification(runtime, txId); |
| 314 | + |
| 315 | + TestUserAttrs(runtime, ++txId, "/MyRoot", "ServerlessDB", AlterUserAttrs({ |
| 316 | + {"cloud_id", "CLOUD_ID_VAL"}, |
| 317 | + {"folder_id", "FOLDER_ID_VAL"}, |
| 318 | + {"database_id", "DATABASE_ID_VAL"}, |
| 319 | + {"label_k", "v"}, |
| 320 | + {"not_a_label_x", "y"}, |
| 321 | + })); |
| 322 | + env.TestWaitNotification(runtime, txId); |
| 323 | + |
| 324 | + TBlockEvents<NMetering::TEvMetering::TEvWriteMeteringJson> block(runtime); |
| 325 | + runtime.WaitFor("metering", [&]{ return block.size() >= 1; }); |
| 326 | + |
| 327 | + const auto& jsonStr = block[0]->Get()->MeteringJson; |
| 328 | + UNIT_ASSERT_C(jsonStr.Contains(R"("labels":{"k":"v"})"), jsonStr); |
| 329 | + UNIT_ASSERT_C(!jsonStr.Contains("not_a_label"), jsonStr); |
| 330 | + } |
| 331 | + |
266 | 332 | Y_UNIT_TEST(TestServerlessComputeResourcesMode) {
|
267 | 333 | TTestBasicRuntime runtime;
|
268 | 334 | TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
|
|
0 commit comments