andrew4699 commented on code in PR #410:
URL: https://github.com/apache/polaris/pull/410#discussion_r1821357668


##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/TestUtil.java:
##########
@@ -177,4 +185,62 @@ public static RESTCatalog createSnowmanManagedCatalog(
     restCatalog.initialize("polaris", propertiesBuilder.buildKeepingLast());
     return restCatalog;
   }
+
+  /**
+   * Performs createSnowmanManagedCatalog() with the given storage config and 
a unique name derived
+   * from the test name.
+   *
+   * @return A client to interact with the catalog.
+   */
+  public static RESTCatalog createSnowmanManagedCatalogWithUniqueName(
+      DropwizardAppExtension<PolarisApplicationConfig> EXT,
+      TestInfo testInfo,
+      PolarisConnectionExtension.PolarisToken adminToken,
+      SnowmanCredentialsExtension.SnowmanCredentials snowmanCredentials,
+      String realm,
+      StorageConfigInfo storageConfigInfo) {
+    String userToken = adminToken.token();
+
+    String catalogName = 
testInfo.getTestMethod().map(Method::getName).orElseThrow();
+    try (Response response =
+        EXT.client()
+            .target(
+                String.format(
+                    "http://localhost:%d/api/management/v1/catalogs/%s";,
+                    EXT.getLocalPort(), catalogName))
+            .request("application/json")
+            .header("Authorization", "Bearer " + userToken)
+            .header(REALM_PROPERTY_KEY, realm)
+            .get()) {
+      if (response.getStatus() == Response.Status.OK.getStatusCode()) {
+        // Already exists! Must be in a parameterized test.
+        // Quick hack to get a unique catalogName.
+        // TODO: Have a while-loop instead with consecutive incrementing 
suffixes.
+        catalogName = catalogName + System.currentTimeMillis();

Review Comment:
   That was just copied from the existing test but I went ahead and updated it 
to a UUID (with dashes removed in case that ever becomes not allowed).



-- 
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]

Reply via email to