You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by ri...@apache.org on 2026/08/16 08:03:30 UTC
(iggy) 06/07: add test clean up
This is an automated email from the ASF dual-hosted git repository.
slbotbm pushed a commit to branch feat/add-python-stream-management-functions
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit 26366659734b321e87ddd7c148d7750b40c5be1f
Author: Rimuksh Kansal <ni...@gmail.com>
AuthorDate: Tue Aug 4 18:23:54 2026 +0900
add test clean up
---
bdd/python/uv.lock | 2 --
examples/python/uv.lock | 2 --
foreign/python/pyproject.toml | 2 --
foreign/python/tests/conftest.py | 37 ++++++++++++++++++++++++++++++-------
foreign/python/tests/test_stream.py | 11 +++++------
foreign/python/uv.lock | 26 --------------------------
6 files changed, 35 insertions(+), 45 deletions(-)
diff --git a/bdd/python/uv.lock b/bdd/python/uv.lock
index d050315e1..61754ccdf 100644
--- a/bdd/python/uv.lock
+++ b/bdd/python/uv.lock
@@ -25,8 +25,6 @@ requires-dist = [
{ name = "pytest-cov", marker = "extra == 'testing'", specifier = ">=4.0,<8.0" },
{ name = "pytest-timeout", marker = "extra == 'all'", specifier = ">=2.0,<3.0" },
{ name = "pytest-timeout", marker = "extra == 'testing'", specifier = ">=2.0,<3.0" },
- { name = "pytest-xdist", marker = "extra == 'all'", specifier = ">=3.0,<4.0" },
- { name = "pytest-xdist", marker = "extra == 'testing'", specifier = ">=3.0,<4.0" },
{ name = "ruff", marker = "extra == 'all'", specifier = ">=0.1.0,<1.0" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1.0,<1.0" },
{ name = "testcontainers", marker = "extra == 'all'", specifier = ">=4.15.0,<5.0" },
diff --git a/examples/python/uv.lock b/examples/python/uv.lock
index bd2f00f01..e20258ae4 100644
--- a/examples/python/uv.lock
+++ b/examples/python/uv.lock
@@ -25,8 +25,6 @@ requires-dist = [
{ name = "pytest-cov", marker = "extra == 'testing'", specifier = ">=4.0,<8.0" },
{ name = "pytest-timeout", marker = "extra == 'all'", specifier = ">=2.0,<3.0" },
{ name = "pytest-timeout", marker = "extra == 'testing'", specifier = ">=2.0,<3.0" },
- { name = "pytest-xdist", marker = "extra == 'all'", specifier = ">=3.0,<4.0" },
- { name = "pytest-xdist", marker = "extra == 'testing'", specifier = ">=3.0,<4.0" },
{ name = "ruff", marker = "extra == 'all'", specifier = ">=0.1.0,<1.0" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1.0,<1.0" },
{ name = "testcontainers", marker = "extra == 'all'", specifier = ">=4.15.0,<5.0" },
diff --git a/foreign/python/pyproject.toml b/foreign/python/pyproject.toml
index 65332fce1..6afc0d1f6 100644
--- a/foreign/python/pyproject.toml
+++ b/foreign/python/pyproject.toml
@@ -102,7 +102,6 @@ testing = [
"pytest>=9.1.1,<10.0",
"pytest-asyncio>=0.24.0,<2.0",
"pytest-cov>=4.0,<8.0",
- "pytest-xdist>=3.0,<4.0",
"pytest-timeout>=2.0,<3.0",
]
@@ -123,7 +122,6 @@ all = [
"pytest>=9.1.1,<10.0",
"pytest-asyncio>=0.24.0,<2.0",
"pytest-cov>=4.0,<8.0",
- "pytest-xdist>=3.0,<4.0",
"pytest-timeout>=2.0,<3.0",
"ruff>=0.1.0,<1.0",
"testcontainers>=4.15.0,<5.0",
diff --git a/foreign/python/tests/conftest.py b/foreign/python/tests/conftest.py
index 3ab97065f..d80c7776d 100644
--- a/foreign/python/tests/conftest.py
+++ b/foreign/python/tests/conftest.py
@@ -22,13 +22,11 @@ This module provides pytest fixtures for setting up test environments
and connecting to Iggy servers in various configurations.
"""
-# TODO(slbotbm): Create text fixture for clean up after
-# delete_stream() has been implemented.
-
import asyncio
import os
import secrets
import string
+from collections.abc import AsyncGenerator
from pathlib import Path
import pytest
@@ -37,9 +35,32 @@ from apache_iggy import IggyClient
from .utils import get_server_config, wait_for_ping, wait_for_server
+_ROOT_USER_ID = 0
+
+
+async def _delete_test_resources(client: IggyClient) -> None:
+ streams = await client.get_streams()
+
+ for stream in streams:
+ topics = await client.get_topics(stream.id)
+ for topic in topics:
+ consumer_groups = await client.get_consumer_groups(stream.id, topic.id)
+ for consumer_group in consumer_groups:
+ await client.delete_consumer_group(
+ stream.id, topic.id, consumer_group.id
+ )
+
+ for stream in streams:
+ await client.delete_stream(stream.id)
-@pytest.fixture(scope="session")
-async def iggy_client() -> IggyClient:
+ users = await client.get_users()
+ for user in users:
+ if user.id != _ROOT_USER_ID:
+ await client.delete_user(user.id)
+
+
+@pytest.fixture(scope="session", autouse=True)
+async def iggy_client() -> AsyncGenerator[IggyClient, None]:
"""
Create and configure an Iggy client for testing.
@@ -50,7 +71,7 @@ async def iggy_client() -> IggyClient:
4. Authenticates with default credentials
5. Verifies connectivity with ping
- Returns:
+ Yields:
IggyClient: Authenticated client ready for testing
"""
host, port = get_server_config()
@@ -68,7 +89,9 @@ async def iggy_client() -> IggyClient:
# Authenticate
await client.login_user("iggy", "iggy")
- return client
+ yield client
+
+ await _delete_test_resources(client)
@pytest.fixture
diff --git a/foreign/python/tests/test_stream.py b/foreign/python/tests/test_stream.py
index 2db391951..24e55e66c 100644
--- a/foreign/python/tests/test_stream.py
+++ b/foreign/python/tests/test_stream.py
@@ -213,11 +213,10 @@ class TestGetStreams:
self, iggy_client: IggyClient, unique_name
):
"""Test get_streams returns every stream created during the test."""
- # Reverse-alphabetical names so that id-ascending (creation) order
- # and name order disagree, proving the list isn't accidentally
- # name-sorted. The client fixture is session-scoped, so other tests
- # may have created streams; assert on the ones created here instead
- # of the full server view.
+ # Stream IDs can be reused after deletion, so creation order does not
+ # imply numeric ID order. The client fixture is session-scoped, so
+ # other tests may have created streams; assert on the ones created
+ # here instead of the full server view.
created = [unique_name(f"z{index}") for index in range(3, 0, -1)]
for name in created:
await iggy_client.create_stream(name)
@@ -226,7 +225,7 @@ class TestGetStreams:
created_names = set(created)
mine = [stream for stream in streams if stream.name in created_names]
- assert [stream.name for stream in mine] == created
+ assert {stream.name for stream in mine} == created_names
assert [stream.id for stream in mine] == sorted(stream.id for stream in mine)
assert all(stream.created_at > 0 for stream in mine)
assert all(stream.size_bytes == 0 for stream in mine)
diff --git a/foreign/python/uv.lock b/foreign/python/uv.lock
index a60f46845..289e40ef1 100644
--- a/foreign/python/uv.lock
+++ b/foreign/python/uv.lock
@@ -23,7 +23,6 @@ all = [
{ name = "pytest-asyncio" },
{ name = "pytest-cov" },
{ name = "pytest-timeout" },
- { name = "pytest-xdist" },
{ name = "ruff" },
{ name = "testcontainers" },
]
@@ -37,7 +36,6 @@ testing = [
{ name = "pytest-asyncio" },
{ name = "pytest-cov" },
{ name = "pytest-timeout" },
- { name = "pytest-xdist" },
]
testing-docker = [
{ name = "testcontainers" },
@@ -57,8 +55,6 @@ requires-dist = [
{ name = "pytest-cov", marker = "extra == 'testing'", specifier = ">=4.0,<8.0" },
{ name = "pytest-timeout", marker = "extra == 'all'", specifier = ">=2.0,<3.0" },
{ name = "pytest-timeout", marker = "extra == 'testing'", specifier = ">=2.0,<3.0" },
- { name = "pytest-xdist", marker = "extra == 'all'", specifier = ">=3.0,<4.0" },
- { name = "pytest-xdist", marker = "extra == 'testing'", specifier = ">=3.0,<4.0" },
{ name = "ruff", marker = "extra == 'all'", specifier = ">=0.1.0,<1.0" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1.0,<1.0" },
{ name = "testcontainers", marker = "extra == 'all'", specifier = ">=4.15.0,<5.0" },
@@ -342,15 +338,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" },
]
-[[package]]
-name = "execnet"
-version = "2.1.2"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/bf/89/780e11f9588d9e7128a3f87788354c7946a9cbb1401ad38a48c4db9a4f07/execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd", size = 166622, upload-time = "2025-11-12T09:56:37.75Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec", size = 40708, upload-time = "2025-11-12T09:56:36.333Z" },
-]
-
[[package]]
name = "idna"
version = "3.15"
@@ -497,19 +484,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/fa/b6/3127540ecdf1464a00e5a01ee60a1b09175f6913f0644ac748494d9c4b21/pytest_timeout-2.4.0-py3-none-any.whl", hash = "sha256:c42667e5cdadb151aeb5b26d114aff6bdf5a907f176a007a30b940d3d865b5c2", size = 14382, upload-time = "2025-05-05T19:44:33.502Z" },
]
-[[package]]
-name = "pytest-xdist"
-version = "3.8.0"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "execnet" },
- { name = "pytest" },
-]
-sdist = { url = "https://files.pythonhosted.org/packages/78/b4/439b179d1ff526791eb921115fca8e44e596a13efeda518b9d845a619450/pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1", size = 88069, upload-time = "2025-07-01T13:30:59.346Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/ca/31/d4e37e9e550c2b92a9cbc2e4d0b7420a27224968580b5a447f420847c975/pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88", size = 46396, upload-time = "2025-07-01T13:30:56.632Z" },
-]
-
[[package]]
name = "python-dotenv"
version = "1.2.2"