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

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


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 99f8eabe19b HBASE-29612 Remove HBaseTestingUtil.forceChangeTaskLogDir 
(#7329)
99f8eabe19b is described below

commit 99f8eabe19b4f9ef8e10ea0f0bea0a67d78436dc
Author: Istvan Toth <[email protected]>
AuthorDate: Sat Sep 20 17:06:40 2025 +0200

    HBASE-29612 Remove HBaseTestingUtil.forceChangeTaskLogDir (#7329)
    
    Co-authored-by: Daniel Roudnitsky <[email protected]>
    Signed-off-by: Duo Zhang <[email protected]>
---
 .../apache/hadoop/hbase/backup/TestBackupBase.java |  4 +--
 .../hbase/backup/TestBackupHFileCleaner.java       |  4 +--
 .../hadoop/hbase/backup/TestBackupSmallTests.java  |  4 +--
 .../apache/hadoop/hbase/HBaseTestingUtility.java   | 39 ++++------------------
 4 files changed, 12 insertions(+), 39 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 2a0be003cab..feb403ae549 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
@@ -315,6 +315,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);
@@ -327,9 +329,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 7fba9c02e94..bfc729aa679 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.HBaseTestingUtility;
 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/HBaseTestingUtility.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 3db73e1ad5f..bc49fe40638 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.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;
@@ -139,7 +138,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.RegionSplitter;
 import org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm;
 import org.apache.hadoop.hbase.util.RetryCounter;
@@ -157,7 +155,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.hadoop.security.authentication.util.KerberosName;
 import org.apache.yetus.audience.InterfaceAudience;
@@ -2784,6 +2781,9 @@ public class HBaseTestingUtility extends 
HBaseZKTestingUtility {
 
   /**
    * 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 {
@@ -2794,36 +2794,11 @@ public class HBaseTestingUtility extends 
HBaseZKTestingUtility {
     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) {
-      // TODO Auto-generated catch block
-      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.
    */
@@ -2835,8 +2810,6 @@ public class HBaseTestingUtility extends 
HBaseZKTestingUtility {
     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