Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
6f76462
Add pycache to gitignore
Bill-hbrhbr Jul 10, 2025
6fa551a
Preemptively update docs
Bill-hbrhbr Jul 10, 2025
01fba04
Add project setup
Bill-hbrhbr Jul 10, 2025
4ac0005
Add integration tests to python linting
Bill-hbrhbr Jul 10, 2025
6f76924
Add sample tests and task workflow to run them
Bill-hbrhbr Jul 10, 2025
6c6701d
Big update
Bill-hbrhbr Jul 11, 2025
c659eb4
Add clp-s test code
Bill-hbrhbr Jul 13, 2025
dc62fd4
Package restructure
Bill-hbrhbr Jul 14, 2025
ded7d4c
Complete clp-s testing (with bug)
Bill-hbrhbr Jul 14, 2025
6880a0f
Make clp-s test workable with keys and rows sorting
Bill-hbrhbr Jul 14, 2025
c24cdaf
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Jul 21, 2025
9587f99
Address some review comments
Bill-hbrhbr Jul 24, 2025
6d73f31
Address more review comments
Bill-hbrhbr Jul 24, 2025
09fc85c
turn download and extract fixture into a private helper function
Bill-hbrhbr Jul 24, 2025
6216e68
UNcomment larget datasets
Bill-hbrhbr Jul 24, 2025
3a6753b
Apply suggestions from code review
Bill-hbrhbr Jul 24, 2025
ac5a9d8
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Jul 24, 2025
734ce73
Move download dir and other attributes inside dataset_logs fixture
Bill-hbrhbr Jul 28, 2025
777a0d3
Make json compare into a helper function
Bill-hbrhbr Jul 28, 2025
5dbe1fc
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Jul 28, 2025
97d881c
Add package basic validity check
Bill-hbrhbr Jul 28, 2025
55a4b21
remove dup class def
Bill-hbrhbr Jul 28, 2025
4aadaae
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Jul 31, 2025
3acbf02
Address review comments
Bill-hbrhbr Aug 1, 2025
be64383
remove unnecessary class param customizations
Bill-hbrhbr Aug 1, 2025
6f83578
Add back missing dataset tests
Bill-hbrhbr Aug 1, 2025
cb0d282
Update dev utils
Bill-hbrhbr Aug 1, 2025
57cf51b
Rename fixtures and fields according to offline discussions
Bill-hbrhbr Aug 4, 2025
bdbe7d2
Address most review comments
Bill-hbrhbr Aug 5, 2025
9c92e93
Furthur renaming from package_config to test_config
Bill-hbrhbr Aug 5, 2025
0857b49
Use __post_init__ to improve dataclass design
Bill-hbrhbr Aug 5, 2025
c035d9d
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 6, 2025
e747bfc
Update integration-tests/tests/test_identity_transformation.py
Bill-hbrhbr Aug 6, 2025
1b10e01
Rename to avoid classes starting with Test
Bill-hbrhbr Aug 8, 2025
61909bd
Address review comment
Bill-hbrhbr Aug 8, 2025
54b26a9
Uncomment tests
Bill-hbrhbr Aug 8, 2025
2922b47
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 8, 2025
14b0141
Split out package config
Bill-hbrhbr Aug 8, 2025
709d9c8
Apply suggestions from code review
Bill-hbrhbr Aug 9, 2025
1a33927
Use singular term for name
Bill-hbrhbr Aug 9, 2025
b047457
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 9, 2025
f0c5a8f
abbreviate var
Bill-hbrhbr Aug 9, 2025
9ca7500
Revert test_log_name singular noun change
Bill-hbrhbr Aug 9, 2025
28119ea
Apply suggestions from code review
Bill-hbrhbr Aug 10, 2025
0cedb12
Lint fix
Bill-hbrhbr Aug 10, 2025
3508514
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 13, 2025
0378bed
Address most review comments
Bill-hbrhbr Aug 16, 2025
64dbb72
Test using CLP core bins instead of package
Bill-hbrhbr Aug 16, 2025
5ae418c
Rename tasks
Bill-hbrhbr Aug 16, 2025
812450c
Add uv requirement to core building
Bill-hbrhbr Aug 16, 2025
011d073
Add README shell script lang hint
Bill-hbrhbr Aug 16, 2025
fce6489
Apply suggestions from code review
Bill-hbrhbr Aug 16, 2025
5303ec9
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 16, 2025
9b40d16
Address coderabbit ai copmments
Bill-hbrhbr Aug 16, 2025
53a6768
Add helper for validating directory exists
Bill-hbrhbr Aug 16, 2025
29c2ded
Add docstring for dataclasses
Bill-hbrhbr Aug 17, 2025
85c37f2
Add docstrings for test utils and improve functions
Bill-hbrhbr Aug 17, 2025
37ffcac
Lint fix
Bill-hbrhbr Aug 17, 2025
35f1690
Add mypy and ruff linters
Bill-hbrhbr Aug 17, 2025
95b6886
ruff lint
Bill-hbrhbr Aug 17, 2025
0a68983
Add missing __init__ files
Bill-hbrhbr Aug 17, 2025
e4f4891
Pass mypy test
Bill-hbrhbr Aug 17, 2025
ca43014
Disable warning about assert
Bill-hbrhbr Aug 17, 2025
ebbc541
Add mypy taskflow and fix all ruff complaints
Bill-hbrhbr Aug 17, 2025
baa6e9d
Update integration-tests/.pytest.ini
Bill-hbrhbr Aug 17, 2025
d22c534
Address coderabbit comment
Bill-hbrhbr Aug 17, 2025
9833069
Lint fix
Bill-hbrhbr Aug 17, 2025
7c818d4
logic fix
Bill-hbrhbr Aug 17, 2025
37c0e23
Improve docstrings
Bill-hbrhbr Aug 17, 2025
c608df6
Add linting section to README
Bill-hbrhbr Aug 17, 2025
1cae84e
Apply suggestions from code review
Bill-hbrhbr Aug 17, 2025
1aa50e6
Add yoda-condition check skips
Bill-hbrhbr Aug 17, 2025
d49cedd
Update integration-tests/README.md
Bill-hbrhbr Aug 17, 2025
5ea3289
Space out README code section
Bill-hbrhbr Aug 17, 2025
8f81696
Update integration-tests/pyproject.toml
Bill-hbrhbr Aug 17, 2025
c5ad284
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 17, 2025
1d63ccc
Make use of python class property
Bill-hbrhbr Aug 17, 2025
4139341
Improve taskfile
Bill-hbrhbr Aug 17, 2025
d5b7f76
Fix tab spaces
Bill-hbrhbr Aug 17, 2025
9f30065
Create taskfile python linting for projects using uv
Bill-hbrhbr Aug 17, 2025
6648734
satisfy yaml linter
Bill-hbrhbr Aug 17, 2025
5b219fb
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 18, 2025
09fbd51
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 18, 2025
6da26a1
Refactor docs.
kirkrodrigues Aug 18, 2025
789f4d1
Apply suggestions from code review
Bill-hbrhbr Aug 20, 2025
d7619cb
Address review concern
Bill-hbrhbr Aug 20, 2025
c8bd52f
Apply suggestions from code review
Bill-hbrhbr Aug 20, 2025
8400e01
Address review comments
Bill-hbrhbr Aug 20, 2025
95d19ba
Update integration-tests/tests/utils/config.py
Bill-hbrhbr Aug 20, 2025
bc4e20b
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 20, 2025
9f022f8
Make integration task depend on the whole package
Bill-hbrhbr Aug 20, 2025
aaba2f1
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Aug 24, 2025
cbd0e8e
Apply suggestions from code review
Bill-hbrhbr Sep 2, 2025
a4382d6
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 2, 2025
b53c04a
Rename assert_utils to asserting_utils
Bill-hbrhbr Sep 2, 2025
73dd3d1
Change validate to validates in docstring start
Bill-hbrhbr Sep 2, 2025
9d280d7
abbreviate validate_dir_exists
Bill-hbrhbr Sep 2, 2025
0de00bb
localize integration tests taskfile vars
Bill-hbrhbr Sep 2, 2025
2f2c97f
Add back missing asserting_utils.py
Bill-hbrhbr Sep 2, 2025
bafa272
Update docs/src/dev-docs/index.md
Bill-hbrhbr Sep 2, 2025
98b228d
lint fix
Bill-hbrhbr Sep 2, 2025
eaf04e4
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 3, 2025
51ec20c
Remove unrelated changes
Bill-hbrhbr Sep 3, 2025
fa81d00
Update docs/src/dev-docs/index.md
Bill-hbrhbr Sep 3, 2025
7ca37da
Fix docs.
kirkrodrigues Sep 4, 2025
9365193
Apply Rabbit's suggestion.
kirkrodrigues Sep 8, 2025
b641bd9
Alphabetize .gitignore.
kirkrodrigues Sep 8, 2025
c2073cd
Update integration-tests/README.md
kirkrodrigues Sep 8, 2025
1fcc997
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 10, 2025
fb274d1
Address review comments
Bill-hbrhbr Sep 10, 2025
4840360
typo fix
Bill-hbrhbr Sep 10, 2025
4f3bb75
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 10, 2025
66f61a7
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 11, 2025
47ccb1c
Move python linting checks specific for unit tests into their own cat…
Bill-hbrhbr Sep 11, 2025
37f59bb
Apply suggestions from code review
Bill-hbrhbr Sep 14, 2025
ba35f88
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 14, 2025
8c98e4d
Address review comment
Bill-hbrhbr Sep 14, 2025
60501f1
lint fix
Bill-hbrhbr Sep 14, 2025
31e69e3
use shutil to find chmod binary
Bill-hbrhbr Sep 14, 2025
f424f21
use shutil to find the curl executable
Bill-hbrhbr Sep 15, 2025
31da58e
Merge branch 'main' into integration-tests-boilerplate
Bill-hbrhbr Sep 15, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__/
.clang-format
.clang-tidy
.lint-venv/
Expand Down
2 changes: 2 additions & 0 deletions docs/src/dev-docs/building-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ prebuilt version instead, check out the [releases](https://github.com/y-scope/cl
* python3-venv (for the version of Python installed)
* [Task] 3.44.0
* We pin the version to 3.44.0 due to [y-scope/clp-ffi-js#110].
* [uv] >= 0.8

## Setup

Expand Down Expand Up @@ -80,4 +81,5 @@ task docker-images:package
This will create a Docker image named `clp-package:dev`.

[Task]: https://taskfile.dev/
[uv]: https://docs.astral.sh/uv/
[y-scope/clp-ffi-js#110]: https://github.com/y-scope/clp-ffi-js/issues/110
8 changes: 8 additions & 0 deletions docs/src/dev-docs/components-core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CLP core is the low-level component that performs compression, decompression, an
* We constrain the version to < 4.0.0 due to [y-scope/clp#795].
* [Task] 3.44.0
* We pin the version to 3.44.0 due to [y-scope/clp-ffi-js#110].
* [uv] >= 0.8

To build, we require some source dependencies, packages from package managers, and libraries built
from source.
Expand Down Expand Up @@ -113,6 +114,12 @@ the relevant paths on your machine.
make -j
```

## Test

```shell
task tests:integration:core
```

:::{toctree}
:hidden:

Expand All @@ -125,6 +132,7 @@ regex-utils
[CMake]: https://cmake.org/
[feature-req]: https://github.com/y-scope/clp/issues/new?assignees=&labels=enhancement&template=feature-request.yml
[Task]: https://taskfile.dev/
[uv]: https://docs.astral.sh/uv/
[y-scope/clp-ffi-js#110]: https://github.com/y-scope/clp-ffi-js/issues/110
[y-scope/clp#795]: https://github.com/y-scope/clp/issues/795
[yscope-dev-utils]: https://github.com/y-scope/yscope-dev-utils
16 changes: 16 additions & 0 deletions docs/src/dev-docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Building
Docs about building CLP.
:::

:::{grid-item-card}
:link: testing/index
Testing
^^^
Docs about testing CLP.
:::

:::{grid-item-card}
:link: contributing-getting-started
Contributing
Expand Down Expand Up @@ -50,6 +57,15 @@ Any design docs describing parts of this project.
building-package
:::

:::{toctree}
:caption: Testing
:hidden:

testing/index
testing/unit-tests
testing/integration-tests
:::

:::{toctree}
:caption: Contributing
:hidden:
Expand Down
19 changes: 19 additions & 0 deletions docs/src/dev-docs/testing/index.md
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.
:::
::::
48 changes: 48 additions & 0 deletions docs/src/dev-docs/testing/integration-tests.md
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### 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
```
## Running tests
### Prerequisites
- Build the CLP components you plan to test (package and/or core).
- From `integration-tests/`, install deps: `uv sync`
### 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:
🤖 Prompt for AI Agents
In docs/src/dev-docs/testing/integration-tests.md around lines 20 to 35, add a
short "Prerequisites" subsection before the "Using `pytest` markers" section
that briefly instructs contributors to build the CLP package (e.g., run the
project's build command) and to run "uv sync" to ensure binaries and
dependencies are up-to-date; keep it concise (2–3 lines), in plain language, and
placed immediately above the note about building CLP/core binaries.


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.
5 changes: 5 additions & 0 deletions docs/src/dev-docs/testing/unit-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Unit tests

:::{warning}
🚧 This section is under construction.
:::
20 changes: 20 additions & 0 deletions integration-tests/.pytest.ini
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
env =
D:CLP_BUILD_DIR=../build
D:CLP_CORE_BINS_DIR=../build/core
D:CLP_PACKAGE_DIR=../build/clp-package
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
1 change: 1 addition & 0 deletions integration-tests/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
7 changes: 7 additions & 0 deletions integration-tests/README.md
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.

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
71 changes: 71 additions & 0 deletions integration-tests/pyproject.toml
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"

[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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"D203", # No blank line before docstrings (D211)
"D203", # Conflicts with D211; prefer no blank line before class docstring
🤖 Prompt for AI Agents
In integration-tests/pyproject.toml around line 43, the inline comment for
"D203" incorrectly states "No blank line before docstrings (D211)" causing a
contradiction with D211; update the comment to clearly state that D203 conflicts
with D211 and that the project prefers D211 (e.g., "D203 conflicts with D211; we
prefer D211 — ensure blank line before multi-line docstrings") or remove/replace
the D203 note so it unambiguously reflects the prefered rule.

"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
1 change: 1 addition & 0 deletions integration-tests/src/integration_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Integration test package for CLP."""
1 change: 1 addition & 0 deletions integration-tests/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Top-level package for CLP integration tests."""
6 changes: 6 additions & 0 deletions integration-tests/tests/conftest.py
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",
]
1 change: 1 addition & 0 deletions integration-tests/tests/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Fixtures for CLP integration tests."""
29 changes: 29 additions & 0 deletions integration-tests/tests/fixtures/integration_test_config.py
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,
)
96 changes: 96 additions & 0 deletions integration-tests/tests/fixtures/integration_test_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Define test logs fixtures."""

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
)
Comment on lines +80 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also chmod -R gu+w the files? Since the hive-24hr dataset is read-only by default, task clean will always fail after running the integration tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 os library.

except Exception as e:
err_msg = f"Failed to download and extract dataset `{name}`."
raise RuntimeError(err_msg) from e

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this for chmod but not for curl? Won't subprocess.run fail anyway if the command can't be found?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Loading
Loading