@@ -218,3 +218,78 @@ Y_UNIT_TEST_SUITE(THiveImplTest) {
218
218
UNIT_ASSERT_VALUES_EQUAL (stDev1, stDev2);
219
219
}
220
220
}
221
+
222
+ Y_UNIT_TEST_SUITE (TCutHistoryRestrictions) {
223
+ class TTestHive : public THive {
224
+ public:
225
+ TTestHive (TTabletStorageInfo *info, const TActorId &tablet) : THive(info, tablet) {}
226
+
227
+ template <typename F>
228
+ void UpdateConfig (F func) {
229
+ func (ClusterConfig);
230
+ BuildCurrentConfig ();
231
+ }
232
+ };
233
+
234
+ Y_UNIT_TEST (BasicTest) {
235
+ TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo;
236
+ hiveStorage->TabletType = TTabletTypes::Hive;
237
+ TTestHive hive (hiveStorage.Get (), TActorId ());
238
+ hive.UpdateConfig ([](NKikimrConfig::THiveConfig& config) {
239
+ config.SetCutHistoryAllowList (" DataShard,Coordinator" );
240
+ config.SetCutHistoryDenyList (" GraphShard" );
241
+ });
242
+ UNIT_ASSERT (hive.IsCutHistoryAllowed (TTabletTypes::DataShard));
243
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::GraphShard));
244
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::Hive));
245
+ }
246
+
247
+ Y_UNIT_TEST (EmptyAllowList) {
248
+ TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo;
249
+ hiveStorage->TabletType = TTabletTypes::Hive;
250
+ TTestHive hive (hiveStorage.Get (), TActorId ());
251
+ hive.UpdateConfig ([](NKikimrConfig::THiveConfig& config) {
252
+ config.SetCutHistoryAllowList (" " );
253
+ config.SetCutHistoryDenyList (" GraphShard" );
254
+ });
255
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::GraphShard));
256
+ UNIT_ASSERT (hive.IsCutHistoryAllowed (TTabletTypes::Hive));
257
+ }
258
+
259
+ Y_UNIT_TEST (EmptyDenyList) {
260
+ TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo;
261
+ hiveStorage->TabletType = TTabletTypes::Hive;
262
+ TTestHive hive (hiveStorage.Get (), TActorId ());
263
+ hive.UpdateConfig ([](NKikimrConfig::THiveConfig& config) {
264
+ config.SetCutHistoryAllowList (" DataShard,Coordinator" );
265
+ config.SetCutHistoryDenyList (" " );
266
+ });
267
+ UNIT_ASSERT (hive.IsCutHistoryAllowed (TTabletTypes::DataShard));
268
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::GraphShard));
269
+ }
270
+
271
+ Y_UNIT_TEST (SameTabletInBothLists) {
272
+ TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo;
273
+ hiveStorage->TabletType = TTabletTypes::Hive;
274
+ TTestHive hive (hiveStorage.Get (), TActorId ());
275
+ hive.UpdateConfig ([](NKikimrConfig::THiveConfig& config) {
276
+ config.SetCutHistoryAllowList (" DataShard,Coordinator" );
277
+ config.SetCutHistoryDenyList (" SchemeShard,DataShard" );
278
+ });
279
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::DataShard));
280
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::SchemeShard));
281
+ UNIT_ASSERT (!hive.IsCutHistoryAllowed (TTabletTypes::Hive));
282
+ UNIT_ASSERT (hive.IsCutHistoryAllowed (TTabletTypes::Coordinator));
283
+ }
284
+
285
+ Y_UNIT_TEST (BothListsEmpty) {
286
+ TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo;
287
+ hiveStorage->TabletType = TTabletTypes::Hive;
288
+ TTestHive hive (hiveStorage.Get (), TActorId ());
289
+ hive.UpdateConfig ([](NKikimrConfig::THiveConfig& config) {
290
+ config.SetCutHistoryAllowList (" " );
291
+ config.SetCutHistoryDenyList (" " );
292
+ });
293
+ UNIT_ASSERT (hive.IsCutHistoryAllowed (TTabletTypes::DataShard));
294
+ }
295
+ }
0 commit comments