@@ -834,6 +834,47 @@ Y_UNIT_TEST_SUITE(DataShardStats) {
834834        WaitTableStats (runtime, shard1, DoesNotHaveSchemaChangesCondition ());
835835    }
836836
837+     Y_UNIT_TEST (BackupTableStatsReportInterval) {
838+         TPortManager pm;
839+         TServerSettings serverSettings (pm.GetPort (2134 ));
840+         serverSettings.SetDomainName (" Root" 
841+             .SetUseRealThreads (false );
842+ 
843+         TServer::TPtr server = new  TServer (serverSettings);
844+         auto & runtime = *server->GetRuntime ();
845+         auto  sender = runtime.AllocateEdgeActor ();
846+ 
847+         runtime.SetLogPriority (NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE);
848+ 
849+         InitRoot (server, sender);
850+ 
851+         auto  [shards, tableId1] = CreateShardedTable (server, sender, " /Root" " table-1" 1 );
852+ 
853+         //  Create a backup copy table
854+         {
855+             auto  senderCopy = runtime.AllocateEdgeActor ();
856+             ui64 txId = AsyncCreateCopyTable (
857+                 server, senderCopy, " /Root" " table-2" " /Root/table-1" /* isBackup=*/ true );
858+             WaitTxNotification (server, senderCopy, txId);
859+         }
860+         auto  tableId2 = ResolveTableId (server, sender, " /Root/table-2" 
861+ 
862+         std::unordered_map<TLocalPathId, size_t > tableToStatsCount;
863+         auto  observerFunc = [&](auto & ev) {
864+             const  NKikimrTxDataShard::TEvPeriodicTableStats& record = ev->Get ()->Record ;
865+             ++tableToStatsCount[record.GetTableLocalId ()];
866+         };
867+         auto  observer = runtime.AddObserver <TEvDataShard::TEvPeriodicTableStats>(observerFunc);
868+ 
869+         runtime.WaitFor (" First stats event" return  !tableToStatsCount.empty (); });
870+         runtime.SimulateSleep (TDuration::Seconds (45 ));
871+         //  Once every 10 seconds
872+         UNIT_ASSERT_GE (tableToStatsCount[tableId1.PathId .LocalPathId ], 4 );
873+         UNIT_ASSERT_LE (tableToStatsCount[tableId1.PathId .LocalPathId ], 5 );
874+         //  Once every 30 seconds
875+         UNIT_ASSERT_GE (tableToStatsCount[tableId2.PathId .LocalPathId ], 1 );
876+         UNIT_ASSERT_LE (tableToStatsCount[tableId2.PathId .LocalPathId ], 2 );
877+     }
837878}
838879
839880}
0 commit comments