Skip to content

Commit c0ec061

Browse files
author
Inigo Goiri
committed
HDFS-13570. TestQuotaByStorageType,TestQuota,TestDFSOutputStream fail on Windows. Contributed by Anbang Hu.
1 parent 59bde09 commit c0ec061

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private void runAdjustChunkBoundary(
212212
dfsCluster.waitActive();
213213

214214
final FSDataOutputStream os = dfsCluster.getFileSystem()
215-
.create(new Path(baseDir.getAbsolutePath(), "testPreventOverflow"));
215+
.create(new Path(baseDir.getPath(), "testPreventOverflow"));
216216
final DFSOutputStream dos = (DFSOutputStream) Whitebox
217217
.getInternalState(os, "wrappedStream");
218218

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void testDSQuotaExceededExceptionIsHumanReadable() {
188188
public void testQuotaCommands() throws Exception {
189189
DFSAdmin admin = new DFSAdmin(conf);
190190
final Path dir = new Path(
191-
PathUtils.getTestPath(getClass()),
191+
PathUtils.getTestDir(getClass()).getPath(),
192192
GenericTestUtils.getMethodName());
193193
assertTrue(dfs.mkdirs(dir));
194194

@@ -478,7 +478,7 @@ public Object run() throws Exception {
478478
@Test
479479
public void testNamespaceCommands() throws Exception {
480480
final Path parent = new Path(
481-
PathUtils.getTestPath(getClass()),
481+
PathUtils.getTestDir(getClass()).getPath(),
482482
GenericTestUtils.getMethodName());
483483
assertTrue(dfs.mkdirs(parent));
484484

@@ -659,7 +659,7 @@ public void testNamespaceCommands() throws Exception {
659659
@Test
660660
public void testSpaceCommands() throws Exception {
661661
final Path parent = new Path(
662-
PathUtils.getTestPath(getClass()),
662+
PathUtils.getTestDir(getClass()).getPath(),
663663
GenericTestUtils.getMethodName());
664664
assertTrue(dfs.mkdirs(parent));
665665

@@ -916,7 +916,7 @@ public void testSpaceCommands() throws Exception {
916916
@Test
917917
public void testQuotaByStorageType() throws Exception {
918918
final Path parent = new Path(
919-
PathUtils.getTestPath(getClass()),
919+
PathUtils.getTestDir(getClass()).getPath(),
920920
GenericTestUtils.getMethodName());
921921
assertTrue(dfs.mkdirs(parent));
922922

@@ -961,7 +961,7 @@ private static void checkContentSummary(final ContentSummary expected,
961961
@Test
962962
public void testMaxSpaceQuotas() throws Exception {
963963
final Path parent = new Path(
964-
PathUtils.getTestPath(getClass()),
964+
PathUtils.getTestDir(getClass()).getPath(),
965965
GenericTestUtils.getMethodName());
966966
assertTrue(dfs.mkdirs(parent));
967967

@@ -1024,7 +1024,7 @@ public void testMaxSpaceQuotas() throws Exception {
10241024
public void testBlockAllocationAdjustsUsageConservatively()
10251025
throws Exception {
10261026
final Path parent = new Path(
1027-
PathUtils.getTestPath(getClass()),
1027+
PathUtils.getTestDir(getClass()).getPath(),
10281028
GenericTestUtils.getMethodName());
10291029
assertTrue(dfs.mkdirs(parent));
10301030

@@ -1074,7 +1074,7 @@ public void testBlockAllocationAdjustsUsageConservatively()
10741074
@Test
10751075
public void testMultipleFilesSmallerThanOneBlock() throws Exception {
10761076
final Path parent = new Path(
1077-
PathUtils.getTestPath(getClass()),
1077+
PathUtils.getTestDir(getClass()).getPath(),
10781078
GenericTestUtils.getMethodName());
10791079
assertTrue(dfs.mkdirs(parent));
10801080

@@ -1184,7 +1184,7 @@ public void testSetSpaceQuotaWhenStorageTypeIsWrong() throws Exception {
11841184
@Test
11851185
public void testHugeFileCount() throws IOException {
11861186
final Path parent = new Path(
1187-
PathUtils.getTestPath(getClass()),
1187+
PathUtils.getTestDir(getClass()).getPath(),
11881188
GenericTestUtils.getMethodName());
11891189
assertTrue(dfs.mkdirs(parent));
11901190

@@ -1217,7 +1217,7 @@ public void testSetSpaceQuotaNegativeNumber() throws Exception {
12171217

12181218
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
12191219
final Path dir = new Path(
1220-
PathUtils.getTestPath(getClass()),
1220+
PathUtils.getTestDir(getClass()).getPath(),
12211221
GenericTestUtils.getMethodName());
12221222
assertTrue(dfs.mkdirs(dir));
12231223

@@ -1248,7 +1248,7 @@ public void testSetSpaceQuotaNegativeNumber() throws Exception {
12481248
public void testSetAndClearSpaceQuotaRegular() throws Exception {
12491249

12501250
final Path dir = new Path(
1251-
PathUtils.getTestPath(getClass()),
1251+
PathUtils.getTestDir(getClass()).getPath(),
12521252
GenericTestUtils.getMethodName());
12531253
assertTrue(dfs.mkdirs(dir));
12541254

@@ -1320,7 +1320,7 @@ private void testSetAndClearSpaceQuotaRegularInternal(
13201320
public void testSetAndClearSpaceQuotaByStorageType() throws Exception {
13211321

13221322
final Path dir = new Path(
1323-
PathUtils.getTestPath(getClass()),
1323+
PathUtils.getTestDir(getClass()).getPath(),
13241324
GenericTestUtils.getMethodName());
13251325
assertTrue(dfs.mkdirs(dir));
13261326

@@ -1373,27 +1373,27 @@ private void testSetAndClearSpaceQuotaByStorageTypeInternal(
13731373
* Test to set and clear space quote when directory doesn't exist.
13741374
*/
13751375
@Test(timeout = 30000)
1376-
public void testSetAndClearSpaceQuotaDirecotryNotExist() throws Exception {
1376+
public void testSetAndClearSpaceQuotaDirectoryNotExist() throws Exception {
13771377
final Path dir = new Path(
1378-
PathUtils.getTestPath(getClass()),
1378+
PathUtils.getTestDir(getClass()).getPath(),
13791379
GenericTestUtils.getMethodName());
13801380

13811381
/* set space quota */
1382-
testSetAndClearSpaceQuotaDirecotryNotExistInternal(
1382+
testSetAndClearSpaceQuotaDirectoryNotExistInternal(
13831383
new String[] {"-setSpaceQuota", "1024", dir.toString()},
13841384
dir,
13851385
-1,
13861386
"setSpaceQuota");
13871387

13881388
/* clear space quota */
1389-
testSetAndClearSpaceQuotaDirecotryNotExistInternal(
1389+
testSetAndClearSpaceQuotaDirectoryNotExistInternal(
13901390
new String[] {"-clrSpaceQuota", dir.toString()},
13911391
dir,
13921392
-1,
13931393
"clrSpaceQuota");
13941394
}
13951395

1396-
private void testSetAndClearSpaceQuotaDirecotryNotExistInternal(
1396+
private void testSetAndClearSpaceQuotaDirectoryNotExistInternal(
13971397
final String[] args,
13981398
final Path dir,
13991399
final int cmdRet,
@@ -1423,7 +1423,7 @@ private void testSetAndClearSpaceQuotaDirecotryNotExistInternal(
14231423
public void testSetAndClearSpaceQuotaPathIsFile() throws Exception {
14241424

14251425
final Path parent = new Path(
1426-
PathUtils.getTestPath(getClass()),
1426+
PathUtils.getTestDir(getClass()).getPath(),
14271427
GenericTestUtils.getMethodName());
14281428
final Path file = new Path(parent, "path-is-file");
14291429
DFSTestUtil.createFile(dfs, file, 1024L, (short) 1L, 0);
@@ -1474,7 +1474,7 @@ private void testSetAndClearSpaceQuotaPathIsFileInternal(
14741474
public void testSetAndClearSpaceQuotaNoAccess() throws Exception {
14751475

14761476
final Path dir = new Path(
1477-
PathUtils.getTestPath(getClass()),
1477+
PathUtils.getTestDir(getClass()).getPath(),
14781478
GenericTestUtils.getMethodName());
14791479
assertTrue(dfs.mkdirs(dir));
14801480

@@ -1496,7 +1496,8 @@ public void testSpaceQuotaExceptionOnClose() throws Exception {
14961496
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
14971497
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
14981498
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
1499-
final Path dir = new Path(PathUtils.getTestPath(getClass()),
1499+
final Path dir = new Path(
1500+
PathUtils.getTestDir(getClass()).getPath(),
15001501
GenericTestUtils.getMethodName());
15011502
assertTrue(dfs.mkdirs(dir));
15021503
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
@@ -1520,7 +1521,8 @@ public void testSpaceQuotaExceptionOnFlush() throws Exception {
15201521
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
15211522
GenericTestUtils.setLogLevel(DFSClient.LOG, Level.TRACE);
15221523
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
1523-
final Path dir = new Path(PathUtils.getTestPath(getClass()),
1524+
final Path dir = new Path(
1525+
PathUtils.getTestDir(getClass()).getPath(),
15241526
GenericTestUtils.getMethodName());
15251527
assertTrue(dfs.mkdirs(dir));
15261528
final String[] args = new String[] {"-setSpaceQuota", "1", dir.toString()};
@@ -1560,7 +1562,8 @@ public void testSpaceQuotaExceptionOnAppend() throws Exception {
15601562
GenericTestUtils.setLogLevel(DFSOutputStream.LOG, Level.TRACE);
15611563
GenericTestUtils.setLogLevel(DataStreamer.LOG, Level.TRACE);
15621564
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
1563-
final Path dir = new Path(PathUtils.getTestPath(getClass()),
1565+
final Path dir = new Path(
1566+
PathUtils.getTestDir(getClass()).getPath(),
15641567
GenericTestUtils.getMethodName());
15651568
dfs.delete(dir, true);
15661569
assertTrue(dfs.mkdirs(dir));
@@ -1617,7 +1620,8 @@ public Integer run() throws Exception {
16171620
private static void scanIntoList(
16181621
final ByteArrayOutputStream baos,
16191622
final List<String> list) {
1620-
final Scanner scanner = new Scanner(baos.toString());
1623+
final Scanner scanner = new Scanner(
1624+
baos.toString().replaceAll("\r\r\n", System.lineSeparator()));
16211625
while (scanner.hasNextLine()) {
16221626
list.add(scanner.nextLine());
16231627
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestQuotaByStorageType.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException;
3737
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
3838
import org.apache.hadoop.test.GenericTestUtils;
39-
import org.apache.hadoop.test.PathUtils;
4039
import org.junit.After;
4140
import org.junit.Before;
4241
import org.junit.Test;
@@ -804,8 +803,7 @@ public void testContentSummaryWithoutStoragePolicy() throws Exception {
804803
*/
805804
@Test
806805
public void testStorageSpaceQuotaWithWarmPolicy() throws IOException {
807-
final Path testDir = new Path(
808-
PathUtils.getTestPath(getClass()),
806+
final Path testDir = new Path(dir,
809807
GenericTestUtils.getMethodName());
810808
assertTrue(dfs.mkdirs(testDir));
811809

@@ -864,9 +862,7 @@ public void testStorageSpaceQuotaWithWarmPolicy() throws IOException {
864862
*/
865863
@Test(timeout = 30000)
866864
public void testStorageSpaceQuotaWithRepFactor() throws IOException {
867-
868-
final Path testDir = new Path(
869-
PathUtils.getTestPath(getClass()),
865+
final Path testDir = new Path(dir,
870866
GenericTestUtils.getMethodName());
871867
assertTrue(dfs.mkdirs(testDir));
872868

@@ -911,8 +907,7 @@ public void testStorageSpaceQuotaWithRepFactor() throws IOException {
911907
*/
912908
@Test(timeout = 30000)
913909
public void testStorageSpaceQuotaPerQuotaClear() throws IOException {
914-
final Path testDir = new Path(
915-
PathUtils.getTestPath(getClass()),
910+
final Path testDir = new Path(dir,
916911
GenericTestUtils.getMethodName());
917912
assertTrue(dfs.mkdirs(testDir));
918913

0 commit comments

Comments
 (0)