Files
dvc/tests/remotes/hdfs.py
T
Ruslan Kuprieiev 51a8c782ae tests: create remote fixtures (#4063)
* tests: use remote fixtures

* tests: use remote fixtures for data cloud tests

* tests: treat remotes as tmp dirs
2020-06-18 01:36:13 +03:00

56 lines
1.1 KiB
Python

import getpass
import os
import platform
from subprocess import CalledProcessError, Popen, check_output
import pytest
from .base import Base
from .local import Local
class HDFS(Base):
@staticmethod
def should_test():
if platform.system() != "Linux":
return False
try:
check_output(
["hadoop", "version"],
shell=True,
executable=os.getenv("SHELL"),
)
except (CalledProcessError, OSError):
return False
p = Popen(
"hadoop fs -ls hdfs://127.0.0.1/",
shell=True,
executable=os.getenv("SHELL"),
)
p.communicate()
if p.returncode != 0:
return False
return True
@staticmethod
def get_url():
return "hdfs://{}@127.0.0.1{}".format(
getpass.getuser(), Local.get_storagepath()
)
@pytest.fixture
def hdfs():
if not HDFS.should_test():
pytest.skip("no hadoop running")
yield HDFS()
@pytest.fixture
def hdfs_remote(tmp_dir, dvc, hdfs):
tmp_dir.add_remote(config=hdfs.config)
yield hdfs