|
@@ -818,6 +818,36 @@ public class TestCopyFiles extends TestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** test globbing */
|
|
|
+ public void testGlobbing() throws Exception {
|
|
|
+ String namenode = null;
|
|
|
+ MiniDFSCluster cluster = null;
|
|
|
+ try {
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ cluster = new MiniDFSCluster(conf, 2, true, null);
|
|
|
+ final FileSystem hdfs = cluster.getFileSystem();
|
|
|
+ namenode = FileSystem.getDefaultUri(conf).toString();
|
|
|
+ if (namenode.startsWith("hdfs://")) {
|
|
|
+ MyFile[] files = createFiles(URI.create(namenode), "/srcdat");
|
|
|
+ ToolRunner.run(new DistCp(conf), new String[] {
|
|
|
+ "-log",
|
|
|
+ namenode+"/logs",
|
|
|
+ namenode+"/srcdat/*",
|
|
|
+ namenode+"/destdat"});
|
|
|
+ assertTrue("Source and destination directories do not match.",
|
|
|
+ checkFiles(hdfs, "/destdat", files));
|
|
|
+ FileSystem fs = FileSystem.get(URI.create(namenode+"/logs"), conf);
|
|
|
+ assertTrue("Log directory does not exist.",
|
|
|
+ fs.exists(new Path(namenode+"/logs")));
|
|
|
+ deldir(hdfs, "/destdat");
|
|
|
+ deldir(hdfs, "/srcdat");
|
|
|
+ deldir(hdfs, "/logs");
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (cluster != null) { cluster.shutdown(); }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static void create(FileSystem fs, Path f) throws IOException {
|
|
|
FSDataOutputStream out = fs.create(f);
|
|
|
try {
|