From 1f6e360ac04a32473e957a9d0bd0f1f5155cf072 Mon Sep 17 00:00:00 2001 From: Hamza Jugon Date: Wed, 20 Nov 2024 16:52:36 +0000 Subject: [PATCH] Adding IcebergValidator to constructors --- .../metadata/cleanup/context/CommonBeans.java | 11 +++++++---- .../metadata/cleanup/context/CommonBeansTest.java | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/beekeeper-metadata-cleanup/src/main/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeans.java b/beekeeper-metadata-cleanup/src/main/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeans.java index 353adfd9..6526f248 100644 --- a/beekeeper-metadata-cleanup/src/main/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeans.java +++ b/beekeeper-metadata-cleanup/src/main/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeans.java @@ -48,6 +48,7 @@ import com.expediagroup.beekeeper.cleanup.service.CleanupService; import com.expediagroup.beekeeper.cleanup.service.DisableTablesService; import com.expediagroup.beekeeper.cleanup.service.RepositoryCleanupService; +import com.expediagroup.beekeeper.cleanup.validation.IcebergValidator; import com.expediagroup.beekeeper.core.repository.HousekeepingMetadataRepository; import com.expediagroup.beekeeper.metadata.cleanup.handler.ExpiredMetadataHandler; import com.expediagroup.beekeeper.metadata.cleanup.handler.MetadataHandler; @@ -102,8 +103,9 @@ public DeletedMetadataReporter deletedMetadataReporter( @Bean(name = "hiveTableCleaner") MetadataCleaner metadataCleaner( - DeletedMetadataReporter deletedMetadataReporter) { - return new HiveMetadataCleaner(deletedMetadataReporter); + DeletedMetadataReporter deletedMetadataReporter, + IcebergValidator icebergValidator) { + return new HiveMetadataCleaner(deletedMetadataReporter, icebergValidator); } @Bean @@ -139,8 +141,9 @@ public S3Client s3Client(AmazonS3 amazonS3, @Value("${properties.dry-run-enabled @Bean(name = "s3PathCleaner") PathCleaner pathCleaner( S3Client s3Client, - BytesDeletedReporter bytesDeletedReporter) { - return new S3PathCleaner(s3Client, new S3SentinelFilesCleaner(s3Client), bytesDeletedReporter); + BytesDeletedReporter bytesDeletedReporter, + IcebergValidator icebergValidator) { + return new S3PathCleaner(s3Client, new S3SentinelFilesCleaner(s3Client), bytesDeletedReporter, icebergValidator); } @Bean(name = "expiredMetadataHandler") diff --git a/beekeeper-metadata-cleanup/src/test/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeansTest.java b/beekeeper-metadata-cleanup/src/test/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeansTest.java index 36085496..83dbc389 100644 --- a/beekeeper-metadata-cleanup/src/test/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeansTest.java +++ b/beekeeper-metadata-cleanup/src/test/java/com/expediagroup/beekeeper/metadata/cleanup/context/CommonBeansTest.java @@ -49,6 +49,7 @@ import com.expediagroup.beekeeper.cleanup.service.CleanupService; import com.expediagroup.beekeeper.cleanup.service.DisableTablesService; import com.expediagroup.beekeeper.cleanup.service.RepositoryCleanupService; +import com.expediagroup.beekeeper.cleanup.validation.IcebergValidator; import com.expediagroup.beekeeper.core.repository.HousekeepingMetadataRepository; import com.expediagroup.beekeeper.metadata.cleanup.handler.ExpiredMetadataHandler; import com.expediagroup.beekeeper.metadata.cleanup.service.MetadataDisableTablesService; @@ -76,6 +77,7 @@ public class CommonBeansTest { private @Mock PathCleaner pathCleaner; private @Mock MeterRegistry meterRegistry; private @Mock HiveClientFactory hiveClientFactory; + private @Mock IcebergValidator icebergValidator; @BeforeEach public void awsSetUp() { @@ -122,7 +124,7 @@ public void verifyHiveClient() { @Test public void verifyHiveMetadataCleaner() { DeletedMetadataReporter reporter = commonBeans.deletedMetadataReporter(meterRegistry, false); - MetadataCleaner metadataCleaner = commonBeans.metadataCleaner(reporter); + MetadataCleaner metadataCleaner = commonBeans.metadataCleaner(reporter, icebergValidator); assertThat(metadataCleaner).isInstanceOf(HiveMetadataCleaner.class); } @@ -152,7 +154,7 @@ public void verifyS3Client() { void verifyS3pathCleaner() { BytesDeletedReporter reporter = commonBeans.bytesDeletedReporter(meterRegistry, false); S3Client s3Client = commonBeans.s3Client(commonBeans.amazonS3(), false); - PathCleaner pathCleaner = commonBeans.pathCleaner(s3Client, reporter); + PathCleaner pathCleaner = commonBeans.pathCleaner(s3Client, reporter, icebergValidator); assertThat(pathCleaner).isInstanceOf(S3PathCleaner.class); }