Skip to content

Commit d11b9e4

Browse files
authored
Allow overriding createCatalog calls in integrations tests (#2516)
This is mostly to add testing flexibility in downstream projects.
1 parent 5f17ff7 commit d11b9e4

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

integration-tests/src/main/java/org/apache/polaris/service/it/env/ManagementApi.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ public GrantResources listGrants(String catalogName, String catalogRoleName) {
164164

165165
public void createCatalog(String principalRoleName, Catalog catalog) {
166166
createCatalog(catalog);
167+
makeAdmin(principalRoleName, catalog);
168+
}
167169

170+
public void makeAdmin(String principalRoleName, Catalog catalog) {
168171
// Create a new CatalogRole that has CATALOG_MANAGE_CONTENT and CATALOG_MANAGE_ACCESS
169172
String catalogRoleName = "custom-admin";
170173
createCatalogRole(catalog.getName(), catalogRoleName);

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationBase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ public void before(TestInfo testInfo) {
275275
.setStorageConfigInfo(storageConfig)
276276
.build();
277277

278-
managementApi.createCatalog(principalRoleName, catalog);
278+
createPolarisCatalog(catalog);
279+
managementApi.makeAdmin(principalRoleName, catalog);
279280

280281
restCatalogConfig =
281282
IntegrationTestsHelper.mergeFromAnnotatedElements(
@@ -340,6 +341,11 @@ protected RESTCatalog catalog() {
340341
return restCatalog;
341342
}
342343

344+
/** Overridable methods to allow subclasses to execute additional logic on catalog creation. */
345+
protected void createPolarisCatalog(Catalog catalog) {
346+
managementApi.createCatalog(catalog);
347+
}
348+
343349
/**
344350
* Initialize a RESTCatalog for testing.
345351
*

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewIntegrationBase.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public void before(TestInfo testInfo) {
137137
.setProperties(props)
138138
.setStorageConfigInfo(storageConfig)
139139
.build();
140-
managementApi.createCatalog(principalRoleName, catalog);
140+
141+
createPolarisCatalog(catalog);
142+
managementApi.makeAdmin(principalRoleName, catalog);
141143

142144
restCatalog =
143145
IcebergHelper.restCatalog(
@@ -152,6 +154,11 @@ public void cleanUp() {
152154
client.cleanUp(adminToken);
153155
}
154156

157+
/** Overridable methods to allow subclasses to execute additional logic on catalog creation. */
158+
protected void createPolarisCatalog(Catalog catalog) {
159+
managementApi.createCatalog(catalog);
160+
}
161+
155162
/**
156163
* @return The catalog's storage config.
157164
*/

0 commit comments

Comments
 (0)