HADOOP-15454. TestRollingFileSystemSinkWithLocal fails on Windows. Contributed by Xiao Liang.

This commit is contained in:
Inigo Goiri 2018-05-10 09:41:16 -07:00
parent c8b53c4364
commit 1da8d4190d
1 changed files with 10 additions and 9 deletions

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.metrics2.sink; package org.apache.hadoop.metrics2.sink;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.metrics2.MetricsSystem; import org.apache.hadoop.metrics2.MetricsSystem;
import org.junit.Test; import org.junit.Test;
@ -36,7 +37,7 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testWrite() throws Exception { public void testWrite() throws Exception {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
MetricsSystem ms = initMetricsSystem(path, false, false); MetricsSystem ms = initMetricsSystem(path, false, false);
assertMetricsContents(doWriteTest(ms, path, 1)); assertMetricsContents(doWriteTest(ms, path, 1));
@ -49,7 +50,7 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testSilentWrite() throws Exception { public void testSilentWrite() throws Exception {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
MetricsSystem ms = initMetricsSystem(path, true, false); MetricsSystem ms = initMetricsSystem(path, true, false);
assertMetricsContents(doWriteTest(ms, path, 1)); assertMetricsContents(doWriteTest(ms, path, 1));
@ -62,7 +63,7 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testExistingWrite() throws Exception { public void testExistingWrite() throws Exception {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
assertMetricsContents(doAppendTest(path, false, false, 2)); assertMetricsContents(doAppendTest(path, false, false, 2));
} }
@ -75,7 +76,7 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testExistingWrite2() throws Exception { public void testExistingWrite2() throws Exception {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
MetricsSystem ms = initMetricsSystem(path, false, false); MetricsSystem ms = initMetricsSystem(path, false, false);
preCreateLogFile(path, 2); preCreateLogFile(path, 2);
@ -91,7 +92,7 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testSilentExistingWrite() throws Exception { public void testSilentExistingWrite() throws Exception {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
assertMetricsContents(doAppendTest(path, false, false, 2)); assertMetricsContents(doAppendTest(path, false, false, 2));
} }
@ -101,12 +102,12 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testFailedWrite() { public void testFailedWrite() {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
MetricsSystem ms = initMetricsSystem(path, false, false); MetricsSystem ms = initMetricsSystem(path, false, false);
new MyMetrics1().registerWith(ms); new MyMetrics1().registerWith(ms);
methodDir.setWritable(false); assertTrue(FileUtil.setWritable(methodDir, false));
MockSink.errored = false; MockSink.errored = false;
try { try {
@ -130,12 +131,12 @@ public class TestRollingFileSystemSinkWithLocal
*/ */
@Test @Test
public void testSilentFailedWrite() { public void testSilentFailedWrite() {
String path = methodDir.getAbsolutePath(); String path = methodDir.toURI().toString();
MetricsSystem ms = initMetricsSystem(path, true, false); MetricsSystem ms = initMetricsSystem(path, true, false);
new MyMetrics1().registerWith(ms); new MyMetrics1().registerWith(ms);
methodDir.setWritable(false); assertTrue(FileUtil.setWritable(methodDir, false));
MockSink.errored = false; MockSink.errored = false;
try { try {