danielcweeks commented on code in PR #10908:
URL: https://github.com/apache/iceberg/pull/10908#discussion_r1714478569


##########
open-api/src/testFixtures/java/org/apache/iceberg/rest/RCKUtils.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.rest;
+
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.CatalogProperties;
+import org.eclipse.jetty.server.Server;
+
+class RCKUtils {
+  private static final String CATALOG_ENV_PREFIX = "CATALOG_";
+  static final String RCK_REQUIRES_NAMESPACE_CREATE = 
"rck.requires-namespace-create";
+  static final String RCK_SUPPORTS_SERVERSIDE_RETRY = 
"rck.supports-serverside-retry";
+
+  private static Server localServer;
+
+  private RCKUtils() {}
+
+  /**
+   * Utility method that allows configuring catalog properties via environment 
variables.
+   *
+   * <p>Returns a property map for all environment variables that start with 
<code>CATALOG_</code>
+   * replacing double-underscore (<code>__</code>) with dash (<code>-</code>) 
and replacing single
+   * underscore (<code>_</code>) with dot (<code>.</code>) to allow for common 
catalog property
+   * conventions. All characters in the name are converted to lowercase and 
values are unmodified.
+   *
+   * <p>Examples:
+   *
+   * <pre><code>
+   *     CATALOG_CATALOG__IMPL=org.apache.iceberg.jdbc.JdbcCatalog -> 
catalog-impl=org.apache.iceberg.jdbc.JdbcCatalog
+   *     CATALOG_URI=jdbc:sqlite:memory: -> uri=jdbc:sqlite:memory:
+   *     CATALOG_WAREHOUSE=test_warehouse     -> warehouse=test_warehouse
+   *     CATALOG_IO_IMPL=org.apache.iceberg.aws.s3.S3FileIO -> 
io-impl=org.apache.iceberg.aws.s3.S3FileIO
+   * .    CATALOG_JDBC_USER=ice_user     -> jdbc.user=ice_user
+   *
+   * </code></pre>
+   *
+   * @return configuration map
+   */
+  static Map<String, String> environmentCatalogConfig() {
+    return System.getenv().entrySet().stream()
+        .filter(e -> e.getKey().startsWith(CATALOG_ENV_PREFIX))
+        .collect(
+            Collectors.toMap(
+                e ->
+                    e.getKey()
+                        .replaceFirst(CATALOG_ENV_PREFIX, "")
+                        .replaceAll("__", "-")
+                        .replaceAll("_", ".")
+                        .toLowerCase(Locale.ROOT),
+                Map.Entry::getValue,
+                (m1, m2) -> {
+                  throw new IllegalArgumentException("Duplicate key: " + m1);
+                },
+                HashMap::new));
+  }
+
+  static boolean isLocalServer() {
+    return Boolean.parseBoolean(System.getProperty("rck.local", "true"));
+  }
+
+  static void startLocalServer() throws Exception {
+    RESTCatalogServer restServer = new RESTCatalogServer();
+    localServer = restServer.start();
+  }
+
+  static void stopLocalServer() throws Exception {
+    localServer.stop();
+  }
+
+  static RESTCatalog initCatalogClient() {
+    Map<String, String> catalogProperties = Maps.newHashMap();
+    catalogProperties.putAll(RCKUtils.environmentCatalogConfig());
+    catalogProperties.putAll(Maps.fromProperties(System.getProperties()));

Review Comment:
   For now, I think it makes sense to keep this simple and just allow for 
environment variable or java property configuration.  That will allow for 
running this in a CI pipeline and the env support helps with docker images, 
which I think @jbonofre and @Fokko are helping to get setup.
   
   I don't think we want to allow parallel execution since some of the tests 
may conflict in their assertions (e.g. table `t1` does not exist, but some 
other test is using the same named table). 



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to