Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)