|
@@ -26,6 +26,7 @@ import org.apache.hadoop.fi.DataTransferTestUtil.DataTransferTest;
|
|
|
import org.apache.hadoop.fi.DataTransferTestUtil.DoosAction;
|
|
|
import org.apache.hadoop.fi.DataTransferTestUtil.OomAction;
|
|
|
import org.apache.hadoop.fi.DataTransferTestUtil.SleepAction;
|
|
|
+import org.apache.hadoop.fi.DataTransferTestUtil.VerificationAction;
|
|
|
import org.apache.hadoop.fi.FiTestUtil.Action;
|
|
|
import org.apache.hadoop.fs.FSDataInputStream;
|
|
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
|
@@ -33,6 +34,7 @@ import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
|
+
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Test;
|
|
|
|
|
@@ -45,6 +47,7 @@ public class TestFiDataTransferProtocol {
|
|
|
static {
|
|
|
conf.setInt("dfs.datanode.handler.count", 1);
|
|
|
conf.setInt("dfs.replication", REPLICATION);
|
|
|
+ conf.setInt("dfs.socket.timeout", 5000);
|
|
|
}
|
|
|
|
|
|
static private FSDataOutputStream createFile(FileSystem fs, Path p
|
|
@@ -63,8 +66,8 @@ public class TestFiDataTransferProtocol {
|
|
|
private static void write1byte(String methodName) throws IOException {
|
|
|
final MiniDFSCluster cluster = new MiniDFSCluster(conf, REPLICATION, true,
|
|
|
null);
|
|
|
+ final FileSystem dfs = cluster.getFileSystem();
|
|
|
try {
|
|
|
- final FileSystem dfs = cluster.getFileSystem();
|
|
|
final Path p = new Path("/" + methodName + "/foo");
|
|
|
final FSDataOutputStream out = createFile(dfs, p);
|
|
|
out.write(1);
|
|
@@ -76,6 +79,7 @@ public class TestFiDataTransferProtocol {
|
|
|
Assert.assertEquals(1, b);
|
|
|
}
|
|
|
finally {
|
|
|
+ dfs.close();
|
|
|
cluster.shutdown();
|
|
|
}
|
|
|
}
|
|
@@ -90,6 +94,93 @@ public class TestFiDataTransferProtocol {
|
|
|
write1byte(methodName);
|
|
|
}
|
|
|
|
|
|
+ private static void runReceiverOpWriteBlockTest(String methodName,
|
|
|
+ int errorIndex, Action<DatanodeID> a) throws IOException {
|
|
|
+ FiTestUtil.LOG.info("Running " + methodName + " ...");
|
|
|
+ final DataTransferTest t = (DataTransferTest) DataTransferTestUtil
|
|
|
+ .initTest();
|
|
|
+ t.fiReceiverOpWriteBlock.set(a);
|
|
|
+ t.fiPipelineInitErrorNonAppend.set(new VerificationAction(methodName,
|
|
|
+ errorIndex));
|
|
|
+ write1byte(methodName);
|
|
|
+ Assert.assertTrue(t.isSuccess());
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void runStatusReadTest(String methodName, int errorIndex,
|
|
|
+ Action<DatanodeID> a) throws IOException {
|
|
|
+ FiTestUtil.LOG.info("Running " + methodName + " ...");
|
|
|
+ final DataTransferTest t = (DataTransferTest) DataTransferTestUtil
|
|
|
+ .initTest();
|
|
|
+ t.fiStatusRead.set(a);
|
|
|
+ t.fiPipelineInitErrorNonAppend.set(new VerificationAction(methodName,
|
|
|
+ errorIndex));
|
|
|
+ write1byte(methodName);
|
|
|
+ Assert.assertTrue(t.isSuccess());
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void runCallReceivePacketTest(String methodName,
|
|
|
+ int errorIndex, Action<DatanodeID> a) throws IOException {
|
|
|
+ FiTestUtil.LOG.info("Running " + methodName + " ...");
|
|
|
+ final DataTransferTest t = (DataTransferTest)DataTransferTestUtil.initTest();
|
|
|
+ t.fiCallReceivePacket.set(a);
|
|
|
+ t.fiPipelineErrorAfterInit.set(new VerificationAction(methodName, errorIndex));
|
|
|
+ write1byte(methodName);
|
|
|
+ Assert.assertTrue(t.isSuccess());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup:
|
|
|
+ * DN0 never responses after received setup request from client.
|
|
|
+ * Client gets an IOException and determine DN0 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_01() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 0, new SleepAction(methodName, 0, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup:
|
|
|
+ * DN1 never responses after received setup request from client.
|
|
|
+ * Client gets an IOException and determine DN1 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_02() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 1, new SleepAction(methodName, 1, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup:
|
|
|
+ * DN2 never responses after received setup request from client.
|
|
|
+ * Client gets an IOException and determine DN2 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_03() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 2, new SleepAction(methodName, 2, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN1 never responses after received setup ack from DN2.
|
|
|
+ * Client gets an IOException and determine DN1 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_04() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runStatusReadTest(methodName, 1, new SleepAction(methodName, 1, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN0 never responses after received setup ack from DN1.
|
|
|
+ * Client gets an IOException and determine DN0 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_05() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runStatusReadTest(methodName, 0, new SleepAction(methodName, 0, 0));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Pipeline setup with DN0 very slow but it won't lead to timeout.
|
|
|
* Client finishes setup successfully.
|
|
@@ -120,18 +211,37 @@ public class TestFiDataTransferProtocol {
|
|
|
runSlowDatanodeTest(methodName, new SleepAction(methodName, 2, 3000));
|
|
|
}
|
|
|
|
|
|
- private static void runCallReceivePacketTest(String methodName,
|
|
|
- Action<DatanodeID> a) throws IOException {
|
|
|
- FiTestUtil.LOG.info("Running " + methodName + " ...");
|
|
|
- ((DataTransferTest)DataTransferTestUtil.initTest()).fiCallReceivePacket.set(a);
|
|
|
- write1byte(methodName);
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN0 throws an OutOfMemoryException right after it
|
|
|
+ * received a setup request from client.
|
|
|
+ * Client gets an IOException and determine DN0 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_09() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 0, new OomAction(methodName, 0));
|
|
|
}
|
|
|
|
|
|
- private static void runStatusReadTest(String methodName, Action<DatanodeID> a
|
|
|
- ) throws IOException {
|
|
|
- FiTestUtil.LOG.info("Running " + methodName + " ...");
|
|
|
- ((DataTransferTest)DataTransferTestUtil.initTest()).fiStatusRead.set(a);
|
|
|
- write1byte(methodName);
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN1 throws an OutOfMemoryException right after it
|
|
|
+ * received a setup request from DN0.
|
|
|
+ * Client gets an IOException and determine DN1 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_10() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 1, new OomAction(methodName, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN2 throws an OutOfMemoryException right after it
|
|
|
+ * received a setup request from DN1.
|
|
|
+ * Client gets an IOException and determine DN2 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_11() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runReceiverOpWriteBlockTest(methodName, 2, new OomAction(methodName, 2));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -142,7 +252,18 @@ public class TestFiDataTransferProtocol {
|
|
|
@Test
|
|
|
public void pipeline_Fi_12() throws IOException {
|
|
|
final String methodName = FiTestUtil.getMethodName();
|
|
|
- runStatusReadTest(methodName, new OomAction(methodName, 1));
|
|
|
+ runStatusReadTest(methodName, 1, new OomAction(methodName, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pipeline setup, DN0 throws an OutOfMemoryException right after it
|
|
|
+ * received a setup ack from DN1.
|
|
|
+ * Client gets an IOException and determine DN0 bad.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void pipeline_Fi_13() throws IOException {
|
|
|
+ final String methodName = FiTestUtil.getMethodName();
|
|
|
+ runStatusReadTest(methodName, 0, new OomAction(methodName, 0));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -153,7 +274,7 @@ public class TestFiDataTransferProtocol {
|
|
|
@Test
|
|
|
public void pipeline_Fi_14() throws IOException {
|
|
|
final String methodName = FiTestUtil.getMethodName();
|
|
|
- runCallReceivePacketTest(methodName, new DoosAction(methodName, 0));
|
|
|
+ runCallReceivePacketTest(methodName, 0, new DoosAction(methodName, 0));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -164,9 +285,9 @@ public class TestFiDataTransferProtocol {
|
|
|
@Test
|
|
|
public void pipeline_Fi_15() throws IOException {
|
|
|
final String methodName = FiTestUtil.getMethodName();
|
|
|
- runCallReceivePacketTest(methodName, new DoosAction(methodName, 1));
|
|
|
+ runCallReceivePacketTest(methodName, 1, new DoosAction(methodName, 1));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Streaming: Write a packet, DN2 throws a DiskOutOfSpaceError
|
|
|
* when it writes the data to disk.
|
|
@@ -175,6 +296,6 @@ public class TestFiDataTransferProtocol {
|
|
|
@Test
|
|
|
public void pipeline_Fi_16() throws IOException {
|
|
|
final String methodName = FiTestUtil.getMethodName();
|
|
|
- runCallReceivePacketTest(methodName, new DoosAction(methodName, 2));
|
|
|
+ runCallReceivePacketTest(methodName, 2, new DoosAction(methodName, 2));
|
|
|
}
|
|
|
}
|