chihsuan commented on code in PR #10966:
URL: https://github.com/apache/ozone/pull/10966#discussion_r4526709794


##########
hadoop-ozone/ozone-testcontainers/src/main/java/org/apache/ozone/testcontainers/OzoneContainer.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.ozone.testcontainers;
+
+import java.time.Duration;
+import org.apache.hadoop.hdds.annotation.InterfaceStability;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
+import org.testcontainers.utility.DockerImageName;
+
+/**
+ * Testcontainers wrapper for a single-node Ozone with S3 Gateway, so JVM
+ * integration tests can start Ozone the way they use the MinIO or LocalStack
+ * modules. Wraps the all-in-one quickstart image,
+ * which runs SCM, OM, datanode, S3 Gateway, Recon and HttpFS in one container
+ * and exposes S3G on 9878.
+ *
+ * <p>Credentials: in non-secure mode S3G does not verify request signatures, 
so any secret / region is
+ * accepted. The access key is still passed to OM as the Ozone user name, so 
it decides the owner of the
+ * buckets and keys a test creates. {@link #getAccessKey()} / {@link 
#getSecretKey()} / {@link #getRegion()}
+ * provide a consistent set for the caller to sign requests with.
+ *
+ * <p>Readiness: the container waits for the S3 Gateway port, then retries 
{@code ozone admin safemode wait}
+ * until SCM leaves safe mode. The startup timeout defaults to four minutes 
and can be changed with
+ * {@link #withStartupTimeout(Duration)}.
+ */
[email protected]
+public class OzoneContainer extends GenericContainer<OzoneContainer> {
+
+  public static final int S3G_PORT = 9878;
+
+  private static final String ACCESS_KEY = "testuser";
+  private static final String SECRET_KEY = "testsecret";
+  private static final String REGION = "us-east-1";
+
+  public OzoneContainer(DockerImageName image) {
+    super(image);
+    withExposedPorts(S3G_PORT);
+    waitingFor(new WaitAllStrategy()
+        .withStrategy(Wait.forListeningPort())

Review Comment:
   What do you think about waiting only on the S3G port?  MinIO and LocalStack 
only wait on their own port or log. I wonder if 
`Wait.forListeningPorts(S3G_PORT)` would keep readiness independent of ports 
users add.
   
   ```suggestion
           .withStrategy(Wait.forListeningPorts(S3G_PORT))
   ```



##########
hadoop-ozone/ozone-testcontainers/README.md:
##########
@@ -0,0 +1,64 @@
+<!--
+  Licensed 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. See accompanying LICENSE file.
+-->
+
+# Ozone Testcontainers module
+
+A Testcontainers module so JVM projects can start a single-node Ozone with S3
+Gateway from their integration tests the same way they use the MinIO / 
LocalStack
+modules. Motivated by the container-based test-framework interest (e.g. Trino)
+raised on [HDDS-14893](https://issues.apache.org/jira/browse/HDDS-14893).

Review Comment:
   nit: I wonder if we need to wrap lines here. The paragraphs break at 
different widths, so maybe one line per paragraph would be simpler.



##########
hadoop-ozone/ozone-testcontainers/README.md:
##########
@@ -0,0 +1,64 @@
+<!--
+  Licensed 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. See accompanying LICENSE file.
+-->
+
+# Ozone Testcontainers module

Review Comment:
   Could we add a short known-limitations section here? I think three things 
that may surprise users:
   
   1. Path-style is required, otherwise requests fail with a bare 405.
   2. `OZONE-SITE.XML_*` env overrides crash the container.
   3. The image needs 4 to 6 GB of memory per HDDS-14452.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to