diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16c7992e..1cadb172 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,10 +32,10 @@ jobs: cache: "pip" - name: Install requirements - run: pip install -e '.[cassandra,dev,f${{ matrix.fedora-version }}]' + run: pip install -e '.[cassandra,f${{ matrix.fedora-version }}-dev,f${{ matrix.fedora-version }}]' - name: Execute lints and tests - run: make tests + run: make test - id: upload-codecov # Third-party action pinned to v2.1.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f7ebcd0..89618528 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: black - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 files: \.py$ diff --git a/astacus/coordinator/plugins/clickhouse/dependencies.py b/astacus/coordinator/plugins/clickhouse/dependencies.py index 209c02bd..09624ac9 100644 --- a/astacus/coordinator/plugins/clickhouse/dependencies.py +++ b/astacus/coordinator/plugins/clickhouse/dependencies.py @@ -3,8 +3,8 @@ See LICENSE for details """ from astacus.coordinator.plugins.clickhouse.manifest import AccessEntity, Table -from collections.abc import Sequence -from typing import Callable, Hashable, TypeVar +from collections.abc import Hashable, Sequence +from typing import Callable, TypeVar # noinspection PyCompatibility import graphlib diff --git a/pyproject.toml b/pyproject.toml index e0339243..a047a8a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,7 @@ f39 = [ "wcmatch == 8.4.1", "zstandard == 0.21.0", ] -dev = [ +f38-dev = [ # Needed by pre-commit to lint and test the project "pre-commit>=3.7.0", "anyio==3.5.0", @@ -116,6 +116,31 @@ dev = [ "respx==0.20.1", ] +f39-dev = [ + # Needed by pre-commit to lint and test the project + "pre-commit==3.7.0", + "anyio==3.7.0", + "pylint==3.0.4", + "pytest-asyncio==0.23.5", + "pytest-cov==4.0.0", + "pytest-mock==3.11.1", + "pytest-order", + "pytest-timeout==2.1.0", + "pytest-watch==4.2.0", + "pytest==7.3.2", + "mypy==1.8.0", + # Types for things that don't seem to have them + "types-botocore>=1.0.2", + "types-PyYAML>=6.0.12.2", + "types-requests>=2.28.11.5", + "types-tabulate>=0.9.0.0", + "types-ujson>=5.9.0.0", + "types-urllib3>=1.26.25.4", + "coverage==7.2.7", + "freezegun==1.2.2", + "respx==0.20.2", +] + [project.urls] "Homepage" = "https://github.com/Aiven-Open/astacus" "Bug Tracker" = "https://github.com/Aiven-Open/astacus/issues" diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 4d7298c2..7067fce2 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -4,7 +4,7 @@ """ from astacus.common.utils import build_netloc from astacus.coordinator.plugins.zookeeper import KazooZooKeeperClient -from collections.abc import AsyncIterator, Iterator, Mapping, Sequence +from collections.abc import AsyncIterator, Mapping, Sequence from pathlib import Path from types import MappingProxyType @@ -21,16 +21,6 @@ logger = logging.getLogger(__name__) -@pytest.fixture(scope="module", name="event_loop") -def fixture_event_loop() -> Iterator[asyncio.AbstractEventLoop]: - # This is the same as the original `event_loop` fixture from `pytest_asyncio` - # but with a module scope, re-declaring this fixture is their suggested way - # of locally increasing the scope of this fixture. - loop = asyncio.get_event_loop_policy().new_event_loop() - yield loop - loop.close() - - async def get_command_path(name: str) -> Path | None: process = await asyncio.create_subprocess_exec( "which", name, stderr=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE @@ -147,7 +137,7 @@ def fixture_ports() -> Ports: return Ports() -@pytest.fixture(scope="module", name="zookeeper") +@pytest.fixture(name="zookeeper") async def fixture_zookeeper(ports: Ports) -> AsyncIterator[Service]: async with create_zookeeper(ports) as zookeeper: yield zookeeper diff --git a/tests/integration/coordinator/plugins/clickhouse/conftest.py b/tests/integration/coordinator/plugins/clickhouse/conftest.py index 80ec5112..d70ca999 100644 --- a/tests/integration/coordinator/plugins/clickhouse/conftest.py +++ b/tests/integration/coordinator/plugins/clickhouse/conftest.py @@ -79,7 +79,7 @@ class ClickHouseServiceCluster(ServiceCluster): ClickHouseCommand = Sequence[str | Path] -@pytest.fixture(scope="module", name="clickhouse_command") +@pytest.fixture(scope="function", name="clickhouse_command") async def fixture_clickhouse_command(request: FixtureRequest) -> ClickHouseCommand: clickhouse_path = request.config.getoption(CLICKHOUSE_PATH_OPTION) if clickhouse_path is None: @@ -91,7 +91,7 @@ async def fixture_clickhouse_command(request: FixtureRequest) -> ClickHouseComma return get_clickhouse_command(clickhouse_path) -@pytest.fixture(scope="module", name="clickhouse_restore_command") +@pytest.fixture(scope="function", name="clickhouse_restore_command") def fixture_clickhouse_restore_command(request: FixtureRequest, clickhouse_command: ClickHouseCommand) -> ClickHouseCommand: clickhouse_restore_path = request.config.getoption(CLICKHOUSE_RESTORE_PATH_OPTION) if clickhouse_restore_path is None: @@ -103,7 +103,7 @@ def get_clickhouse_command(clickhouse_path: Path) -> ClickHouseCommand: return [clickhouse_path] if clickhouse_path.name.endswith("-server") else [clickhouse_path, "server"] -@pytest.fixture(scope="module", name="clickhouse") +@pytest.fixture(scope="function", name="clickhouse") async def fixture_clickhouse(ports: Ports, clickhouse_command: ClickHouseCommand) -> AsyncIterator[Service]: async with create_clickhouse_service(ports, clickhouse_command) as service: yield service @@ -192,13 +192,13 @@ def bucket(self, *, bucket_name: str) -> Iterator[MinioBucket]: s3_client.delete_bucket(Bucket=bucket_name) # type: ignore[attr-defined] -@pytest.fixture(scope="module", name="minio") +@pytest.fixture(scope="function", name="minio") async def fixture_minio(ports: Ports) -> AsyncIterator[MinioService]: async with create_minio_service(ports) as service: yield service -@pytest.fixture(scope="module", name="minio_bucket") +@pytest.fixture(scope="function", name="minio_bucket") async def fixture_minio_bucket(minio: MinioService) -> AsyncIterator[MinioBucket]: with minio.bucket(bucket_name="clickhouse-bucket") as bucket: yield bucket diff --git a/tests/integration/coordinator/plugins/clickhouse/test_plugin.py b/tests/integration/coordinator/plugins/clickhouse/test_plugin.py index 53cc05f9..e3876b8b 100644 --- a/tests/integration/coordinator/plugins/clickhouse/test_plugin.py +++ b/tests/integration/coordinator/plugins/clickhouse/test_plugin.py @@ -93,7 +93,7 @@ async def restorable_cluster_manager( yield storage_path -@pytest.fixture(scope="module", name="restorable_cluster") +@pytest.fixture(scope="function", name="restorable_cluster") async def fixture_restorable_cluster( ports: Ports, clickhouse_command: ClickHouseCommand, @@ -148,7 +148,7 @@ async def restored_cluster_manager( yield clients -@pytest.fixture(scope="module", name="restored_cluster", params=[*get_restore_steps_names(), None]) +@pytest.fixture(scope="function", name="restored_cluster", params=[*get_restore_steps_names(), None]) async def fixture_restored_cluster( ports: Ports, request: SubRequest,