Skip to content

Commit 4741ef9

Browse files
committed
complete reset of the compression formats
1 parent 78c6458 commit 4741ef9

File tree

3 files changed

+58
-41
lines changed

3 files changed

+58
-41
lines changed

integration-tests/tests/fixtures/integration_test_logs.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,43 @@ def _download_and_extract_dataset(
8484
err_msg = f"Failed to download and extract dataset `{name}`."
8585
raise RuntimeError(err_msg) from e
8686

87-
extraction_path = str(integration_test_logs.extraction_dir)
88-
8987
# Allow the extracted content to be deletable or overwritable
9088
chmod_bin = shutil.which("chmod")
9189
if chmod_bin is None:
9290
err_msg = "chmod executable not found"
9391
raise RuntimeError(err_msg)
94-
subprocess.run([chmod_bin, "-R", "gu+w", extraction_path], check=True)
92+
subprocess.run([chmod_bin, "-R", "gu+w", str(integration_test_logs.extraction_dir)], check=True)
9593

9694
# Create tar of the extracted content for different compression formats
97-
tar_bin = shutil.which("tar")
98-
if tar_bin is None:
99-
err_msg = "tar executable not found"
95+
gzip_bin = shutil.which("gzip")
96+
if gzip_bin is None:
97+
err_msg = "gzip executable not found"
10098
raise RuntimeError(err_msg)
101-
subprocess.run([tar_bin, "--create", f"--file={integration_test_logs.base_tar_path}", f"--directory={integration_test_logs.extraction_dir}", extraction_path], check=True)
102-
103-
# Create LibLZMA xz tar
99+
gzip_cmds = [gzip_bin, "--decompress", "--stdout", str(integration_test_logs.tar_gz_path)]
100+
with integration_test_logs.base_tar_path.open(mode="wb") as fout:
101+
subprocess.run(gzip_cmds, check=True, stdout=fout, stdin=subprocess.DEVNULL)
102+
103+
# Create lz4 tar
104+
lz4_bin = str(integration_test_config.deps_config.lz4_binary_path)
105+
lz4_cmds = [
106+
lz4_bin,
107+
str(integration_test_logs.base_tar_path),
108+
str(integration_test_logs.tar_lz4_path),
109+
]
110+
subprocess.run(lz4_cmds, check=True)
111+
112+
# Create xz tar
104113
xz_bin = str(integration_test_config.deps_config.xz_binary_path)
105-
xz_cmds = [xz_bin, "--keep", "--compress", "--stdout", extraction_path]
106-
with open(integration_test_logs.tar_xz_path, "wb") as fout:
114+
xz_cmds = [xz_bin, "--compress", "--stdout", str(integration_test_logs.base_tar_path)]
115+
with integration_test_logs.tar_xz_path.open(mode="wb") as fout:
107116
subprocess.run(xz_cmds, check=True, stdout=fout, stdin=subprocess.DEVNULL)
108117

118+
# Create zstd tar
119+
zstd_bin = str(integration_test_config.deps_config.zstd_binary_path)
120+
zstd_cmds = [zstd_bin, "--stdout", str(integration_test_logs.base_tar_path)]
121+
with integration_test_logs.tar_zstd_path.open(mode="wb") as fout:
122+
subprocess.run(zstd_cmds, check=True, stdout=fout, stdin=subprocess.DEVNULL)
123+
109124
logger.info("Downloaded and extracted uncompressed logs for dataset `%s`.", name)
110125
request.config.cache.set(name, True)
111126
return integration_test_logs

integration-tests/tests/test_identity_transformation.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,38 @@ def test_clp_identity_transform(
5353
integration_test_logs: IntegrationTestLogs = request.getfixturevalue(test_logs_fixture)
5454
logs_source_dir: Path = integration_test_logs.extraction_dir
5555

56-
#test_paths = CompressionTestConfig(
57-
# test_name=f"clp-{integration_test_logs.name}",
58-
# compression_input=integration_test_logs.extraction_dir,
59-
# integration_test_config=integration_test_config,
60-
#)
61-
#_run_clp_identity_transform(logs_source_dir, test_paths, integration_test_config)
62-
63-
#test_paths = CompressionTestConfig(
64-
# test_name=f"clp-{integration_test_logs.name}-tar-gz",
65-
# compression_input=integration_test_logs.tar_gz_path,
66-
# integration_test_config=integration_test_config,
67-
#)
68-
#_run_clp_identity_transform(logs_source_dir, test_paths, integration_test_config)
69-
70-
test_paths = CompressionTestConfig(
71-
test_name=f"clp-{integration_test_logs.name}-tar-xz",
72-
compression_input=integration_test_logs.tar_xz_path,
73-
integration_test_config=integration_test_config,
74-
)
75-
_run_clp_identity_transform(logs_source_dir, test_paths, integration_test_config)
56+
archives_to_test = [
57+
integration_test_logs.extraction_dir,
58+
integration_test_logs.tar_gz_path,
59+
integration_test_logs.tar_lz4_path,
60+
integration_test_logs.tar_xz_path,
61+
integration_test_logs.tar_zstd_path,
62+
]
63+
for archive_path in archives_to_test:
64+
_run_clp_identity_transform(archive_path, integration_test_config, logs_source_dir)
7665

7766

7867
def _run_clp_identity_transform(
79-
logs_source_dir: Path,
80-
test_paths: CompressionTestConfig,
68+
compression_input: Path,
8169
integration_test_config: IntegrationTestConfig,
70+
logs_source_dir: Path,
8271
) -> None:
72+
test_paths = CompressionTestConfig(
73+
test_name=f"clp-{compression_input.name}",
74+
compression_input=compression_input,
75+
integration_test_config=integration_test_config,
76+
)
8377
test_paths.clear_test_outputs()
8478

8579
bin_path = str(integration_test_config.core_config.clp_binary_path)
8680
input_path = str(test_paths.compression_input)
8781
compression_path = str(test_paths.compression_dir)
8882
decompression_path = str(test_paths.decompression_dir)
89-
path_prefix_to_remove = input_path if test_paths.compression_input.is_dir() else str(test_paths.compression_input.parent)
83+
path_prefix_to_remove = (
84+
input_path
85+
if test_paths.compression_input.is_dir()
86+
else str(test_paths.compression_input.parent)
87+
)
9088

9189
# fmt: off
9290
compression_cmd = [

integration-tests/tests/utils/config.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def xz_binary_path(self) -> Path:
7474
return self.clp_deps_core_dir / "LibLZMA-static-install" / "bin" / "xz"
7575

7676

77-
7877
@dataclass(frozen=True)
7978
class PackageConfig:
8079
"""The configuration for the clp package subject to testing."""
@@ -143,34 +142,39 @@ def __post_init__(self, integration_test_config: IntegrationTestConfig) -> None:
143142
if 0 == len(name):
144143
err_msg = "`name` cannot be empty."
145144
raise ValueError(err_msg)
145+
146146
logs_download_dir = integration_test_config.logs_download_dir
147147
validate_dir_exists_and_is_absolute(logs_download_dir)
148148

149149
object.__setattr__(self, "name", name)
150150
object.__setattr__(self, "extraction_dir", logs_download_dir / name)
151151

152152
@property
153-
def base_tar_path(self) -> None:
153+
def base_tar_path(self) -> Path:
154+
""":return: The absolute path to the tar archive."""
154155
return self.extraction_dir.with_suffix(".tar")
155156

156157
@property
157-
def tar_gz_path(self) -> None:
158+
def tar_gz_path(self) -> Path:
159+
""":return: The absolute path to the tar gzip archive."""
158160
return self.extraction_dir.with_suffix(".tar.gz")
159161

160162
@property
161-
def tar_lz4_path(self) -> None:
163+
def tar_lz4_path(self) -> Path:
164+
""":return: The absolute path to the tar lz4 archive."""
162165
return self.extraction_dir.with_suffix(".tar.lz4")
163166

164167
@property
165-
def tar_xz_path(self) -> None:
168+
def tar_xz_path(self) -> Path:
169+
""":return: The absolute path to the tar xz archive."""
166170
return self.extraction_dir.with_suffix(".tar.xz")
167171

168172
@property
169-
def tar_zstd_path(self) -> None:
173+
def tar_zstd_path(self) -> Path:
174+
""":return: The absolute path to the tar zstd archive."""
170175
return self.extraction_dir.with_suffix(".tar.zstd")
171176

172177

173-
174178
@dataclass(frozen=True)
175179
class CompressionTestConfig:
176180
"""Compression test configuration providing per-test metadata for artifacts and directories."""

0 commit comments

Comments
 (0)