@Test
  public void testOldWALsDirSizeChore() throws IOException {
    // Assume the OldWALs directory size is initially zero as the chore hasn't run yet
    long currentOldWALsDirSize = master.getMasterWalManager().getOldWALsDirSize();
    assertEquals("Initial OldWALs directory size should be zero before running the chore", 0,
      currentOldWALsDirSize);

    int dummyFileSize = 50 * 1024 * 1024; // 50MB
    byte[] dummyData = new byte[dummyFileSize];

    // Create a dummy file in the OldWALs directory
    Path dummyFileInOldWALsDir = new Path(master.getMasterWalManager().getOldLogDir(), "dummy.txt");
    try (FSDataOutputStream outputStream =
      master.getMasterWalManager().getFileSystem().create(dummyFileInOldWALsDir)) {
      outputStream.write(dummyData);
    }

    // Run the OldWALsDirSizeChore to update the directory size
    OldWALsDirSizeChore oldWALsDirSizeChore = new OldWALsDirSizeChore(master);
    oldWALsDirSizeChore.chore();

    // Verify that the OldWALs directory size has increased by the file size
    assertEquals("OldWALs directory size after chore should be as expected", dummyFileSize,
      master.getMasterWalManager().getOldWALsDirSize());
  }
Tests for OldWALsDirSizeChore Here we are using the {@link MockMasterServices} to mock the Hbase
Master. Chore's won't be running automatically; we need to run every time.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOldWALsDirSizeChore.java