addtestcase

This commit is contained in:
guophilipse 2022-04-24 23:54:52 +08:00
parent 3276544a8d
commit 4dc415002d
1 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,10 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.AppendTestUtil;
import org.apache.hadoop.hdfs.protocol.Block;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
@ -132,6 +136,23 @@ public class OfflineEditsViewerHelper {
DFSTestUtil.runOperations(cluster, dfs, cluster.getConfiguration(0), DFSTestUtil.runOperations(cluster, dfs, cluster.getConfiguration(0),
dfs.getDefaultBlockSize(), 0); dfs.getDefaultBlockSize(), 0);
String client = "client";
String clientMachine = "clientMachine";
String src = "/test/testTruncate";
Path srcPath = new Path(src);
byte[] contents = AppendTestUtil.initBuffer(512);
FSDataOutputStream out = dfs.create(srcPath, true, 4, (short)3,
dfs.getDefaultBlockSize());
out.write(contents, 0, 511);
out.close();
INodesInPath iip = cluster.getNamesystem().getFSDirectory().getINodesInPath(src, FSDirectory.DirOp.WRITE);
cluster.getNamesystem().writeLock();
Block truncateBlock = FSDirTruncateOp.prepareFileForTruncate(cluster.getNamesystem(), iip,
client, clientMachine, 1, null);
cluster.getNamesystem().getEditLog().logTruncate(src, client, clientMachine, truncateBlock.getNumBytes()-1, Time.now(), truncateBlock);
cluster.getNamesystem().writeUnlock();
// OP_ROLLING_UPGRADE_START // OP_ROLLING_UPGRADE_START
cluster.getNamesystem().getEditLog().logStartRollingUpgrade(Time.now()); cluster.getNamesystem().getEditLog().logStartRollingUpgrade(Time.now());
// OP_ROLLING_UPGRADE_FINALIZE // OP_ROLLING_UPGRADE_FINALIZE