@@ -89,6 +89,32 @@ NProtoPrivate::TGetStorageStatsResponse GetStorageStats(
8989 return response;
9090}
9191
92+ void CheckShardsSize (
93+ const TShardedFileSystemConfig& fsConfig,
94+ TServiceClient& service,
95+ const ui64 blocksCount)
96+ {
97+ const auto mainStats =
98+ GetStorageStats (service, fsConfig.FsId , false /* allowCache */ );
99+ const auto shard1Stats = GetStorageStats (
100+ service,
101+ fsConfig.Shard1Id ,
102+ false /* allowCache */ ,
103+ NProtoPrivate::STATS_REQUEST_MODE_FORCE_FETCH_SHARDS);
104+ const auto shard2Stats = GetStorageStats (
105+ service,
106+ fsConfig.Shard2Id ,
107+ false /* allowCache */ ,
108+ NProtoPrivate::STATS_REQUEST_MODE_FORCE_FETCH_SHARDS);
109+ UNIT_ASSERT_EQUAL (blocksCount, mainStats.GetStats ().GetTotalBlocksCount ());
110+ UNIT_ASSERT_EQUAL (
111+ blocksCount,
112+ shard1Stats.GetStats ().GetTotalBlocksCount ());
113+ UNIT_ASSERT_EQUAL (
114+ blocksCount,
115+ shard2Stats.GetStats ().GetTotalBlocksCount ());
116+ }
117+
92118} // namespace
93119
94120// //////////////////////////////////////////////////////////////////////////////
@@ -2548,35 +2574,10 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest)
25482574 UNIT_ASSERT_EQUAL (2 , shard2Topology.ShardFileSystemIdsSize ());
25492575 }
25502576
2551- auto checkShardsSize = [&](const ui64 blocksCount)
2552- {
2553- const auto mainStats =
2554- GetStorageStats (service, fsConfig.FsId , false /* allowCache */ );
2555- const auto shard1Stats = GetStorageStats (
2556- service,
2557- fsConfig.Shard1Id ,
2558- false /* allowCache */ ,
2559- NProtoPrivate::STATS_REQUEST_MODE_FORCE_FETCH_SHARDS);
2560- const auto shard2Stats = GetStorageStats (
2561- service,
2562- fsConfig.Shard2Id ,
2563- false /* allowCache */ ,
2564- NProtoPrivate::STATS_REQUEST_MODE_FORCE_FETCH_SHARDS);
2565- UNIT_ASSERT_EQUAL (
2566- blocksCount,
2567- mainStats.GetStats ().GetTotalBlocksCount ());
2568- UNIT_ASSERT_EQUAL (
2569- blocksCount,
2570- shard1Stats.GetStats ().GetTotalBlocksCount ());
2571- UNIT_ASSERT_EQUAL (
2572- blocksCount,
2573- shard2Stats.GetStats ().GetTotalBlocksCount ());
2574- };
2575-
25762577 // After resizing and turning on StrictFileSystemSizeEnforcement every
25772578 // shard should have the same TotalBytesCount equal to that of the main
25782579 // filesystem
2579- checkShardsSize ( fsConfig.MainFsBlockCount ());
2580+ CheckShardsSize (fsConfig, service, fsConfig.MainFsBlockCount ());
25802581
25812582 // Downsize the filesystem by force
25822583 const auto newBlocksCount = fsConfig.MainFsBlockCount () / 2 ;
@@ -2585,7 +2586,7 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest)
25852586 newBlocksCount,
25862587 true /* force */ );
25872588
2588- checkShardsSize ( newBlocksCount);
2589+ CheckShardsSize (fsConfig, service, newBlocksCount);
25892590
25902591 // Attempt to write one more file should fail
25912592 const auto file = createFile (" notEnoughSpace" );
@@ -2598,6 +2599,32 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest)
25982599 GenerateValidateData (fileSize, 0xBADF00D ));
25992600 }
26002601
2602+ SERVICE_TEST_SIMPLE (
2603+ ShouldResizeShardsInStrictWithStrictFileSystemSizeEnforcement)
2604+ {
2605+ // Create file system with two shards 1000 * 4 * 1024 bytes each
2606+ config.SetMultiTabletForwardingEnabled (true );
2607+ config.SetStrictFileSystemSizeEnforcementEnabled (true );
2608+ TShardedFileSystemConfig fsConfig;
2609+ CREATE_ENV_AND_SHARDED_FILESYSTEM ();
2610+
2611+ // Downsize the filesystem by force to a size that less than
2612+ // ShardAllocationUnit
2613+ const auto newBlocksCount = config.GetShardAllocationUnit () / 2 ;
2614+ service.ResizeFileStore (
2615+ fsConfig.FsId ,
2616+ newBlocksCount,
2617+ true /* force */ );
2618+
2619+ CheckShardsSize (fsConfig, service, newBlocksCount);
2620+
2621+ // It is prohibited to resize an individual shard if
2622+ // StrictFileSystemSizeEnforcementEnabled
2623+ service.AssertResizeFileStoreFailed (
2624+ fsConfig.Shard1Id ,
2625+ newBlocksCount * 2 );
2626+ }
2627+
26012628 SERVICE_TEST_SIMPLE (ShouldRetryFileSystemResize)
26022629 {
26032630 // Create a filsystem with two shards.
0 commit comments