Skip to content

Unify RealmEntityManagerFactory usage in tests #2050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.CatalogEntity;
import org.apache.polaris.core.entity.CatalogRoleEntity;
import org.apache.polaris.core.entity.PolarisPrivilege;
import org.apache.polaris.core.entity.PrincipalEntity;
import org.apache.polaris.core.persistence.PolarisEntityManager;
import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult;
import org.apache.polaris.core.persistence.resolver.PolarisResolutionManifest;
import org.apache.polaris.service.catalog.iceberg.IcebergCatalogHandler;
import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
import org.apache.polaris.service.config.RealmEntityManagerFactory;
import org.apache.polaris.service.context.catalog.CallContextCatalogFactory;
import org.apache.polaris.service.context.catalog.PolarisCallContextCatalogFactory;
import org.apache.polaris.service.http.IfNoneMatch;
Expand Down Expand Up @@ -1791,12 +1788,7 @@ public void testSendNotificationSufficientPrivileges() {

PolarisCallContextCatalogFactory factory =
new PolarisCallContextCatalogFactory(
new RealmEntityManagerFactory(null, null, null) {
@Override
public PolarisEntityManager getOrCreateEntityManager(RealmContext realmContext) {
return entityManager;
}
},
realmEntityManagerFactory,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that realmEntityManagerFactory was already being used 4 lines below this one

managerFactory,
userSecretsManagerFactory,
Mockito.mock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public Map<String, String> getConfigOverrides() {
private PolarisCallContext polarisContext;
private PolarisAdminService adminService;
private StorageCredentialCache storageCredentialCache;
private RealmEntityManagerFactory realmEntityManagerFactory;
private PolarisEntityManager entityManager;
private FileIOFactory fileIOFactory;
private InMemoryFileIO fileIO;
Expand Down Expand Up @@ -356,7 +357,7 @@ public void before(TestInfo testInfo) {
.build()
.asCatalog()));

RealmEntityManagerFactory realmEntityManagerFactory =
realmEntityManagerFactory =
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache);
this.fileIOFactory =
Expand Down Expand Up @@ -990,11 +991,7 @@ public void testValidateNotificationFailToCreateFileIO() {
new PolarisPassthroughResolutionView(
polarisContext, entityManager, securityContext, catalog().name());
FileIOFactory fileIOFactory =
spy(
new DefaultFileIOFactory(
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache),
metaStoreManagerFactory));
spy(new DefaultFileIOFactory(realmEntityManagerFactory, metaStoreManagerFactory));
IcebergCatalog catalog =
new IcebergCatalog(
entityManager,
Expand Down Expand Up @@ -1883,10 +1880,7 @@ public void testDropTableWithPurge() {
.containsEntry(StorageAccessProperty.AWS_TOKEN, SESSION_TOKEN);
FileIO fileIO =
new TaskFileIOSupplier(
new DefaultFileIOFactory(
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache),
metaStoreManagerFactory))
new DefaultFileIOFactory(realmEntityManagerFactory, metaStoreManagerFactory))
.apply(taskEntity, polarisContext);
Assertions.assertThat(fileIO).isNotNull().isInstanceOf(ExceptionMappingFileIO.class);
Assertions.assertThat(((ExceptionMappingFileIO) fileIO).getInnerIo())
Expand Down Expand Up @@ -2028,10 +2022,7 @@ public void testFileIOWrapper() {
polarisContext, entityManager, securityContext, CATALOG_NAME);

MeasuredFileIOFactory measured =
new MeasuredFileIOFactory(
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache),
metaStoreManagerFactory);
new MeasuredFileIOFactory(realmEntityManagerFactory, metaStoreManagerFactory);
IcebergCatalog catalog =
new IcebergCatalog(
entityManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ public void before(TestInfo testInfo) {
PolarisPassthroughResolutionView passthroughView =
new PolarisPassthroughResolutionView(
polarisContext, entityManager, securityContext, CATALOG_NAME);
RealmEntityManagerFactory realmEntityManagerFactory =
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache);
FileIOFactory fileIOFactory =
new DefaultFileIOFactory(
new RealmEntityManagerFactory(
metaStoreManagerFactory, configurationStore, storageCredentialCache),
metaStoreManagerFactory);
new DefaultFileIOFactory(realmEntityManagerFactory, metaStoreManagerFactory);

testPolarisEventListener = (TestPolarisEventListener) polarisEventListener;
this.catalog =
Expand Down
Loading