This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new 06baef87b40 HBASE-29612 Remove HBaseTestingUtil.forceChangeTaskLogDir 
(#7326)
06baef87b40 is described below

commit 06baef87b40d6b73a64e3ae6d2d194367d165d14
Author: Istvan Toth <[email protected]>
AuthorDate: Sat Sep 20 17:04:24 2025 +0200

    HBASE-29612 Remove HBaseTestingUtil.forceChangeTaskLogDir (#7326)
    
    Co-authored-by: Daniel Roudnitsky <[email protected]>
    Signed-off-by: Duo Zhang <[email protected]>
    (cherry picked from commit 99b7e6cdba1bc66839bbf3a9f34500937921adc6)
---
 .../apache/hadoop/hbase/backup/TestBackupBase.java |  4 +--
 .../hbase/backup/TestBackupHFileCleaner.java       |  4 +--
 .../hadoop/hbase/backup/TestBackupSmallTests.java  |  4 +--
 .../org/apache/hadoop/hbase/HBaseTestingUtil.java  | 38 ++++------------------
 4 files changed, 12 insertions(+), 38 deletions(-)

diff --git 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
index a14fce59faf..bfc61010257 100644
--- 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
+++ 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
@@ -310,6 +310,8 @@ public class TestBackupBase {
     // Set MultiWAL (with 2 default WAL files per RS)
     conf1.set(WALFactory.WAL_PROVIDER, provider);
     TEST_UTIL.startMiniCluster();
+    conf1 = TEST_UTIL.getConfiguration();
+    TEST_UTIL.startMiniMapReduceCluster();
 
     if (useSecondCluster) {
       conf2 = HBaseConfiguration.create(conf1);
@@ -322,9 +324,7 @@ public class TestBackupBase {
       CommonFSUtils.setWALRootDir(TEST_UTIL2.getConfiguration(), p);
       TEST_UTIL2.startMiniCluster();
     }
-    conf1 = TEST_UTIL.getConfiguration();
 
-    TEST_UTIL.startMiniMapReduceCluster();
     BACKUP_ROOT_DIR =
       new Path(new Path(TEST_UTIL.getConfiguration().get("fs.defaultFS")), 
BACKUP_ROOT_DIR)
         .toString();
diff --git 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupHFileCleaner.java
 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupHFileCleaner.java
index cfceada51a0..9989748746c 100644
--- 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupHFileCleaner.java
+++ 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupHFileCleaner.java
@@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
 
-@Category({ MasterTests.class, SmallTests.class })
+@Category({ MasterTests.class, MediumTests.class })
 public class TestBackupHFileCleaner {
 
   @ClassRule
diff --git 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSmallTests.java
 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSmallTests.java
index 83cc19578ad..5add9412014 100644
--- 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSmallTests.java
+++ 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSmallTests.java
@@ -22,14 +22,14 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hdfs.DFSTestUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-@Category(SmallTests.class)
+@Category(MediumTests.class)
 public class TestBackupSmallTests extends TestBackupBase {
 
   @ClassRule
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
index 93bde45a9d5..d1b1382c33d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
@@ -28,7 +28,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UncheckedIOException;
 import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
 import java.net.BindException;
 import java.net.DatagramSocket;
 import java.net.InetAddress;
@@ -136,7 +135,6 @@ import org.apache.hadoop.hbase.util.JVMClusterUtil;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
 import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.ReflectionUtils;
 import org.apache.hadoop.hbase.util.RetryCounter;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.wal.WAL;
@@ -152,7 +150,6 @@ import 
org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
 import org.apache.hadoop.hdfs.server.namenode.EditLogFileOutputStream;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MiniMRCluster;
-import org.apache.hadoop.mapred.TaskLog;
 import org.apache.hadoop.minikdc.MiniKdc;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
@@ -2295,6 +2292,9 @@ public class HBaseTestingUtil extends HBaseZKTestingUtil {
 
   /**
    * Starts a <code>MiniMRCluster</code> with a default number of 
<code>TaskTracker</code>'s.
+   * MiniMRCluster caches hadoop.log.dir when first started. It is not 
possible to start multiple
+   * MiniMRCluster instances with different log dirs. MiniMRCluster is only to 
be used from when the
+   * test is run from a separate VM (i.e not in SmallTests)
    * @throws IOException When starting the cluster fails.
    */
   public MiniMRCluster startMiniMapReduceCluster() throws IOException {
@@ -2305,35 +2305,11 @@ public class HBaseTestingUtil extends 
HBaseZKTestingUtil {
     return mrCluster;
   }
 
-  /**
-   * Tasktracker has a bug where changing the hadoop.log.dir system property 
will not change its
-   * internal static LOG_DIR variable.
-   */
-  private void forceChangeTaskLogDir() {
-    Field logDirField;
-    try {
-      logDirField = TaskLog.class.getDeclaredField("LOG_DIR");
-      logDirField.setAccessible(true);
-
-      Field modifiersField = ReflectionUtils.getModifiersField();
-      modifiersField.setAccessible(true);
-      modifiersField.setInt(logDirField, logDirField.getModifiers() & 
~Modifier.FINAL);
-
-      logDirField.set(null, new File(hadoopLogDir, "userlogs"));
-    } catch (SecurityException e) {
-      throw new RuntimeException(e);
-    } catch (NoSuchFieldException e) {
-      throw new RuntimeException(e);
-    } catch (IllegalArgumentException e) {
-      throw new RuntimeException(e);
-    } catch (IllegalAccessException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
   /**
    * Starts a <code>MiniMRCluster</code>. Call {@link 
#setFileSystemURI(String)} to use a different
-   * filesystem.
+   * filesystem. MiniMRCluster caches hadoop.log.dir when first started. It is 
not possible to start
+   * multiple MiniMRCluster instances with different log dirs. MiniMRCluster 
is only to be used from
+   * when the test is run from a separate VM (i.e not in SmallTests)
    * @param servers The number of <code>TaskTracker</code>'s to start.
    * @throws IOException When starting the cluster fails.
    */
@@ -2345,8 +2321,6 @@ public class HBaseTestingUtil extends HBaseZKTestingUtil {
     setupClusterTestDir();
     createDirsAndSetProperties();
 
-    forceChangeTaskLogDir();
-
     //// hadoop2 specific settings
     // Tests were failing because this process used 6GB of virtual memory and 
was getting killed.
     // we up the VM usable so that processes don't get killed.

Reply via email to