|
| 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;
|
@@ -253,6 +253,72 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) {
|
253 | 253 | }
|
254 | 254 | }
|
255 | 255 |
|
| 256 | + Y_UNIT_TEST(StorageBillingLabels) { |
| 257 | + TTestBasicRuntime runtime; |
| 258 | + TTestEnv env(runtime); |
| 259 | + ui64 txId = 100; |
| 260 | + |
| 261 | + SetAllowServerlessStorageBilling(&runtime, true); |
| 262 | + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 263 | + Name: "SharedDB" |
| 264 | + )"); |
| 265 | + env.TestWaitNotification(runtime, txId); |
| 266 | + |
| 267 | + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 268 | + Name: "SharedDB" |
| 269 | + StoragePools { |
| 270 | + Name: "pool-1" |
| 271 | + Kind: "pool-kind-1" |
| 272 | + } |
| 273 | + PlanResolution: 50 |
| 274 | + Coordinators: 1 |
| 275 | + Mediators: 1 |
| 276 | + TimeCastBucketsPerMediator: 2 |
| 277 | + ExternalSchemeShard: true |
| 278 | + )"); |
| 279 | + env.TestWaitNotification(runtime, txId); |
| 280 | + |
| 281 | + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( |
| 282 | + Name: "ServerlessDB" |
| 283 | + ResourcesDomainKey { |
| 284 | + SchemeShard: %lu |
| 285 | + PathId: 2 |
| 286 | + } |
| 287 | + )", TTestTxConfig::SchemeShard)); |
| 288 | + env.TestWaitNotification(runtime, txId); |
| 289 | + |
| 290 | + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( |
| 291 | + Name: "ServerlessDB" |
| 292 | + StoragePools { |
| 293 | + Name: "pool-1" |
| 294 | + Kind: "pool-kind-1" |
| 295 | + } |
| 296 | + PlanResolution: 50 |
| 297 | + Coordinators: 1 |
| 298 | + Mediators: 1 |
| 299 | + TimeCastBucketsPerMediator: 2 |
| 300 | + ExternalSchemeShard: true |
| 301 | + ExternalHive: false |
| 302 | + )"); |
| 303 | + env.TestWaitNotification(runtime, txId); |
| 304 | + |
| 305 | + TestUserAttrs(runtime, ++txId, "/MyRoot", "ServerlessDB", AlterUserAttrs({ |
| 306 | + {"cloud_id", "CLOUD_ID_VAL"}, |
| 307 | + {"folder_id", "FOLDER_ID_VAL"}, |
| 308 | + {"database_id", "DATABASE_ID_VAL"}, |
| 309 | + {"label_k", "v"}, |
| 310 | + {"not_a_label_x", "y"}, |
| 311 | + })); |
| 312 | + env.TestWaitNotification(runtime, txId); |
| 313 | + |
| 314 | + TBlockEvents<NMetering::TEvMetering::TEvWriteMeteringJson> block(runtime); |
| 315 | + runtime.WaitFor("metering", [&]{ return block.size() >= 1; }); |
| 316 | + |
| 317 | + const auto& jsonStr = block[0]->Get()->MeteringJson; |
| 318 | + UNIT_ASSERT_C(jsonStr.Contains(R"("labels":{"k":"v"})"), jsonStr); |
| 319 | + UNIT_ASSERT_C(!jsonStr.Contains("not_a_label"), jsonStr); |
| 320 | + } |
| 321 | + |
256 | 322 | Y_UNIT_TEST(TestServerlessComputeResourcesMode) {
|
257 | 323 | TTestBasicRuntime runtime;
|
258 | 324 | TTestEnv env(runtime, TTestEnvOptions().EnableServerlessExclusiveDynamicNodes(true));
|
|
0 commit comments