Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei committed Dec 2, 2024
1 parent 44001ab commit 358324a
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ public void tearDown() {
new CompactionConfigRestorer().restoreCompactionConfig();
}

/** Test comparation of tasks with different avg file size */
@Test
public void testAvgFileSizeCompare() throws InterruptedException {
AbstractCompactionTask[] compactionTasks = new AbstractCompactionTask[100];
for (int i = 0; i < 10; ++i) {
List<TsFileResource> resources = new ArrayList<>();
for (int j = i; j < 10; ++j) {
resources.add(
new FakedTsFileResource(new File(String.format("%d-%d-0-0.tsfile", i + j, i + j)), i));
}
compactionTasks[i] =
new FakedInnerSpaceCompactionTask("fakeSg", 0, tsFileManager, true, resources, 0);
compactionTaskQueue.put(compactionTasks[i]);
}

for (int i = 0; i < 10; ++i) {
AbstractCompactionTask currentTask = compactionTaskQueue.take();
assertTrue(currentTask == compactionTasks[i]);
}
}

/** Test comparation of tasks with different file num */
@Test
public void testFileNumCompare() throws InterruptedException {
Expand All @@ -82,7 +103,7 @@ public void testFileNumCompare() throws InterruptedException {
List<TsFileResource> resources = new ArrayList<>();
for (int j = i; j < 100; ++j) {
resources.add(
new FakedTsFileResource(new File(String.format("%d-%d-0-0.tsfile", i + j, i + j)), j));
new FakedTsFileResource(new File(String.format("%d-%d-0-0.tsfile", i + j, i + j)), 1));
}
compactionTasks[i] =
new FakedInnerSpaceCompactionTask("fakeSg", 0, tsFileManager, true, resources, 0);
Expand Down Expand Up @@ -205,7 +226,7 @@ public void testComparationOfDifferentTaskType() throws InterruptedException {
List<TsFileResource> resources = new ArrayList<>();
for (int j = i; j < 100; ++j) {
resources.add(
new FakedTsFileResource(new File(String.format("%d-%d-0-0.tsfile", i + j, i + j)), j));
new FakedTsFileResource(new File(String.format("%d-%d-0-0.tsfile", i + j, i + j)), 1));
}
innerCompactionTasks[i] =
new FakedInnerSpaceCompactionTask("fakeSg", 0, tsFileManager, true, resources, 0);
Expand Down

0 comments on commit 358324a

Please sign in to comment.