def test_webhdfs_cp_file(hdfs_cluster): fs = WebHDFS(hdfs_cluster, user="******", data_proxy={"worker.example.com": "localhost"}) src, dst = "/user/testuser/testrun/f1", "/user/testuser/testrun/f2" fs.mkdir("/user/testuser/testrun") with fs.open(src, "wb") as f: f.write(b"hello") fs.cp_file(src, dst) assert fs.exists(src) assert fs.exists(dst) assert fs.cat(src) == fs.cat(dst)
def test_workflow(hdfs_cluster): w = WebHDFS(hdfs_cluster, user='******', data_proxy={'worker.example.com': 'localhost'}) fn = '/user/testuser/testrun/afile' w.mkdir('/user/testuser/testrun') with w.open(fn, 'wb') as f: f.write(b'hello') assert w.exists(fn) info = w.info(fn) assert info['size'] == 5 assert w.isfile(fn) assert w.cat(fn) == b'hello' w.rm('/user/testuser/testrun', recursive=True) assert not w.exists(fn)
def test_workflow(hdfs_cluster): w = WebHDFS(hdfs_cluster, user="******", data_proxy={"worker.example.com": "localhost"}) fn = "/user/testuser/testrun/afile" w.mkdir("/user/testuser/testrun") with w.open(fn, "wb") as f: f.write(b"hello") assert w.exists(fn) info = w.info(fn) assert info["size"] == 5 assert w.isfile(fn) assert w.cat(fn) == b"hello" w.rm("/user/testuser/testrun", recursive=True) assert not w.exists(fn)