You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+22-7Lines changed: 22 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
5
5
## Commands
6
6
7
7
```bash
8
-
just install # lock + sync all deps (run after pulling or changing pyproject.toml)
9
-
just lint # eof-fixer, ruff format, ruff check --fix, ty check
10
-
just lint-ci # same but no auto-fix (used in CI)
11
-
just test# pytest with coverage
12
-
just test-branch # pytest with branch coverage
13
-
just publish # bump version to $GITHUB_REF_NAME, build, publish to PyPI
8
+
just install # lock + sync all deps (run after pulling or changing pyproject.toml)
9
+
just lint # eof-fixer, ruff format, ruff check --fix, ty check
10
+
just lint-ci # same but no auto-fix (used in CI)
11
+
just build # build the application Docker image
12
+
just test# run all tests in Docker (starts Redpanda, runs pytest, tears down)
13
+
just test-branch # same with branch coverage
14
+
just down # tear down all containers
15
+
just publish # bump version to $GITHUB_REF_NAME, build, publish to PyPI
14
16
```
15
17
16
18
Run a single test file or test by name:
@@ -43,6 +45,19 @@ Runs as a background asyncio task (spawned via `spawn()`). Collects `KafkaCommit
43
45
44
46
## Key patterns
45
47
46
-
-**Singleton reset in tests**: `KafkaConcurrentHandler._initialized = False` and `._instance = None` must be reset between tests. Each test file does this directly in an `autouse``reset_singleton` fixture — not via `stop_concurrent_processing`.
48
+
-**Singleton reset in tests**: `KafkaConcurrentHandler._initialized = False` and `._instance = None` must be reset between tests. The shared `autouse``reset_singleton` fixture lives in `tests/conftest.py` — do not re-define it in individual test files.
47
49
-**Type suppression**: use `# ty: ignore[rule-name]` (not `# type: ignore`) for ty type checker suppressions.
48
50
-**No `from __future__ import annotations`**: annotations are evaluated eagerly; `typing.Self`/`typing.Never` are used directly (requires Python ≥ 3.11).
51
+
52
+
## Integration tests
53
+
54
+
`tests/test_integration.py` runs against a real Redpanda container (Kafka-compatible, lightweight) via `testcontainers[kafka]`. The container is session-scoped — one instance for the whole test run.
55
+
56
+
**Running integration tests** requires Docker — they run automatically as part of `just test`.
57
+
58
+
**Key findings from building these tests:**
59
+
60
+
-`async with KafkaBroker():` only calls `connect()`, which sets up the producer. It does **not** start subscribers. You must also call `await broker.start()` explicitly to launch the consumer poll tasks.
61
+
- Always use `auto_offset_reset="earliest"` on test subscribers. The default `"latest"` causes the consumer to miss messages published before it gets its partition assignment.
62
+
- Pre-create topics with `AIOKafkaAdminClient` before starting the broker. Auto-creation on first publish triggers a `NotLeaderForPartitionError` retry loop that can outlast short sleeps.
63
+
- After `await broker.start()`, sleep ~1.5 s before publishing to let the consumer join the group and receive partition assignments.
0 commit comments