Skip to content

Commit

Permalink
Address tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuQQiu committed Apr 24, 2024
1 parent 6342313 commit ff331cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/fs/test_docker_fsspec_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from alluxiofs import AlluxioFileSystem
from tests.conftest import ALLUXIO_FILE_PATH
from tests.conftest import LOCAL_FILE_PATH
from tests.fs.utils import replace_protocol_with_alluxio

NUM_TESTS = 10

Expand All @@ -12,7 +13,6 @@
LOGGER = logging.getLogger(__name__)

FILE_PATH = "/opt/alluxio/ufs/test.csv"
ALLUXIO_PREFIX = "alluxio::"


def validate_read_range(
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_alluxio_fsspec_cat_file(alluxio_file_system: AlluxioFileSystem):
)
alluxio_fsspec_cat_file(
alluxio_file_system,
ALLUXIO_PREFIX + ALLUXIO_FILE_PATH,
replace_protocol_with_alluxio(ALLUXIO_FILE_PATH),
LOCAL_FILE_PATH,
)
alluxio_fsspec_cat_file(alluxio_file_system, FILE_PATH, LOCAL_FILE_PATH)
Expand Down
6 changes: 2 additions & 4 deletions tests/fs/test_docker_fsspec_dir_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from alluxiofs import AlluxioFileSystem
from tests.conftest import LOCAL_FILE_PATH
from tests.fs.test_docker_fsspec_cat import ALLUXIO_PREFIX
from tests.fs.test_docker_fsspec_file_function import check_file_info

LOGGER = logging.getLogger(__name__)

DIR_PATH = "/opt/alluxio/ufs"
SUB_DIR_PATH = "/opt/alluxio/ufs/hash_res"
FILE_PREFIX = "file://"
ALLUXIO_PREFIX = "alluxio://"


def check_dir_info(dir_info, dir_path):
Expand Down Expand Up @@ -41,9 +41,7 @@ def alluxio_fsspec_test_dir(alluxio_file_system, alluxio_dir_path):
def test_alluxio_fsspec_dir_function(alluxio_file_system: AlluxioFileSystem):
alluxio_fsspec_test_dir(alluxio_file_system, DIR_PATH)
alluxio_fsspec_test_dir(alluxio_file_system, FILE_PREFIX + DIR_PATH)
alluxio_fsspec_test_dir(
alluxio_file_system, ALLUXIO_PREFIX + FILE_PREFIX + DIR_PATH
)
alluxio_fsspec_test_dir(alluxio_file_system, ALLUXIO_PREFIX + DIR_PATH)


def test_etcd_alluxio_fsspec_dir_function(
Expand Down
4 changes: 2 additions & 2 deletions tests/fs/test_docker_fsspec_file_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from alluxiofs import AlluxioFileSystem
from tests.conftest import ALLUXIO_FILE_PATH
from tests.conftest import LOCAL_FILE_PATH
from tests.fs.test_docker_fsspec_cat import ALLUXIO_PREFIX
from tests.fs.test_docker_fsspec_cat import FILE_PATH
from tests.fs.utils import replace_protocol_with_alluxio

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -41,7 +41,7 @@ def test_alluxio_fsspec_file_function(alluxio_file_system: AlluxioFileSystem):
)
alluxio_fsspec_test_file(
alluxio_file_system,
ALLUXIO_PREFIX + ALLUXIO_FILE_PATH,
replace_protocol_with_alluxio(ALLUXIO_FILE_PATH),
LOCAL_FILE_PATH,
)
alluxio_fsspec_test_file(alluxio_file_system, FILE_PATH, LOCAL_FILE_PATH)
Expand Down
6 changes: 6 additions & 0 deletions tests/fs/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import re


def replace_protocol_with_alluxio(file_path):
protocol_pattern = r"^\w+://"
return re.sub(protocol_pattern, "alluxio://", file_path)

0 comments on commit ff331cc

Please sign in to comment.