-
Notifications
You must be signed in to change notification settings - Fork 82
feat(integration-tests): Add infrastructure for running integration tests; Add basic integration tests for clp
& clp-s
compression.
#1100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f76462
6fa551a
01fba04
4ac0005
6f76924
6c6701d
c659eb4
dc62fd4
ded7d4c
6880a0f
c24cdaf
9587f99
6d73f31
09fc85c
6216e68
3a6753b
ac5a9d8
734ce73
777a0d3
5dbe1fc
97d881c
55a4b21
4aadaae
3acbf02
be64383
6f83578
cb0d282
57cf51b
bdbe7d2
9c92e93
0857b49
c035d9d
e747bfc
1b10e01
61909bd
54b26a9
2922b47
14b0141
709d9c8
1a33927
b047457
f0c5a8f
9ca7500
28119ea
0cedb12
3508514
0378bed
64dbb72
5ae418c
812450c
011d073
fce6489
5303ec9
9b40d16
53a6768
29c2ded
85c37f2
37ffcac
35f1690
95b6886
0a68983
e4f4891
ca43014
ebbc541
baa6e9d
d22c534
9833069
7c818d4
37c0e23
c608df6
1cae84e
1aa50e6
d49cedd
5ea3289
8f81696
c5ad284
1d63ccc
4139341
d5b7f76
9f30065
6648734
5b219fb
09fbd51
6da26a1
789f4d1
d7619cb
c8bd52f
8400e01
95d19ba
bc4e20b
9f022f8
aaba2f1
cbd0e8e
a4382d6
b53c04a
73dd3d1
9d280d7
0de00bb
2f2c97f
bafa272
98b228d
eaf04e4
51ec20c
fa81d00
7ca37da
9365193
b641bd9
c2073cd
1fcc997
fb274d1
4840360
4f3bb75
66f61a7
47ccb1c
37f59bb
ba35f88
8c98e4d
60501f1
31e69e3
f424f21
31da58e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__/ | ||
.clang-format | ||
.clang-tidy | ||
.lint-venv/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Overview | ||
|
||
::::{grid} 1 1 1 1 | ||
:gutter: 2 | ||
|
||
:::{grid-item-card} | ||
:link: unit-tests | ||
Unit tests | ||
^^^ | ||
Docs about running unit tests for each component. | ||
::: | ||
|
||
:::{grid-item-card} | ||
:link: integration-tests | ||
Integration tests | ||
^^^ | ||
Docs about running CLP's integration tests. | ||
::: | ||
:::: |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Integration tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The `integration-tests` directory contains a Python project that provides end-to-end tests for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CLP via the `pytest` framework. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
## Running tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To run all integration tests: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
task tests:integration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To test the core CLP binaries: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
task tests:integration:core | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
### Using `pytest` markers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To run more specific sets of tests, you can use `pytest` directly with `pytest` markers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
:::{note} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Before running tests using `pytest`, ensure that the CLP package and/or core binaries have been | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
built. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
::: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ensure all commands below are run from inside the `integration-tests` directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To list all available markers: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uv run python -m pytest --markers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+20
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Optional: Add a short “Prerequisites” subsection Briefly call out “Build CLP” and “uv sync” before running commands to help first-time contributors. ## Running tests
+
+### Prerequisites
+
+- Build the CLP components you plan to test (package and/or core).
+- From `integration-tests/`, install deps: `uv sync` 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To run tests related to a specific marker (e.g., `clp_s`): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uv run python -m pytest -m clp_s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
### Specifying custom CLP binary paths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You can override the default binary paths by setting the following environment variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* **`CLP_CORE_BINS_DIR`**: Directory containing the CLP core binaries to test. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* **`CLP_PACKAGE_DIR`**: Directory of the CLP package to test. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Unit tests | ||
|
||
:::{warning} | ||
🚧 This section is under construction. | ||
::: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[pytest] | ||
addopts = | ||
--capture=no | ||
--code-highlight=yes | ||
--color=yes | ||
--strict-config | ||
--strict-markers | ||
--verbose | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
env = | ||
D:CLP_BUILD_DIR=../build | ||
D:CLP_CORE_BINS_DIR=../build/core | ||
D:CLP_PACKAGE_DIR=../build/clp-package | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log_cli = True | ||
log_cli_date_format = %Y-%m-%d %H:%M:%S,%f | ||
log_cli_format = %(name)s %(asctime)s [%(levelname)s] %(message)s | ||
log_cli_level = INFO | ||
markers = | ||
clp: mark tests that use the CLP storage engine | ||
clp_s: mark tests that use the CLP-S storage engine | ||
core: mark tests that test the CLP core binaries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.9 |
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# CLP integration tests | ||
|
||
This Python project provides end-to-end tests for CLP via the `pytest` framework. | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
For more information, see the [integration test docs][integration-test-docs]. | ||
|
||
[integration-test-docs]: https://docs.yscope.com/clp/main/dev-docs/testing/integration-tests |
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,71 @@ | ||||||
[project] | ||||||
name = "integration-tests" | ||||||
version = "0.1.0" | ||||||
description = "Integration tests for CLP." | ||||||
readme = "README.md" | ||||||
authors = [ | ||||||
{ name = "YScope Inc.", email = "dev@yscope.com" } | ||||||
] | ||||||
requires-python = ">=3.9" | ||||||
|
||||||
[project.scripts] | ||||||
integration-tests = "integration_tests:main" | ||||||
|
||||||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
[build-system] | ||||||
requires = ["hatchling"] | ||||||
build-backend = "hatchling.build" | ||||||
|
||||||
[dependency-groups] | ||||||
dev = [ | ||||||
"mypy>=1.16.0", | ||||||
"ruff>=0.11.12", | ||||||
"pytest>=8.4.1", | ||||||
"pytest-env>=1.1.5", | ||||||
] | ||||||
|
||||||
[tool.mypy] | ||||||
strict = true | ||||||
|
||||||
# Additional output | ||||||
pretty = true | ||||||
show_error_code_links = true | ||||||
show_error_context = true | ||||||
show_error_end = true | ||||||
|
||||||
[tool.ruff] | ||||||
line-length = 100 | ||||||
|
||||||
[tool.ruff.lint] | ||||||
select = ["ALL"] | ||||||
ignore = [ | ||||||
"ANN401", # Allow using `Any` type for function signatures | ||||||
"COM812", # Redundant and conflicts with ruff format | ||||||
"D203", # No blank line before docstrings (D211) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Clarify D203 comment to avoid contradiction with D211. D203 conflicts with D211; we’re preferring D211. Update the note. - "D203", # No blank line before docstrings (D211)
+ "D203", # Conflicts with D211; prefer no blank line before class docstring 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||
"D205", # Breaks if summary is larger than one line due to wrapping or if no summary exists | ||||||
"D212", # Enforce docstring summary line on the next line after quotes (D213) | ||||||
"D400", # First line of docstrings may not end in period | ||||||
"D401", # Docstrings should be written in present tense (not imperative) | ||||||
"D415", # First line of docstrings may not end in a period, question mark, or exclamation point | ||||||
"FBT", # Allow bool positional parameters since other value positions are allowed | ||||||
"FIX002", # Allow todo statements | ||||||
"PERF401", # Allow for loops when creating lists | ||||||
"PERF403", # Allow for loops when creating dicts | ||||||
"S311", # Allow usage of `random` package | ||||||
"S603", # Automatically trust inputs of subprocess execution | ||||||
"SIM102", # Allow collapsible if statements for readability | ||||||
"SIM300", # Skip Yoda-condition format fixes | ||||||
"TD002", # Author unnecessary for todo statement | ||||||
"TD003", # Issue link unnecessary for todo statement | ||||||
"UP015", # Explicit open modes are helpful | ||||||
] | ||||||
isort.order-by-type = false | ||||||
|
||||||
[tool.ruff.lint.per-file-ignores] | ||||||
"tests/**" = [ | ||||||
"S101", # Allow usage of pytest `assert` | ||||||
"TC003", # Ignore performance overhead of imports only used for type checking | ||||||
] | ||||||
|
||||||
[tool.ruff.format] | ||||||
docstring-code-format = true | ||||||
docstring-code-line-length = 100 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Integration test package for CLP.""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Top-level package for CLP integration tests.""" | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""Make the fixtures defined in `tests/fixtures/` globally available without imports.""" | ||
|
||
pytest_plugins = [ | ||
"tests.fixtures.integration_test_config", | ||
"tests.fixtures.integration_test_logs", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Fixtures for CLP integration tests.""" | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Define the integration test configuration fixture.""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from tests.utils.config import ( | ||
CoreConfig, | ||
IntegrationTestConfig, | ||
PackageConfig, | ||
) | ||
from tests.utils.utils import get_env_var | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def integration_test_config() -> IntegrationTestConfig: | ||
"""Fixture that provides an IntegrationTestConfig shared across tests.""" | ||
core_config = CoreConfig( | ||
clp_core_bins_dir=Path(get_env_var("CLP_CORE_BINS_DIR")).expanduser().resolve() | ||
) | ||
package_config = PackageConfig( | ||
clp_package_dir=Path(get_env_var("CLP_PACKAGE_DIR")).expanduser().resolve() | ||
) | ||
test_root_dir = Path(get_env_var("CLP_BUILD_DIR")).expanduser().resolve() / "integration-tests" | ||
return IntegrationTestConfig( | ||
core_config=core_config, | ||
package_config=package_config, | ||
test_root_dir=test_root_dir, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
"""Define test logs fixtures.""" | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import logging | ||
import shutil | ||
import subprocess | ||
|
||
import pytest | ||
|
||
from tests.utils.config import ( | ||
IntegrationTestConfig, | ||
IntegrationTestLogs, | ||
) | ||
from tests.utils.utils import unlink | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def hive_24hr( | ||
request: pytest.FixtureRequest, | ||
integration_test_config: IntegrationTestConfig, | ||
) -> IntegrationTestLogs: | ||
"""Fixture that provides `hive_24hr` test logs shared across tests.""" | ||
return _download_and_extract_dataset( | ||
request=request, | ||
integration_test_config=integration_test_config, | ||
name="hive-24hr", | ||
tarball_url="https://zenodo.org/records/7094921/files/hive-24hr.tar.gz?download=1", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def postgresql( | ||
request: pytest.FixtureRequest, | ||
integration_test_config: IntegrationTestConfig, | ||
) -> IntegrationTestLogs: | ||
"""Fixture that provides `postgresql` test logs shared across tests.""" | ||
return _download_and_extract_dataset( | ||
request=request, | ||
integration_test_config=integration_test_config, | ||
name="postgresql", | ||
tarball_url="https://zenodo.org/records/10516402/files/postgresql.tar.gz?download=1", | ||
) | ||
|
||
|
||
def _download_and_extract_dataset( | ||
request: pytest.FixtureRequest, | ||
integration_test_config: IntegrationTestConfig, | ||
name: str, | ||
tarball_url: str, | ||
) -> IntegrationTestLogs: | ||
integration_test_logs = IntegrationTestLogs( | ||
name=name, | ||
tarball_url=tarball_url, | ||
integration_test_config=integration_test_config, | ||
) | ||
if request.config.cache.get(name, False): | ||
logger.info("Test logs `%s` are up-to-date. Skipping download.", name) | ||
return integration_test_logs | ||
|
||
curl_bin = shutil.which("curl") | ||
if curl_bin is None: | ||
err_msg = "curl executable not found" | ||
raise RuntimeError(err_msg) | ||
|
||
try: | ||
# fmt: off | ||
curl_cmds = [ | ||
curl_bin, | ||
"--fail", | ||
"--location", | ||
"--output", str(integration_test_logs.tarball_path), | ||
"--show-error", | ||
tarball_url, | ||
] | ||
# fmt: on | ||
subprocess.run(curl_cmds, check=True) | ||
|
||
unlink(integration_test_logs.extraction_dir) | ||
shutil.unpack_archive( | ||
integration_test_logs.tarball_path, integration_test_logs.extraction_dir | ||
) | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+80
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. Let me know if you need to open an issue for changing the implementation to use the |
||
except Exception as e: | ||
err_msg = f"Failed to download and extract dataset `{name}`." | ||
raise RuntimeError(err_msg) from e | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Allow the extracted content to be deletable or overwritable | ||
chmod_bin = shutil.which("chmod") | ||
if chmod_bin is None: | ||
err_msg = "chmod executable not found" | ||
raise RuntimeError(err_msg) | ||
Comment on lines
+88
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess the linter didn't complain because I turned off the formatting for the curl block. |
||
subprocess.run([chmod_bin, "-R", "gu+w", integration_test_logs.extraction_dir], check=True) | ||
|
||
logger.info("Downloaded and extracted uncompressed logs for dataset `%s`.", name) | ||
request.config.cache.set(name, True) | ||
return integration_test_logs |
Uh oh!
There was an error while loading. Please reload this page.