Skip to content

Commit

Permalink
Update PagingCleanupServiceTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Jugon committed Nov 20, 2024
1 parent 6baeee4 commit 7090dc4
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.google.common.collect.Lists;

import com.expediagroup.beekeeper.cleanup.path.PathCleaner;
import com.expediagroup.beekeeper.core.checker.IcebergTableChecker;
import com.expediagroup.beekeeper.core.model.HousekeepingPath;
import com.expediagroup.beekeeper.core.model.HousekeepingStatus;
import com.expediagroup.beekeeper.core.model.PeriodDuration;
Expand All @@ -74,9 +75,10 @@ public class PagingCleanupServiceTest {
private @Autowired HousekeepingPathRepository housekeepingPathRepository;
private @MockBean PathCleaner pathCleaner;

private @MockBean IcebergTableChecker icebergTableChecker;
@Test
public void typicalWithPaging() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 2, false);

List<String> paths = List.of("s3://bucket/some_foo", "s3://bucket/some_bar", "s3://bucket/some_foobar");
Expand All @@ -97,7 +99,7 @@ public void typicalWithPaging() {

@Test
public void mixOfScheduledAndFailedPaths() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 2, false);
List<HousekeepingPath> paths = List
.of(createEntityHousekeepingPath("s3://bucket/some_foo", SCHEDULED),
Expand All @@ -113,7 +115,7 @@ public void mixOfScheduledAndFailedPaths() {

@Test
public void mixOfAllPaths() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 2, false);
List<HousekeepingPath> paths = List
.of(createEntityHousekeepingPath("s3://bucket/some_foo", SCHEDULED),
Expand All @@ -130,7 +132,7 @@ public void mixOfAllPaths() {

@Test
void pathCleanerException() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 2, false);

doThrow(new RuntimeException("Error")).doNothing().when(pathCleaner).cleanupPath(any(HousekeepingPath.class));
Expand Down Expand Up @@ -158,7 +160,7 @@ void pathCleanerException() {
@Test
@Timeout(value = 10)
void doNotInfiniteLoopOnRepeatedFailures() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 1, false);
List<HousekeepingPath> paths = List
.of(createEntityHousekeepingPath("s3://bucket/some_foo", FAILED),
Expand Down Expand Up @@ -186,7 +188,7 @@ void doNotInfiniteLoopOnRepeatedFailures() {
@Test
@Timeout(value = 10)
void doNotInfiniteLoopOnDryRunCleanup() {
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner);
UnreferencedPathHandler handler = new UnreferencedPathHandler(housekeepingPathRepository, pathCleaner, icebergTableChecker);
pagingCleanupService = new PagingPathCleanupService(List.of(handler), 1, true);
List<HousekeepingPath> paths = List
.of(createEntityHousekeepingPath("s3://bucket/some_foo", SCHEDULED),
Expand All @@ -211,7 +213,6 @@ private HousekeepingPath createEntityHousekeepingPath(String path, HousekeepingS
.housekeepingStatus(housekeepingStatus)
.creationTimestamp(localNow)
.modifiedTimestamp(localNow)
.modifiedTimestamp(localNow)
.cleanupDelay(PeriodDuration.of(Duration.parse("P3D")))
.cleanupAttempts(0)
.lifecycleType(UNREFERENCED.toString())
Expand Down

0 comments on commit 7090dc4

Please sign in to comment.