HDFS-2029. In TestWriteRead, check visible length immediately after openning the file and fix code style. Contributed by John George
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@1131264 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index a9fdb9b..c045501 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -479,6 +479,9 @@
HDFS-1986. Add option to get http/https address from
DFSUtil#getInfoServer(). (Tanping via suresh)
+ HDFS-2029. In TestWriteRead, check visible length immediately after
+ openning the file and fix code style. (John George via szetszwo)
+
OPTIMIZATIONS
HDFS-1458. Improve checkpoint performance by avoiding unnecessary image
diff --git a/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteRead.java b/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteRead.java
index e293c96..0baf759 100644
--- a/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteRead.java
+++ b/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteRead.java
@@ -101,12 +101,11 @@
/** Junit Test reading while writing. */
@Test
- public void TestWriteRead1() throws IOException {
+ public void testWriteReadSeq() throws IOException {
useFCOption = false;
positionReadOption = false;
String fname = filenameOption;
- positionReadOption = false; // sequential read
// need to run long enough to fail: takes 25 to 35 seec on Mac
int stat = testWriteAndRead(fname, WR_NTIMES, WR_CHUNK_SIZE);
LOG.info("Summary status from test1: status= " + stat);
@@ -115,7 +114,7 @@
/** Junit Test position read while writing. */
@Test
- public void TestWriteReadPos() throws IOException {
+ public void testWriteReadPos() throws IOException {
String fname = filenameOption;
positionReadOption = true; // position read
int stat = testWriteAndRead(fname, WR_NTIMES, WR_CHUNK_SIZE);
@@ -146,6 +145,13 @@
long visibleLenFromReadStream = getVisibleFileLength(in);
+ if (visibleLenFromReadStream < byteExpected)
+ {
+ throw new IOException(visibleLenFromReadStream
+ + " = visibleLenFromReadStream < bytesExpected= "
+ + byteExpected);
+ }
+
totalByteRead = readUntilEnd(in, buffer, buffer.length, fname,
beginPosition, visibleLenFromReadStream, positionReadOption);
in.close();