HDFS-13004. TestLeaseRecoveryStriped.testLeaseRecovery is failing when safeLength is 0MB or larger than the test file. (Zsolt Venczel via lei)
This commit is contained in:
parent
370f1c6283
commit
3bd9ea63df
|
@ -363,11 +363,12 @@ public class StripedFileTestUtil {
|
||||||
List<List<LocatedBlock>> blockGroupList = new ArrayList<>();
|
List<List<LocatedBlock>> blockGroupList = new ArrayList<>();
|
||||||
LocatedBlocks lbs = dfs.getClient().getLocatedBlocks(srcPath.toString(), 0L,
|
LocatedBlocks lbs = dfs.getClient().getLocatedBlocks(srcPath.toString(), 0L,
|
||||||
Long.MAX_VALUE);
|
Long.MAX_VALUE);
|
||||||
int expectedNumGroup = 0;
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
expectedNumGroup = (length - 1) / blkGroupSize + 1;
|
int expectedNumGroup = (length - 1) / blkGroupSize + 1;
|
||||||
|
|
||||||
|
assertEquals(expectedNumGroup, lbs.getLocatedBlocks().size());
|
||||||
}
|
}
|
||||||
assertEquals(expectedNumGroup, lbs.getLocatedBlocks().size());
|
|
||||||
|
|
||||||
final ErasureCodingPolicy ecPolicy = dfs.getErasureCodingPolicy(srcPath);
|
final ErasureCodingPolicy ecPolicy = dfs.getErasureCodingPolicy(srcPath);
|
||||||
final int cellSize = ecPolicy.getCellSize();
|
final int cellSize = ecPolicy.getCellSize();
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class TestLeaseRecoveryStriped {
|
||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
private final Path dir = new Path("/" + this.getClass().getSimpleName());
|
private final Path dir = new Path("/" + this.getClass().getSimpleName());
|
||||||
final Path p = new Path(dir, "testfile");
|
final Path p = new Path(dir, "testfile");
|
||||||
|
private final int testFileLength = (stripesPerBlock - 1) * stripeSize;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
|
@ -191,17 +192,20 @@ public class TestLeaseRecoveryStriped {
|
||||||
|
|
||||||
private void runTest(int[] blockLengths, long safeLength) throws Exception {
|
private void runTest(int[] blockLengths, long safeLength) throws Exception {
|
||||||
writePartialBlocks(blockLengths);
|
writePartialBlocks(blockLengths);
|
||||||
|
|
||||||
|
int checkDataLength = Math.min(testFileLength, (int)safeLength);
|
||||||
|
|
||||||
recoverLease();
|
recoverLease();
|
||||||
|
|
||||||
List<Long> oldGS = new ArrayList<>();
|
List<Long> oldGS = new ArrayList<>();
|
||||||
oldGS.add(1001L);
|
oldGS.add(1001L);
|
||||||
StripedFileTestUtil.checkData(dfs, p, (int)safeLength,
|
StripedFileTestUtil.checkData(dfs, p, checkDataLength,
|
||||||
new ArrayList<DatanodeInfo>(), oldGS, blockGroupSize);
|
new ArrayList<DatanodeInfo>(), oldGS, blockGroupSize);
|
||||||
// After recovery, storages are reported by primary DN. we should verify
|
// After recovery, storages are reported by primary DN. we should verify
|
||||||
// storages reported by blockReport.
|
// storages reported by blockReport.
|
||||||
cluster.restartNameNode(true);
|
cluster.restartNameNode(true);
|
||||||
cluster.waitFirstBRCompleted(0, 10000);
|
cluster.waitFirstBRCompleted(0, 10000);
|
||||||
StripedFileTestUtil.checkData(dfs, p, (int)safeLength,
|
StripedFileTestUtil.checkData(dfs, p, checkDataLength,
|
||||||
new ArrayList<DatanodeInfo>(), oldGS, blockGroupSize);
|
new ArrayList<DatanodeInfo>(), oldGS, blockGroupSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,12 +223,11 @@ public class TestLeaseRecoveryStriped {
|
||||||
final FSDataOutputStream out = dfs.create(p);
|
final FSDataOutputStream out = dfs.create(p);
|
||||||
final DFSStripedOutputStream stripedOut = (DFSStripedOutputStream) out
|
final DFSStripedOutputStream stripedOut = (DFSStripedOutputStream) out
|
||||||
.getWrappedStream();
|
.getWrappedStream();
|
||||||
int length = (stripesPerBlock - 1) * stripeSize;
|
|
||||||
int[] posToKill = getPosToKill(blockLengths);
|
int[] posToKill = getPosToKill(blockLengths);
|
||||||
int checkingPos = nextCheckingPos(posToKill, 0);
|
int checkingPos = nextCheckingPos(posToKill, 0);
|
||||||
Set<Integer> stoppedStreamerIndexes = new HashSet<>();
|
Set<Integer> stoppedStreamerIndexes = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
for (int pos = 0; pos < length; pos++) {
|
for (int pos = 0; pos < testFileLength; pos++) {
|
||||||
out.write(StripedFileTestUtil.getByte(pos));
|
out.write(StripedFileTestUtil.getByte(pos));
|
||||||
if (pos == checkingPos) {
|
if (pos == checkingPos) {
|
||||||
for (int index : getIndexToStop(posToKill, pos)) {
|
for (int index : getIndexToStop(posToKill, pos)) {
|
||||||
|
|
Loading…
Reference in New Issue