Skip to content

Commit e7e79e1

Browse files
Merge branch 'main' into feature branch
2 parents 324ade4 + 2f79349 commit e7e79e1

File tree

8 files changed

+96
-91
lines changed

8 files changed

+96
-91
lines changed

integration-tests/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# Make the fixtures defined in `tests/fixtures/` globally available without imports.
66
pytest_plugins = [
7-
"tests.fixtures.integration_test_config",
87
"tests.fixtures.integration_test_logs",
8+
"tests.fixtures.path_configs",
99
"tests.fixtures.package_instance",
1010
"tests.fixtures.package_config",
1111
]

integration-tests/tests/fixtures/integration_test_config.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

integration-tests/tests/fixtures/integration_test_logs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Define test logs fixtures."""
1+
"""Session-scoped test log fixtures shared across integration tests."""
22

33
import logging
44
import shutil
@@ -7,8 +7,8 @@
77
import pytest
88

99
from tests.utils.config import (
10-
IntegrationTestConfig,
1110
IntegrationTestLogs,
11+
IntegrationTestPathConfig,
1212
)
1313
from tests.utils.utils import unlink
1414

@@ -18,12 +18,12 @@
1818
@pytest.fixture(scope="session")
1919
def hive_24hr(
2020
request: pytest.FixtureRequest,
21-
integration_test_config: IntegrationTestConfig,
21+
integration_test_path_config: IntegrationTestPathConfig,
2222
) -> IntegrationTestLogs:
23-
"""Fixture that provides `hive_24hr` test logs shared across tests."""
23+
"""Provides shared `hive_24hr` test logs."""
2424
return _download_and_extract_dataset(
2525
request=request,
26-
integration_test_config=integration_test_config,
26+
integration_test_path_config=integration_test_path_config,
2727
name="hive-24hr",
2828
tarball_url="https://zenodo.org/records/7094921/files/hive-24hr.tar.gz?download=1",
2929
)
@@ -32,27 +32,27 @@ def hive_24hr(
3232
@pytest.fixture(scope="session")
3333
def postgresql(
3434
request: pytest.FixtureRequest,
35-
integration_test_config: IntegrationTestConfig,
35+
integration_test_path_config: IntegrationTestPathConfig,
3636
) -> IntegrationTestLogs:
37-
"""Fixture that provides `postgresql` test logs shared across tests."""
37+
"""Provides shared `postgresql` test logs."""
3838
return _download_and_extract_dataset(
3939
request=request,
40-
integration_test_config=integration_test_config,
40+
integration_test_path_config=integration_test_path_config,
4141
name="postgresql",
4242
tarball_url="https://zenodo.org/records/10516402/files/postgresql.tar.gz?download=1",
4343
)
4444

4545

4646
def _download_and_extract_dataset(
4747
request: pytest.FixtureRequest,
48-
integration_test_config: IntegrationTestConfig,
48+
integration_test_path_config: IntegrationTestPathConfig,
4949
name: str,
5050
tarball_url: str,
5151
) -> IntegrationTestLogs:
5252
integration_test_logs = IntegrationTestLogs(
5353
name=name,
5454
tarball_url=tarball_url,
55-
integration_test_config=integration_test_config,
55+
integration_test_path_config=integration_test_path_config,
5656
)
5757
if request.config.cache.get(name, False):
5858
logger.info("Test logs `%s` are up-to-date. Skipping download.", name)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Session-scoped path configuration fixtures shared across integration tests."""
2+
3+
import pytest
4+
5+
from tests.utils.config import (
6+
ClpCorePathConfig,
7+
IntegrationTestPathConfig,
8+
PackagePathConfig,
9+
)
10+
from tests.utils.utils import resolve_path_env_var
11+
12+
13+
@pytest.fixture(scope="session")
14+
def clp_core_path_config() -> ClpCorePathConfig:
15+
"""Provides paths for the CLP core binaries."""
16+
return ClpCorePathConfig(clp_core_bins_dir=resolve_path_env_var("CLP_CORE_BINS_DIR"))
17+
18+
19+
@pytest.fixture(scope="session")
20+
def integration_test_path_config() -> IntegrationTestPathConfig:
21+
"""Provides paths for the integration-test directory and its contents."""
22+
return IntegrationTestPathConfig(
23+
test_root_dir=resolve_path_env_var("CLP_BUILD_DIR") / "integration-tests"
24+
)
25+
26+
27+
@pytest.fixture(scope="session")
28+
def package_path_config() -> PackagePathConfig:
29+
"""Provides paths for the clp-package directory and its contents."""
30+
return PackagePathConfig(clp_package_dir=resolve_path_env_var("CLP_PACKAGE_DIR"))

integration-tests/tests/test_identity_transformation.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
from tests.utils.asserting_utils import run_and_assert
99
from tests.utils.config import (
10-
CompressionTestConfig,
11-
CoreConfig,
12-
IntegrationTestConfig,
10+
ClpCorePathConfig,
11+
CompressionTestPathConfig,
1312
IntegrationTestLogs,
13+
IntegrationTestPathConfig,
1414
)
1515
from tests.utils.utils import (
1616
is_dir_tree_content_equal,
@@ -38,28 +38,28 @@
3838
@text_datasets
3939
def test_clp_identity_transform(
4040
request: pytest.FixtureRequest,
41-
core_config: CoreConfig,
42-
integration_test_config: IntegrationTestConfig,
41+
clp_core_path_config: ClpCorePathConfig,
42+
integration_test_path_config: IntegrationTestPathConfig,
4343
test_logs_fixture: str,
4444
) -> None:
4545
"""
4646
Validate that compression and decompression by the core binary `clp` run successfully and are
4747
lossless.
4848
4949
:param request:
50-
:param core_config:
51-
:param integration_test_config:
50+
:param clp_core_path_config:
51+
:param integration_test_path_config:
5252
:param test_logs_fixture:
5353
"""
5454
integration_test_logs: IntegrationTestLogs = request.getfixturevalue(test_logs_fixture)
55-
test_paths = CompressionTestConfig(
55+
test_paths = CompressionTestPathConfig(
5656
test_name=f"clp-{integration_test_logs.name}",
5757
logs_source_dir=integration_test_logs.extraction_dir,
58-
integration_test_config=integration_test_config,
58+
integration_test_path_config=integration_test_path_config,
5959
)
6060
test_paths.clear_test_outputs()
6161

62-
bin_path = str(core_config.clp_binary_path)
62+
bin_path = str(clp_core_path_config.clp_binary_path)
6363
src_path = str(test_paths.logs_source_dir)
6464
compression_path = str(test_paths.compression_dir)
6565
decompression_path = str(test_paths.decompression_dir)
@@ -92,41 +92,41 @@ def test_clp_identity_transform(
9292
@json_datasets
9393
def test_clp_s_identity_transform(
9494
request: pytest.FixtureRequest,
95-
core_config: CoreConfig,
96-
integration_test_config: IntegrationTestConfig,
95+
clp_core_path_config: ClpCorePathConfig,
96+
integration_test_path_config: IntegrationTestPathConfig,
9797
test_logs_fixture: str,
9898
) -> None:
9999
"""
100100
Validate that compression and decompression by the core binary `clp-s` run successfully and are
101101
lossless.
102102
103103
:param request:
104-
:param core_config:
105-
:param integration_test_config:
104+
:param clp_core_path_config:
105+
:param integration_test_path_config:
106106
:param test_logs_fixture:
107107
"""
108108
integration_test_logs: IntegrationTestLogs = request.getfixturevalue(test_logs_fixture)
109109
test_logs_name = integration_test_logs.name
110110

111-
test_paths = CompressionTestConfig(
111+
test_paths = CompressionTestPathConfig(
112112
test_name=f"clp-s-{test_logs_name}",
113113
logs_source_dir=integration_test_logs.extraction_dir,
114-
integration_test_config=integration_test_config,
114+
integration_test_path_config=integration_test_path_config,
115115
)
116-
_clp_s_compress_and_decompress(core_config, test_paths)
116+
_clp_s_compress_and_decompress(clp_core_path_config, test_paths)
117117

118118
# Recompress the decompressed output that's consolidated into a single json file, and decompress
119119
# it again to verify consistency. The compression input of the second iteration points to the
120120
# decompression output of the first.
121121
# TODO: Remove this check once we can directly compare decompressed logs (which would preserve
122122
# the directory structure and row/key order) with the original downloaded logs.
123123
# See also: https://docs.yscope.com/clp/main/user-guide/core-clp-s.html#current-limitations
124-
consolidated_json_test_paths = CompressionTestConfig(
124+
consolidated_json_test_paths = CompressionTestPathConfig(
125125
test_name=f"clp-s-{test_logs_name}-consolidated-json",
126126
logs_source_dir=test_paths.decompression_dir,
127-
integration_test_config=integration_test_config,
127+
integration_test_path_config=integration_test_path_config,
128128
)
129-
_clp_s_compress_and_decompress(core_config, consolidated_json_test_paths)
129+
_clp_s_compress_and_decompress(clp_core_path_config, consolidated_json_test_paths)
130130

131131
_consolidated_json_file_name = "original"
132132
input_path = consolidated_json_test_paths.logs_source_dir / _consolidated_json_file_name
@@ -140,10 +140,11 @@ def test_clp_s_identity_transform(
140140

141141

142142
def _clp_s_compress_and_decompress(
143-
core_config: CoreConfig, test_paths: CompressionTestConfig
143+
clp_core_path_config: ClpCorePathConfig,
144+
test_paths: CompressionTestPathConfig,
144145
) -> None:
145146
test_paths.clear_test_outputs()
146-
bin_path = str(core_config.clp_s_binary_path)
147+
bin_path = str(clp_core_path_config.clp_s_binary_path)
147148
src_path = str(test_paths.logs_source_dir)
148149
compression_path = str(test_paths.compression_dir)
149150
decompression_path = str(test_paths.decompression_dir)

integration-tests/tests/utils/config.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222

2323
@dataclass(frozen=True)
24-
class CoreConfig:
25-
"""The configuration for the clp core binaries subject to testing."""
24+
class ClpCorePathConfig:
25+
"""Path configuration for the CLP core binaries."""
2626

27-
#:
27+
#: Root directory containing all CLP core binaries.
2828
clp_core_bins_dir: Path
2929

3030
def __post_init__(self) -> None:
@@ -35,7 +35,6 @@ def __post_init__(self) -> None:
3535
clp_core_bins_dir = self.clp_core_bins_dir
3636
validate_dir_exists(clp_core_bins_dir)
3737

38-
# Check for required CLP core binaries
3938
required_binaries = [
4039
"clg",
4140
"clo",
@@ -51,7 +50,7 @@ def __post_init__(self) -> None:
5150
f"CLP core binaries at {clp_core_bins_dir} are incomplete."
5251
f" Missing binaries: {', '.join(missing_binaries)}"
5352
)
54-
raise ValueError(err_msg)
53+
raise RuntimeError(err_msg)
5554

5655
@property
5756
def clp_binary_path(self) -> Path:
@@ -86,15 +85,14 @@ def __post_init__(self, test_root_dir: Path) -> None:
8685
clp_package_dir = self.clp_package_dir
8786
validate_dir_exists(clp_package_dir)
8887

89-
# Check for required package script directories
9088
required_dirs = ["etc", "sbin"]
9189
missing_dirs = [d for d in required_dirs if not (clp_package_dir / d).is_dir()]
9290
if len(missing_dirs) > 0:
9391
err_msg = (
9492
f"CLP package at {clp_package_dir} is incomplete."
9593
f" Missing directories: {', '.join(missing_dirs)}"
9694
)
97-
raise ValueError(err_msg)
95+
raise RuntimeError(err_msg)
9896

9997
# Initialize cache directory for package tests.
10098
validate_dir_exists(test_root_dir)
@@ -218,15 +216,18 @@ def _get_clp_instance_id(clp_instance_id_file_path: Path) -> str:
218216

219217

220218
@dataclass(frozen=True)
221-
class IntegrationTestConfig:
222-
"""The general configuration for integration tests."""
219+
class IntegrationTestPathConfig:
220+
"""Path configuration for CLP integration tests."""
223221

224-
#: Root directory for integration tests output.
222+
#: Default directory for integration test output.
225223
test_root_dir: Path
226-
logs_download_dir_init: InitVar[Path | None] = None
224+
227225
#: Directory to store the downloaded logs.
228226
logs_download_dir: Path = field(init=False, repr=True)
229227

228+
#: Optional initialization value used to set `logs_download_dir`.
229+
logs_download_dir_init: InitVar[Path | None] = None
230+
230231
def __post_init__(self, logs_download_dir_init: Path | None) -> None:
231232
"""Initialize and create required directories for integration tests."""
232233
if logs_download_dir_init is not None:
@@ -246,19 +247,19 @@ class IntegrationTestLogs:
246247
name: str
247248
#:
248249
tarball_url: str
249-
integration_test_config: InitVar[IntegrationTestConfig]
250+
integration_test_path_config: InitVar[IntegrationTestPathConfig]
250251
#:
251252
tarball_path: Path = field(init=False, repr=True)
252253
#:
253254
extraction_dir: Path = field(init=False, repr=True)
254255

255-
def __post_init__(self, integration_test_config: IntegrationTestConfig) -> None:
256+
def __post_init__(self, integration_test_path_config: IntegrationTestPathConfig) -> None:
256257
"""Initialize and set tarball and extraction paths for integration test logs."""
257258
name = self.name.strip()
258259
if 0 == len(name):
259260
err_msg = "`name` cannot be empty."
260261
raise ValueError(err_msg)
261-
logs_download_dir = integration_test_config.logs_download_dir
262+
logs_download_dir = integration_test_path_config.logs_download_dir
262263
validate_dir_exists(logs_download_dir)
263264

264265
object.__setattr__(self, "name", name)
@@ -267,26 +268,26 @@ def __post_init__(self, integration_test_config: IntegrationTestConfig) -> None:
267268

268269

269270
@dataclass(frozen=True)
270-
class CompressionTestConfig:
271-
"""Compression test configuration providing per-test metadata for artifacts and directories."""
271+
class CompressionTestPathConfig:
272+
"""Per-test path configuration for compression workflow artifacts."""
272273

273274
#:
274275
test_name: str
275276
#: Directory containing the original (uncompressed) log files used by this test.
276277
logs_source_dir: Path
277-
integration_test_config: InitVar[IntegrationTestConfig]
278+
integration_test_path_config: InitVar[IntegrationTestPathConfig]
278279
#: Path to store compressed archives generated by the test.
279280
compression_dir: Path = field(init=False, repr=True)
280281
#: Path to store decompressed logs generated by the test.
281282
decompression_dir: Path = field(init=False, repr=True)
282283

283-
def __post_init__(self, integration_test_config: IntegrationTestConfig) -> None:
284+
def __post_init__(self, integration_test_path_config: IntegrationTestPathConfig) -> None:
284285
"""Initialize and set required directory paths for compression tests."""
285286
test_name = self.test_name.strip()
286287
if 0 == len(test_name):
287288
err_msg = "`test_name` cannot be empty."
288289
raise ValueError(err_msg)
289-
test_root_dir = integration_test_config.test_root_dir
290+
test_root_dir = integration_test_path_config.test_root_dir
290291
validate_dir_exists(test_root_dir)
291292

292293
object.__setattr__(self, "test_name", test_name)

0 commit comments

Comments
 (0)