-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
|
||
from alluxiofs import AlluxioFileSystem | ||
from tests.fs.test_docker_fsspec_file_function 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://" | ||
|
||
|
||
def check_dir_info(dir_info, dir_path): | ||
assert dir_info.get("name") == dir_path | ||
assert dir_info.get("type") == "directory" | ||
assert not dir_info.get("size") | ||
|
||
|
||
def alluxio_fsspec_test_dir(alluxio_file_system, alluxio_dir_path): | ||
file_list = alluxio_file_system.ls(alluxio_dir_path) | ||
assert len(file_list) == 2 | ||
if file_list[0].get("type") == "file": | ||
check_file_info(file_list[0]) | ||
check_dir_info(file_list[1], SUB_DIR_PATH) | ||
elif file_list[0].get("type") == "directory": | ||
check_dir_info(file_list[0], SUB_DIR_PATH) | ||
check_file_info(file_list[1]) | ||
else: | ||
raise AssertionError("File type is invalid.") | ||
dir_info = alluxio_file_system.info(alluxio_dir_path) | ||
check_dir_info(dir_info, DIR_PATH) | ||
assert alluxio_file_system.isdir(alluxio_dir_path) | ||
assert not alluxio_file_system.isfile(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 | ||
) | ||
|
||
|
||
def test_etcd_alluxio_fsspec_dir_function( | ||
etcd_alluxio_file_system: AlluxioFileSystem, | ||
): | ||
test_alluxio_fsspec_dir_function(etcd_alluxio_file_system) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters