@Test (timeout = 30000)
public void testRWBufferDirBecomesRO() throws Exception {

  assumeNotWindows();
  String dir3 = buildBufferDir(ROOT, 3);
  String dir4 = buildBufferDir(ROOT, 4);
  try {
    conf.set(CONTEXT, dir3 + "," + dir4);
    assertTrue(localFs.mkdirs(new Path(dir3)));
    assertTrue(localFs.mkdirs(new Path(dir4)));
    // Create the first small file
    createTempFile(SMALL_FILE_SIZE);
    // Determine the round-robin sequence
    int nextDirIdx = (dirAllocator.getCurrentDirectoryIndex() == 0) ? 3 : 4;
    validateTempDirCreation(buildBufferDir(ROOT, nextDirIdx));
    // change buffer directory 2 to be read only
    new File(new Path(dir4).toUri().getPath()).setReadOnly();
    validateTempDirCreation(dir3);
    validateTempDirCreation(dir3);
  } finally {
    rmBufferDirs();
  }
}