This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 889f3b7de8 HDDS-10284. Move GenericTestUtils#getTempPath to
MiniOzoneCluster (#8300)
889f3b7de8 is described below
commit 889f3b7de885d498de02a1283d7bf4b7f90d4ec3
Author: Anastasia Kostryukova <[email protected]>
AuthorDate: Fri Apr 18 16:33:58 2025 +0300
HDDS-10284. Move GenericTestUtils#getTempPath to MiniOzoneCluster (#8300)
---
.../org/apache/ozone/test/GenericTestUtils.java | 38 +---------------------
.../apache/hadoop/ozone/TestMiniOzoneCluster.java | 3 +-
.../org/apache/hadoop/ozone/MiniOzoneCluster.java | 31 ++++++++++++++++--
3 files changed, 30 insertions(+), 42 deletions(-)
diff --git
a/hadoop-hdds/test-utils/src/test/java/org/apache/ozone/test/GenericTestUtils.java
b/hadoop-hdds/test-utils/src/test/java/org/apache/ozone/test/GenericTestUtils.java
index dedaaa9b37..78d00712a5 100644
---
a/hadoop-hdds/test-utils/src/test/java/org/apache/ozone/test/GenericTestUtils.java
+++
b/hadoop-hdds/test-utils/src/test/java/org/apache/ozone/test/GenericTestUtils.java
@@ -21,7 +21,6 @@
import com.google.common.base.Preconditions;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -56,9 +55,7 @@
* Provides some very generic helpers which might be used across the tests.
*/
public abstract class GenericTestUtils {
- public static final String SYSPROP_TEST_DATA_DIR = "test.build.data";
- public static final String DEFAULT_TEST_DATA_DIR;
- public static final String DEFAULT_TEST_DATA_PATH = "target/test/data/";
+
/**
* Error string used in
* {@link GenericTestUtils#waitFor(BooleanSupplier, int, int)}.
@@ -68,16 +65,8 @@ public abstract class GenericTestUtils {
public static final String ERROR_INVALID_ARGUMENT =
"Total wait time should be greater than check interval time";
- public static final boolean WINDOWS =
- System.getProperty("os.name").startsWith("Windows");
-
private static final long NANOSECONDS_PER_MILLISECOND = 1_000_000;
- static {
- DEFAULT_TEST_DATA_DIR =
- "target" + File.separator + "test" + File.separator + "data";
- }
-
/**
* Return current time in millis as an {@code Instant}. This may be
* before {@link Instant#now()}, since the latter includes nanoseconds, too.
@@ -90,31 +79,6 @@ public static Instant getTestStartTime() {
return Instant.ofEpochMilli(System.currentTimeMillis());
}
- /**
- * Get a temp path. This may or may not be relative; it depends on what the
- * {@link #SYSPROP_TEST_DATA_DIR} is set to. If unset, it returns a path
- * under the relative path {@link #DEFAULT_TEST_DATA_PATH}
- *
- * @param subpath sub path, with no leading "/" character
- * @return a string to use in paths
- *
- * @deprecated use {@link org.junit.jupiter.api.io.TempDir} instead.
- */
- @Deprecated
- public static String getTempPath(String subpath) {
- String prop = WINDOWS ? DEFAULT_TEST_DATA_PATH
- : System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_PATH);
-
- if (prop.isEmpty()) {
- // corner case: property is there but empty
- prop = DEFAULT_TEST_DATA_PATH;
- }
- if (!prop.endsWith("/")) {
- prop = prop + "/";
- }
- return prop + subpath;
- }
-
/**
* Wait for the specified test to return true. The test will be performed
* initially and then every {@code checkEveryMillis} until at least
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java
index 6e26a3ae7a..de53b851eb 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java
@@ -45,7 +45,6 @@
import
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
import
org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
import org.apache.hadoop.ozone.container.common.volume.StorageVolume;
-import org.apache.ozone.test.GenericTestUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -267,7 +266,7 @@ public void testMultipleDataDirs() throws Exception {
+ "-" + cluster.getClusterId();
assertEquals(name, cluster.getName());
- final String baseDir = GenericTestUtils.getTempPath(name);
+ final String baseDir = MiniOzoneCluster.Builder.getTempPath(name);
assertEquals(baseDir, cluster.getBaseDir());
diff --git
a/hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
b/hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
index 9fa8b79959..6c1a709239 100644
---
a/hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
+++
b/hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
@@ -35,7 +35,6 @@
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.recon.ReconServer;
import
org.apache.hadoop.security.authentication.client.AuthenticationException;
-import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.util.ExitUtils;
import org.apache.ratis.util.function.CheckedFunction;
@@ -250,7 +249,7 @@ default String getName() {
}
default String getBaseDir() {
- return GenericTestUtils.getTempPath(getName());
+ return Builder.getTempPath(getName());
}
/**
@@ -263,6 +262,10 @@ abstract class Builder {
protected static final int ACTIVE_SCMS_NOT_SET = -1;
protected static final int DEFAULT_RATIS_RPC_TIMEOUT_SEC = 1;
+ private static final String SYSPROP_TEST_DATA_DIR = "test.build.data";
+ private static final String DEFAULT_TEST_DATA_PATH = "target/test/data/";
+ private static final boolean WINDOWS =
System.getProperty("os.name").startsWith("Windows");
+
protected OzoneConfiguration conf;
protected String path;
@@ -296,6 +299,28 @@ protected void prepareForNextBuild() {
setClusterId();
}
+ /**
+ * Get a temp path. This may or may not be relative; it depends on what the
+ * {@link #SYSPROP_TEST_DATA_DIR} is set to. If unset, it returns a path
+ * under the relative path {@link #DEFAULT_TEST_DATA_PATH}
+ *
+ * @param subpath sub path, with no leading "/" character
+ * @return a string to use in paths
+ */
+ protected static String getTempPath(String subpath) {
+ String prop = WINDOWS ? DEFAULT_TEST_DATA_PATH
+ : System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_PATH);
+
+ if (prop.isEmpty()) {
+ // corner case: property is there but empty
+ prop = DEFAULT_TEST_DATA_PATH;
+ }
+ if (!prop.endsWith("/")) {
+ prop = prop + "/";
+ }
+ return prop + subpath;
+ }
+
public Builder setSCMConfigurator(SCMConfigurator configurator) {
this.scmConfigurator = configurator;
return this;
@@ -303,7 +328,7 @@ public Builder setSCMConfigurator(SCMConfigurator
configurator) {
private void setClusterId() {
clusterId = UUID.randomUUID().toString();
- path = GenericTestUtils.getTempPath(
+ path = getTempPath(
MiniOzoneClusterImpl.class.getSimpleName() + "-" + clusterId);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]