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


##########
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:
   Done! The smoke test now exposes an extra unused port to cover this. The 
mocked readiness tests can't get past the port check without a real container, 
so I dropped them.
   



##########
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:
   Added. While checking, I noticed virtual-hosted object requests can also hit 
the wrong bucket, so that's in there too.
   



##########
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:
   Done, one line per paragraph now.
   



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