From 82c5214ab1bc7740027a860b4689d330856eb498 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Fri, 19 Nov 2010 06:26:22 +0000 Subject: [PATCH] HADOOP-7045. TestDU fails on systems with local file systems with extended attributes. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1036746 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ .../core/org/apache/hadoop/fs/TestDU.java | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e88d2b00cc4..9fe67e3da7e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -19,6 +19,9 @@ Trunk (unreleased changes) whose entries are changing (e.g. in a multi-thread or multi-process environment). (Sanjay Radia via eli) + HADOOP-7045. TestDU fails on systems with local file systems with + extended attributes. (eli) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/test/core/org/apache/hadoop/fs/TestDU.java b/src/test/core/org/apache/hadoop/fs/TestDU.java index 6df487be55f..f6cfa1c7cac 100644 --- a/src/test/core/org/apache/hadoop/fs/TestDU.java +++ b/src/test/core/org/apache/hadoop/fs/TestDU.java @@ -65,7 +65,10 @@ public class TestDU extends TestCase { * @throws InterruptedException */ public void testDU() throws IOException, InterruptedException { - int writtenSize = 32*1024; // writing 32K + final int writtenSize = 32*1024; // writing 32K + // Allow for extra 4K on-disk slack for local file systems + // that may store additional file metadata (eg ext attrs). + final int slack = 4*1024; File file = new File(DU_DIR, "data"); createFile(file, writtenSize); @@ -76,7 +79,9 @@ public class TestDU extends TestCase { long duSize = du.getUsed(); du.shutdown(); - assertEquals(writtenSize, duSize); + assertTrue("Invalid on-disk size", + duSize >= writtenSize && + writtenSize <= (duSize + slack)); //test with 0 interval, will not launch thread du = new DU(file, 0); @@ -84,12 +89,16 @@ public class TestDU extends TestCase { duSize = du.getUsed(); du.shutdown(); - assertEquals(writtenSize, duSize); + assertTrue("Invalid on-disk size", + duSize >= writtenSize && + writtenSize <= (duSize + slack)); //test without launching thread du = new DU(file, 10000); duSize = du.getUsed(); - - assertEquals(writtenSize, duSize); + + assertTrue("Invalid on-disk size", + duSize >= writtenSize && + writtenSize <= (duSize + slack)); } }