HDFS-12497. Re-enable TestDFSStripedOutputStreamWithFailure tests. Contributed by Huafeng Wang.
This commit is contained in:
parent
6b7c87c945
commit
0477eff8be
|
@ -26,6 +26,7 @@ import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse;
|
||||||
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
||||||
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
||||||
|
@ -38,6 +39,7 @@ import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.DataNode;
|
import org.apache.hadoop.hdfs.server.datanode.DataNode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.io.erasurecode.CodecUtil;
|
import org.apache.hadoop.io.erasurecode.CodecUtil;
|
||||||
|
import org.apache.hadoop.io.erasurecode.ECSchema;
|
||||||
import org.apache.hadoop.io.erasurecode.ErasureCodeNative;
|
import org.apache.hadoop.io.erasurecode.ErasureCodeNative;
|
||||||
import org.apache.hadoop.io.erasurecode.rawcoder.NativeRSRawErasureCoderFactory;
|
import org.apache.hadoop.io.erasurecode.rawcoder.NativeRSRawErasureCoderFactory;
|
||||||
import org.apache.hadoop.security.token.Token;
|
import org.apache.hadoop.security.token.Token;
|
||||||
|
@ -77,19 +79,19 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
.getLogger().setLevel(Level.ALL);
|
.getLogger().setLevel(Level.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final int cellSize = 64 * 1024; //64k
|
||||||
|
private final int stripesPerBlock = 4;
|
||||||
private ErasureCodingPolicy ecPolicy;
|
private ErasureCodingPolicy ecPolicy;
|
||||||
private int dataBlocks;
|
private int dataBlocks;
|
||||||
private int parityBlocks;
|
private int parityBlocks;
|
||||||
private int cellSize;
|
|
||||||
private final int stripesPerBlock = 4;
|
|
||||||
private int blockSize;
|
private int blockSize;
|
||||||
private int blockGroupSize;
|
private int blockGroupSize;
|
||||||
|
|
||||||
private static final int FLUSH_POS =
|
private static final int FLUSH_POS =
|
||||||
9 * DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_DEFAULT + 1;
|
9 * DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_DEFAULT + 1;
|
||||||
|
|
||||||
public ErasureCodingPolicy getEcPolicy() {
|
public ECSchema getEcSchema() {
|
||||||
return StripedFileTestUtil.getDefaultECPolicy();
|
return StripedFileTestUtil.getDefaultECPolicy().getSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,10 +99,9 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
ecPolicy = getEcPolicy();
|
ecPolicy = new ErasureCodingPolicy(getEcSchema(), cellSize);
|
||||||
dataBlocks = ecPolicy.getNumDataUnits();
|
dataBlocks = ecPolicy.getNumDataUnits();
|
||||||
parityBlocks = ecPolicy.getNumParityUnits();
|
parityBlocks = ecPolicy.getNumParityUnits();
|
||||||
cellSize = ecPolicy.getCellSize();
|
|
||||||
blockSize = cellSize * stripesPerBlock;
|
blockSize = cellSize * stripesPerBlock;
|
||||||
blockGroupSize = blockSize * dataBlocks;
|
blockGroupSize = blockSize * dataBlocks;
|
||||||
dnIndexSuite = getDnIndexSuite();
|
dnIndexSuite = getDnIndexSuite();
|
||||||
|
@ -220,6 +221,10 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDNs).build();
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDNs).build();
|
||||||
cluster.waitActive();
|
cluster.waitActive();
|
||||||
dfs = cluster.getFileSystem();
|
dfs = cluster.getFileSystem();
|
||||||
|
AddErasureCodingPolicyResponse[] res =
|
||||||
|
dfs.addErasureCodingPolicies(new ErasureCodingPolicy[]{ecPolicy});
|
||||||
|
ecPolicy = res[0].getPolicy();
|
||||||
|
dfs.enableErasureCodingPolicy(ecPolicy.getName());
|
||||||
DFSTestUtil.enableAllECPolicies(dfs);
|
DFSTestUtil.enableAllECPolicies(dfs);
|
||||||
dfs.mkdirs(dir);
|
dfs.mkdirs(dir);
|
||||||
dfs.setErasureCodingPolicy(dir, ecPolicy.getName());
|
dfs.setErasureCodingPolicy(dir, ecPolicy.getName());
|
||||||
|
@ -241,7 +246,7 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=240000)
|
@Test(timeout=300000)
|
||||||
public void testMultipleDatanodeFailure56() throws Exception {
|
public void testMultipleDatanodeFailure56() throws Exception {
|
||||||
runTestWithMultipleFailure(getLength(56));
|
runTestWithMultipleFailure(getLength(56));
|
||||||
}
|
}
|
||||||
|
@ -260,7 +265,8 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
|
|
||||||
@Test(timeout=240000)
|
@Test(timeout=240000)
|
||||||
public void testBlockTokenExpired() throws Exception {
|
public void testBlockTokenExpired() throws Exception {
|
||||||
final int length = dataBlocks * (blockSize - cellSize);
|
// Make sure killPos is greater than the length of one stripe
|
||||||
|
final int length = dataBlocks * cellSize * 3;
|
||||||
final HdfsConfiguration conf = newHdfsConfiguration();
|
final HdfsConfiguration conf = newHdfsConfiguration();
|
||||||
|
|
||||||
conf.setBoolean(DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_ENABLE_KEY, true);
|
conf.setBoolean(DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_ENABLE_KEY, true);
|
||||||
|
@ -306,7 +312,7 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
IOException.class,
|
IOException.class,
|
||||||
"File " + dirFile + " could only be written to " +
|
"File " + dirFile + " could only be written to " +
|
||||||
numDatanodes + " of the " + dataBlocks + " required nodes for " +
|
numDatanodes + " of the " + dataBlocks + " required nodes for " +
|
||||||
getEcPolicy().getName(),
|
ecPolicy.getName(),
|
||||||
() -> {
|
() -> {
|
||||||
try (FSDataOutputStream out = dfs.create(dirFile, true)) {
|
try (FSDataOutputStream out = dfs.create(dirFile, true)) {
|
||||||
out.write("something".getBytes());
|
out.write("something".getBytes());
|
||||||
|
@ -706,8 +712,6 @@ public class TestDFSStripedOutputStreamWithFailure {
|
||||||
|
|
||||||
private void run(int offset) {
|
private void run(int offset) {
|
||||||
int base = getBase();
|
int base = getBase();
|
||||||
// TODO: Fix and re-enable these flaky tests. See HDFS-12417.
|
|
||||||
assumeTrue("Test has been temporarily disabled. See HDFS-12417.", false);
|
|
||||||
assumeTrue(base >= 0);
|
assumeTrue(base >= 0);
|
||||||
final int i = offset + base;
|
final int i = offset + base;
|
||||||
final Integer length = getLength(i);
|
final Integer length = getLength(i);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hdfs;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
import org.apache.hadoop.io.erasurecode.ECSchema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tests write operation of DFS striped file with a random erasure code
|
* This tests write operation of DFS striped file with a random erasure code
|
||||||
|
@ -28,18 +28,18 @@ import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
||||||
public class TestDFSStripedOutputStreamWithFailureWithRandomECPolicy extends
|
public class TestDFSStripedOutputStreamWithFailureWithRandomECPolicy extends
|
||||||
TestDFSStripedOutputStreamWithFailure {
|
TestDFSStripedOutputStreamWithFailure {
|
||||||
|
|
||||||
|
private final ECSchema schema;
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(
|
private static final Log LOG = LogFactory.getLog(
|
||||||
TestDFSStripedOutputStreamWithRandomECPolicy.class.getName());
|
TestDFSStripedOutputStreamWithRandomECPolicy.class.getName());
|
||||||
|
|
||||||
private ErasureCodingPolicy ecPolicy;
|
|
||||||
|
|
||||||
public TestDFSStripedOutputStreamWithFailureWithRandomECPolicy() {
|
public TestDFSStripedOutputStreamWithFailureWithRandomECPolicy() {
|
||||||
ecPolicy = StripedFileTestUtil.getRandomNonDefaultECPolicy();
|
schema = StripedFileTestUtil.getRandomNonDefaultECPolicy().getSchema();
|
||||||
LOG.info(ecPolicy);
|
LOG.info(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErasureCodingPolicy getEcPolicy() {
|
public ECSchema getEcSchema() {
|
||||||
return ecPolicy;
|
return schema;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue