diff --git a/fe/fe-core/src/test/java/com/starrocks/catalog/CatalogRecycleBinTest.java b/fe/fe-core/src/test/java/com/starrocks/catalog/CatalogRecycleBinTest.java index 3baaf9688f696..6f4e7c549c9ad 100644 --- a/fe/fe-core/src/test/java/com/starrocks/catalog/CatalogRecycleBinTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/catalog/CatalogRecycleBinTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.Sets; import com.starrocks.common.Config; import com.starrocks.common.jmockit.Deencapsulation; +import com.starrocks.lake.snapshot.ClusterSnapshotMgr; import com.starrocks.persist.EditLog; import com.starrocks.server.GlobalStateMgr; import com.starrocks.sql.ast.PartitionValue; @@ -186,15 +187,19 @@ public void testReplayEraseTable() { @Test public void testReplayEraseTableEx(@Mocked GlobalStateMgr globalStateMgr) { + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); new Expectations() { { GlobalStateMgr.getCurrentState(); result = globalStateMgr; - globalStateMgr.getEditLog().logEraseMultiTables((List) any); + globalStateMgr.getCurrentState().getEditLog().logEraseMultiTables((List) any); minTimes = 1; maxTimes = 1; result = null; + + globalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; } }; @@ -207,9 +212,9 @@ public void testReplayEraseTableEx(@Mocked GlobalStateMgr globalStateMgr) { bin.recycleTable(13, table3, true); bin.eraseTable(System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); - waitPartitionClearFinished(bin, 11L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); - waitPartitionClearFinished(bin, 12L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); - waitPartitionClearFinished(bin, 13L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); + waitTableClearFinished(bin, 1L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); + waitTableClearFinished(bin, 2L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); + waitTableClearFinished(bin, 3L, System.currentTimeMillis() + Config.catalog_trash_expire_second * 1000L + 10000); Assert.assertEquals(0, bin.getTables(11L).size()); Assert.assertEquals(0, bin.getTables(12L).size()); @@ -357,6 +362,14 @@ public void testAddTabletToInvertedIndexWithLocalTabletError(@Mocked GlobalState @Test public void testEnsureEraseLater() { + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); + new Expectations() { + { + GlobalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; + } + }; + Config.catalog_trash_expire_second = 600; // set expire in 10 minutes CatalogRecycleBin recycleBin = new CatalogRecycleBin(); Database db = new Database(111, "uno"); @@ -428,6 +441,13 @@ public void testRecycleDb(@Mocked GlobalStateMgr globalStateMgr, @Mocked EditLog minTimes = 0; } }; + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); + new Expectations() { + { + globalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; + } + }; recycleBin.eraseDatabase(now); @@ -486,6 +506,13 @@ public void testRecycleTableMaxBatchSize(@Mocked GlobalStateMgr globalStateMgr, result = null; } }; + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); + new Expectations() { + { + globalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; + } + }; CatalogRecycleBin recycleBin = new CatalogRecycleBin(); for (int i = 0; i < CatalogRecycleBin.getMaxEraseOperationsPerCycle() + 1; i++) { Table t = new Table(i, String.format("t%d", i), Table.TableType.VIEW, null); @@ -523,6 +550,13 @@ public void testRecycleTable(@Mocked GlobalStateMgr globalStateMgr, @Mocked Edit result = null; } }; + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); + new Expectations() { + { + globalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; + } + }; // 1. add 2 tables long dbId = 1; @@ -605,6 +639,13 @@ public void testRecyclePartition(@Mocked GlobalStateMgr globalStateMgr, @Mocked minTimes = 0; } }; + ClusterSnapshotMgr clusterSnapshotMgr = new ClusterSnapshotMgr(); + new Expectations() { + { + globalStateMgr.getCurrentState().getClusterSnapshotMgr(); + result = clusterSnapshotMgr; + } + }; // 1. add 2 partitions long dbId = 1;