HDFS-13570. TestQuotaByStorageType,TestQuota,TestDFSOutputStream fail on Windows. Contributed by Anbang Hu.
This commit is contained in:
parent
59bde09920
commit
c0ec061e28
|
@ -212,7 +212,7 @@ public class TestDFSOutputStream {
|
||||||
dfsCluster.waitActive();
|
dfsCluster.waitActive();
|
||||||
|
|
||||||
final FSDataOutputStream os = dfsCluster.getFileSystem()
|
final FSDataOutputStream os = dfsCluster.getFileSystem()
|
||||||
.create(new Path(baseDir.getAbsolutePath(), "testPreventOverflow"));
|
.create(new Path(baseDir.getPath(), "testPreventOverflow"));
|
||||||
final DFSOutputStream dos = (DFSOutputStream) Whitebox
|
final DFSOutputStream dos = (DFSOutputStream) Whitebox
|
||||||
.getInternalState(os, "wrappedStream");
|
.getInternalState(os, "wrappedStream");
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class TestQuota {
|
||||||
public void testQuotaCommands() throws Exception {
|
public void testQuotaCommands() throws Exception {
|
||||||
DFSAdmin admin = new DFSAdmin(conf);
|
DFSAdmin admin = new DFSAdmin(conf);
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testNamespaceCommands() throws Exception {
|
public void testNamespaceCommands() throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testSpaceCommands() throws Exception {
|
public void testSpaceCommands() throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testQuotaByStorageType() throws Exception {
|
public void testQuotaByStorageType() throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testMaxSpaceQuotas() throws Exception {
|
public void testMaxSpaceQuotas() throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -1024,7 +1024,7 @@ public class TestQuota {
|
||||||
public void testBlockAllocationAdjustsUsageConservatively()
|
public void testBlockAllocationAdjustsUsageConservatively()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -1074,7 +1074,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleFilesSmallerThanOneBlock() throws Exception {
|
public void testMultipleFilesSmallerThanOneBlock() throws Exception {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -1184,7 +1184,7 @@ public class TestQuota {
|
||||||
@Test
|
@Test
|
||||||
public void testHugeFileCount() throws IOException {
|
public void testHugeFileCount() throws IOException {
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(parent));
|
assertTrue(dfs.mkdirs(parent));
|
||||||
|
|
||||||
|
@ -1217,7 +1217,7 @@ public class TestQuota {
|
||||||
|
|
||||||
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ public class TestQuota {
|
||||||
public void testSetAndClearSpaceQuotaRegular() throws Exception {
|
public void testSetAndClearSpaceQuotaRegular() throws Exception {
|
||||||
|
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
|
||||||
|
@ -1320,7 +1320,7 @@ public class TestQuota {
|
||||||
public void testSetAndClearSpaceQuotaByStorageType() throws Exception {
|
public void testSetAndClearSpaceQuotaByStorageType() throws Exception {
|
||||||
|
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
|
||||||
|
@ -1373,27 +1373,27 @@ public class TestQuota {
|
||||||
* Test to set and clear space quote when directory doesn't exist.
|
* Test to set and clear space quote when directory doesn't exist.
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
public void testSetAndClearSpaceQuotaDirecotryNotExist() throws Exception {
|
public void testSetAndClearSpaceQuotaDirectoryNotExist() throws Exception {
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
|
|
||||||
/* set space quota */
|
/* set space quota */
|
||||||
testSetAndClearSpaceQuotaDirecotryNotExistInternal(
|
testSetAndClearSpaceQuotaDirectoryNotExistInternal(
|
||||||
new String[] {"-setSpaceQuota", "1024", dir.toString()},
|
new String[] {"-setSpaceQuota", "1024", dir.toString()},
|
||||||
dir,
|
dir,
|
||||||
-1,
|
-1,
|
||||||
"setSpaceQuota");
|
"setSpaceQuota");
|
||||||
|
|
||||||
/* clear space quota */
|
/* clear space quota */
|
||||||
testSetAndClearSpaceQuotaDirecotryNotExistInternal(
|
testSetAndClearSpaceQuotaDirectoryNotExistInternal(
|
||||||
new String[] {"-clrSpaceQuota", dir.toString()},
|
new String[] {"-clrSpaceQuota", dir.toString()},
|
||||||
dir,
|
dir,
|
||||||
-1,
|
-1,
|
||||||
"clrSpaceQuota");
|
"clrSpaceQuota");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSetAndClearSpaceQuotaDirecotryNotExistInternal(
|
private void testSetAndClearSpaceQuotaDirectoryNotExistInternal(
|
||||||
final String[] args,
|
final String[] args,
|
||||||
final Path dir,
|
final Path dir,
|
||||||
final int cmdRet,
|
final int cmdRet,
|
||||||
|
@ -1423,7 +1423,7 @@ public class TestQuota {
|
||||||
public void testSetAndClearSpaceQuotaPathIsFile() throws Exception {
|
public void testSetAndClearSpaceQuotaPathIsFile() throws Exception {
|
||||||
|
|
||||||
final Path parent = new Path(
|
final Path parent = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
final Path file = new Path(parent, "path-is-file");
|
final Path file = new Path(parent, "path-is-file");
|
||||||
DFSTestUtil.createFile(dfs, file, 1024L, (short) 1L, 0);
|
DFSTestUtil.createFile(dfs, file, 1024L, (short) 1L, 0);
|
||||||
|
@ -1474,7 +1474,7 @@ public class TestQuota {
|
||||||
public void testSetAndClearSpaceQuotaNoAccess() throws Exception {
|
public void testSetAndClearSpaceQuotaNoAccess() throws Exception {
|
||||||
|
|
||||||
final Path dir = new Path(
|
final Path dir = new Path(
|
||||||
PathUtils.getTestPath(getClass()),
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
|
||||||
|
@ -1496,7 +1496,8 @@ public class TestQuota {
|
||||||
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
|
||||||
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
||||||
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
||||||
final Path dir = new Path(PathUtils.getTestPath(getClass()),
|
final Path dir = new Path(
|
||||||
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
|
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
|
||||||
|
@ -1520,7 +1521,8 @@ public class TestQuota {
|
||||||
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
||||||
GenericTestUtils.setLogLevel(DFSClient.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DFSClient.LOG, Level.TRACE);
|
||||||
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
||||||
final Path dir = new Path(PathUtils.getTestPath(getClass()),
|
final Path dir = new Path(
|
||||||
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
|
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
|
||||||
|
@ -1560,7 +1562,8 @@ public class TestQuota {
|
||||||
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
|
||||||
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
|
||||||
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
||||||
final Path dir = new Path(PathUtils.getTestPath(getClass()),
|
final Path dir = new Path(
|
||||||
|
PathUtils.getTestDir(getClass()).getPath(),
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
dfs.delete(dir, true);
|
dfs.delete(dir, true);
|
||||||
assertTrue(dfs.mkdirs(dir));
|
assertTrue(dfs.mkdirs(dir));
|
||||||
|
@ -1617,7 +1620,8 @@ public class TestQuota {
|
||||||
private static void scanIntoList(
|
private static void scanIntoList(
|
||||||
final ByteArrayOutputStream baos,
|
final ByteArrayOutputStream baos,
|
||||||
final List<String> list) {
|
final List<String> list) {
|
||||||
final Scanner scanner = new Scanner(baos.toString());
|
final Scanner scanner = new Scanner(
|
||||||
|
baos.toString().replaceAll("\r\r\n", System.lineSeparator()));
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
list.add(scanner.nextLine());
|
list.add(scanner.nextLine());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||||
import org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException;
|
import org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.apache.hadoop.test.PathUtils;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -804,8 +803,7 @@ public class TestQuotaByStorageType {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testStorageSpaceQuotaWithWarmPolicy() throws IOException {
|
public void testStorageSpaceQuotaWithWarmPolicy() throws IOException {
|
||||||
final Path testDir = new Path(
|
final Path testDir = new Path(dir,
|
||||||
PathUtils.getTestPath(getClass()),
|
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(testDir));
|
assertTrue(dfs.mkdirs(testDir));
|
||||||
|
|
||||||
|
@ -864,9 +862,7 @@ public class TestQuotaByStorageType {
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
public void testStorageSpaceQuotaWithRepFactor() throws IOException {
|
public void testStorageSpaceQuotaWithRepFactor() throws IOException {
|
||||||
|
final Path testDir = new Path(dir,
|
||||||
final Path testDir = new Path(
|
|
||||||
PathUtils.getTestPath(getClass()),
|
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(testDir));
|
assertTrue(dfs.mkdirs(testDir));
|
||||||
|
|
||||||
|
@ -911,8 +907,7 @@ public class TestQuotaByStorageType {
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
public void testStorageSpaceQuotaPerQuotaClear() throws IOException {
|
public void testStorageSpaceQuotaPerQuotaClear() throws IOException {
|
||||||
final Path testDir = new Path(
|
final Path testDir = new Path(dir,
|
||||||
PathUtils.getTestPath(getClass()),
|
|
||||||
GenericTestUtils.getMethodName());
|
GenericTestUtils.getMethodName());
|
||||||
assertTrue(dfs.mkdirs(testDir));
|
assertTrue(dfs.mkdirs(testDir));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue