Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added tests_integration/__init__.py
Empty file.
50 changes: 21 additions & 29 deletions tests2/test_cache_fs.py → tests_integration/test_cache_fs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest

from tests2.base import TOP_LEVEL, TestZstash, run_cmd
from tests_integration.utils import TestZstash, run_cmd


class TestCacheFs(TestZstash):
Expand All @@ -17,7 +17,7 @@ def test_hpss_none_fs_on(self):
# internal symlink (in same dir, in different dir), external symlink
# internal hard link (in same dir, in different dir), external hard link, broken hard link
self.setup_dirs(include_broken_symlink=False)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src before create
self.assertTrue(os.path.islink("file0_soft.txt"))
Expand All @@ -28,10 +28,10 @@ def test_hpss_none_fs_on(self):
self.assertFalse(os.path.islink("file_not_included_hard.txt"))
self.assertFalse(os.path.islink("original_was_deleted_hard.txt"))

os.chdir(f"{TOP_LEVEL}/{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache --follow-symlinks zstash_src"
os.chdir(f"{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={self.work_dir}/test_cache --follow-symlinks zstash_src"
run_cmd(cmd)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src after create
# Running `create` should not alter the source directory.
Expand All @@ -44,9 +44,7 @@ def test_hpss_none_fs_on(self):
self.assertFalse(os.path.islink("original_was_deleted_hard.txt"))

os.chdir("../zstash_extracted")
cmd = (
f"zstash extract --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache"
)
cmd = f"zstash extract --hpss=none --cache={self.work_dir}/test_cache"
run_cmd(cmd)

# Test extraction from zstash_archive
Expand Down Expand Up @@ -81,24 +79,22 @@ def test_hpss_none_fs_on_broken_symlink(self):
# Cases:
# broken symlink
self.setup_dirs(include_broken_symlink=True)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src before create
self.assertTrue(os.path.islink("original_was_deleted_soft.txt"))

os.chdir(f"{TOP_LEVEL}/{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache --follow-symlinks zstash_src"
os.chdir(f"{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={self.work_dir}/test_cache --follow-symlinks zstash_src"
run_cmd(cmd)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src after create
# Running `create` should not alter the source directory.
self.assertTrue(os.path.islink("original_was_deleted_soft.txt"))

os.chdir("../zstash_extracted")
cmd = (
f"zstash extract --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache"
)
cmd = f"zstash extract --hpss=none --cache={self.work_dir}/test_cache"
_, err = run_cmd(cmd)
# This is ultimately caused by:
# `Exception: Archive creation failed due to broken symlink.`
Expand All @@ -111,7 +107,7 @@ def test_hpss_none_fs_on_broken_symlink(self):
def test_hpss_none_fs_off(self):
#
self.setup_dirs(include_broken_symlink=False)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src before create
self.assertTrue(os.path.islink("file0_soft.txt"))
Expand All @@ -122,10 +118,10 @@ def test_hpss_none_fs_off(self):
self.assertFalse(os.path.islink("file_not_included_hard.txt"))
self.assertFalse(os.path.islink("original_was_deleted_hard.txt"))

os.chdir(f"{TOP_LEVEL}/{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache zstash_src"
os.chdir(f"{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={self.work_dir}/test_cache zstash_src"
run_cmd(cmd)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src after create
# Running `create` should not alter the source directory.
Expand All @@ -138,9 +134,7 @@ def test_hpss_none_fs_off(self):
self.assertFalse(os.path.islink("original_was_deleted_hard.txt"))

os.chdir("../zstash_extracted")
cmd = (
f"zstash extract --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache"
)
cmd = f"zstash extract --hpss=none --cache={self.work_dir}/test_cache"
run_cmd(cmd)

# Test extraction from zstash_archive
Expand Down Expand Up @@ -172,24 +166,22 @@ def test_hpss_none_fs_off(self):

def test_hpss_none_fs_off_broken_symlink(self):
self.setup_dirs(include_broken_symlink=True)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src before create
self.assertTrue(os.path.islink("original_was_deleted_soft.txt"))

os.chdir(f"{TOP_LEVEL}/{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache zstash_src"
os.chdir(f"{self.work_dir}/")
cmd = f"zstash create --hpss=none --cache={self.work_dir}/test_cache zstash_src"
run_cmd(cmd)
os.chdir(f"{TOP_LEVEL}/{self.work_dir}/zstash_src/")
os.chdir(f"{self.work_dir}/zstash_src/")

# Test zstash_src after create
# Running `create` should not alter the source directory.
self.assertTrue(os.path.islink("original_was_deleted_soft.txt"))

os.chdir("../zstash_extracted")
cmd = (
f"zstash extract --hpss=none --cache={TOP_LEVEL}/{self.work_dir}/test_cache"
)
cmd = f"zstash extract --hpss=none --cache={self.work_dir}/test_cache"
run_cmd(cmd)
# With fs off, this command completes successfully.

Expand Down
10 changes: 10 additions & 0 deletions tests_integration/test_tutorial_2020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Test 2020 tutorial workflow.
# https://github.com/E3SM-Project/zstash/pull/79/files

from tests_integration.utils import TestZstash


class TestTutorial2020(TestZstash):

def test_tutorial_2020(self):
pass
111 changes: 111 additions & 0 deletions tests_integration/test_tutorial_2024.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Test workflow similar to the 2024 tutorial.
# https://github.com/E3SM-Project/zstash/blob/add-tutorial-materials/tutorial_materials/zstash_demo.md


import os

from tests_integration.utils import TestZstash, run_cmd


class TestTutorial2024(TestZstash):

def test_tutorial_2024(self):
# This test can only be run on NERSC, using NERSC HPSS.
self.conditional_hpss_skip()
self.setup_dirs()
os.chdir(f"{self.work_dir}")

files_to_include = "dir1/*.txt" # Should match file1.txt
cmd = f"zstash create --hpss={self.hpss_dir} --cache={self.cache_dir} --include={files_to_include} {self.dir_to_archive}"
output, err = run_cmd(cmd)
expected_present = [
"Creating new tar archive",
"Archiving dir1/file1.txt",
"Transferring file to HPSS",
"Completed archive file",
]
expected_absent = [
"ERROR",
"Archiving file0.txt",
"Archiving file_empty.txt",
"Archiving file0_soft.txt",
"Archiving dir2/file1_soft.txt",
"Archiving file_not_included_soft.txt",
"Archiving file0_hard.txt",
"Archiving dir2/file1_hard.txt",
"Archiving file_not_included_hard.txt",
"Archiving original_was_deleted_hard.txt",
]
self.check_strings(cmd, output + err, expected_present, expected_absent)

os.mkdir("check_output")
os.chdir("check_output")
cmd = f"zstash check --hpss={self.hpss_dir}"
output, err = run_cmd(cmd)
expected_present = [
"Transferring file from HPSS",
"Opening tar archive",
"Checking dir1/file1.txt",
"No failures detected when checking the files",
]
expected_absent = [
"ERROR",
"Checking file0.txt",
"Checking file_empty.txt",
"Checking file0_soft.txt",
"Checking dir2/file1_soft.txt",
"Checking file_not_included_soft.txt",
"Checking file0_hard.txt",
"Checking dir2/file1_hard.txt",
"Checking file_not_included_hard.txt",
"Checking original_was_deleted_hard.txt",
]
self.check_strings(cmd, output + err, expected_present, expected_absent)
os.chdir(f"{self.work_dir}")

os.mkdir("ls_output")
os.chdir("ls_output")
cmd = f"zstash ls --hpss={self.hpss_dir}"
output, err = run_cmd(cmd)
expected_present = [
"dir1/file1.txt",
]
expected_absent = [
"ERROR",
"file0.txt",
"file_empty.txt",
"file0_soft.txt",
"dir2/file1_soft.txt",
"file_not_included_soft.txt",
"file0_hard.txt",
"dir2/file1_hard.txt",
"file_not_included_hard.txt",
"original_was_deleted_hard.txt",
]
self.check_strings(cmd, output + err, expected_present, expected_absent)
os.chdir(f"{self.work_dir}")

os.mkdir("extract_output")
os.chdir("extract_output")
cmd = f"zstash extract --hpss={self.hpss_dir}"
output, err = run_cmd(cmd)
expected_present = [
"Transferring file from HPSS",
"Opening tar archive",
"Extracting dir1/file1.txt",
"No failures detected when extracting the files",
]
expected_absent = [
"ERROR",
"Extracting file0.txt",
"Extracting file_empty.txt",
"Extracting file0_soft.txt",
"Extracting dir2/file1_soft.txt",
"Extracting file_not_included_soft.txt",
"Extracting file0_hard.txt",
"Extracting dir2/file1_hard.txt",
"Extracting file_not_included_hard.txt",
"Extracting original_was_deleted_hard.txt",
]
self.check_strings(cmd, output + err, expected_present, expected_absent)
os.chdir(f"{self.work_dir}")
Loading
Loading