snazy commented on code in PR #3043:
URL: https://github.com/apache/polaris/pull/3043#discussion_r2535444958
##########
runtime/service/src/test/java/org/apache/polaris/service/task/ManifestFileCleanupTaskHandlerTest.java:
##########
@@ -39,41 +42,47 @@
import org.apache.iceberg.io.OutputFile;
import org.apache.iceberg.io.PositionOutputStream;
import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.AsyncTaskType;
import org.apache.polaris.core.entity.TaskEntity;
-import org.apache.polaris.core.persistence.BasePersistence;
-import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import org.apache.polaris.service.TestFileIOFactory;
-import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@QuarkusTest
class ManifestFileCleanupTaskHandlerTest {
- @Inject MetaStoreManagerFactory metaStoreManagerFactory;
+ @Inject CallContext callContext;
+ @InjectMock TaskFileIOSupplier taskFileIOSupplier;
private final RealmContext realmContext = () -> "realmName";
+ private PolarisCallContext polarisCallContext;
+ private ExecutorService executor;
- private TaskFileIOSupplier buildTaskFileIOSupplier(FileIO fileIO) {
- return new TaskFileIOSupplier(
- new TestFileIOFactory(fileIO),
Mockito.mock(StorageAccessConfigProvider.class));
+ @BeforeEach
+ public void beforeEach() {
+ QuarkusMock.installMockForType(realmContext, RealmContext.class);
+ polarisCallContext = callContext.getPolarisCallContext();
+ executor = Executors.newSingleThreadExecutor();
}
- private PolarisCallContext newCallContext() {
- BasePersistence metaStore =
metaStoreManagerFactory.getOrCreateSession(realmContext);
- return new PolarisCallContext(realmContext, metaStore);
+ @AfterEach
+ public void afterEach() {
+ executor.shutdownNow();
Review Comment:
```suggestion
executor.close();
```
##########
runtime/service/src/test/java/org/apache/polaris/service/task/BatchFileCleanupTaskHandlerTest.java:
##########
@@ -43,34 +46,43 @@
import org.apache.iceberg.inmemory.InMemoryFileIO;
import org.apache.iceberg.io.FileIO;
import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.AsyncTaskType;
import org.apache.polaris.core.entity.TaskEntity;
-import org.apache.polaris.core.persistence.BasePersistence;
-import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import org.apache.polaris.service.TestFileIOFactory;
-import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@QuarkusTest
public class BatchFileCleanupTaskHandlerTest {
- @Inject MetaStoreManagerFactory metaStoreManagerFactory;
+ @Inject CallContext callContext;
+ @InjectMock TaskFileIOSupplier taskFileIOSupplier;
+
private final RealmContext realmContext = () -> "realmName";
+ private PolarisCallContext polarisCallContext;
+ private ExecutorService executor;
+
+ @BeforeEach
+ public void beforeEach() {
+ QuarkusMock.installMockForType(realmContext, RealmContext.class);
+ polarisCallContext = callContext.getPolarisCallContext();
+ executor = Executors.newSingleThreadExecutor();
+ }
- private TaskFileIOSupplier buildTaskFileIOSupplier(FileIO fileIO) {
- return new TaskFileIOSupplier(
- new TestFileIOFactory(fileIO),
Mockito.mock(StorageAccessConfigProvider.class));
+ @AfterEach
+ public void afterEach() {
+ executor.shutdownNow();
Review Comment:
```suggestion
executor.close();
```
Better to wait until the executor is fully closed and all tasks have stopped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]