Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了一个从 hdfs 写入和读取的类。给定在这些类被实例化时发生的某些条件,它们创建一个特定的路径和文件,并写入它(或者它们转到先前创建的路径和文件并从中读取)。我已经通过运行一些 hadoop 作业对其进行了测试,它似乎运行正常。
但是,我希望能够在 JUnit 框架中对此进行测试,但是我还没有找到能够在 JUnit 中测试对 hdfs 的读写的好的解决方案。我将不胜感激有关此事的有用建议。谢谢。
我自己还没有尝试过,但我相信您正在寻找的是 org.apache.hadoop.hdfs.MiniDFSCluster。
它在 hadoop-test-.jar 而不是 hadoop-core-.jar 中。我猜 Hadoop 项目在内部使用它进行测试。
这里是:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/MiniDFSCluster.java?revision=1127823&view=markup&pathrev=1130381
我认为在同一个目录中有很多用途,但这里有一个:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteRead.java?revision=1130381&view=markup&pathrev=1130381