Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: srlch <[email protected]>
  • Loading branch information
srlch committed Jan 17, 2025
1 parent a6bca3e commit 676ade4
Showing 1 changed file with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Long>) any);
globalStateMgr.getCurrentState().getEditLog().logEraseMultiTables((List<Long>) any);
minTimes = 1;
maxTimes = 1;
result = null;

globalStateMgr.getCurrentState().getClusterSnapshotMgr();
result = clusterSnapshotMgr;
}
};

Expand All @@ -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());
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 676ade4

Please sign in to comment.