Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Format : [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/). Les numéros

## [Non publié]

## [0.10.1] - 2026-11-03

### Ajouté
- **Tests : parité complète indexer↔sortie, 100 % de couverture (#159,
PR #164)** — la migration #160 laissait quatre lignes de `src/indexer.py`
(avertissement multi-nœuds, options `auth`, couture `_client()`, action
invalide sans DLQ) et la branche multievents de `handle_doc` non couvertes ;
`src/` atteint 100 % de couverture lignes et branches (277 tests),
l'exigence de l'issue #159.

## [0.10.0] - 2026-11-03

### Ajouté
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "rsyslogstach"
version = "0.10.0"
version = "0.10.1"
description = "Pont rsyslog -> omprog (asyncio) -> OpenSearch, compatible schéma/filtres Logstash"
license = "GPL-3.0-or-later"
requires-python = ">=3.11"
Expand Down
92 changes: 92 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import httpx
import pytest
from loguru import logger

from indexer import OpenSearchIndexer, SendOutcome
from omprog import ACK_OK, ACK_RETRY, build_bridge, build_parser, health_check_loop
Expand Down Expand Up @@ -413,6 +414,27 @@ async def scenario() -> str:
assert index == "logs-test-app1"
assert body["src"] == "app1"

def test_clone_deux_evenements_indexes(self, tmp_path: Path) -> None:
"""#141 : un `clone` produit l'original ET la copie, tous deux indexés.

Le second événement réussit alors que le premier aussi : le résultat
conservé reste la première réussite (branche de garde de `handle_doc`).
"""
conf = """
filter {
clone { clones => ["copie"] }
}
"""
bridge, fake = make_bridge(tmp_path, pipeline_conf=conf)

async def scenario() -> str:
reply = await bridge.handle_line(json.dumps({"message": "x"}))
await bridge.close()
return reply

assert asyncio.run(scenario()) == ACK_OK
assert len(fake.calls) == 2


class TestDebitMinimal:
def test_200_messages_sous_la_seconde(self, tmp_path: Path) -> None:
Expand Down Expand Up @@ -463,6 +485,76 @@ async def scenario() -> SendOutcome:
assert asyncio.run(scenario()) is SendOutcome.RETRYABLE


class TestOptionsIndexer:
"""Options du connecteur traduites en options de sortie (#160), parité vérifiée."""

@staticmethod
def _indexer(auth: tuple[str, str] | None = None, **kwargs: Any) -> OpenSearchIndexer:
return OpenSearchIndexer(
hosts=[{"host": "127.0.0.1", "port": 9200}],
auth=auth,
index_pattern="switch-logs-%Y.%m.%d",
use_ssl=False,
verify_certs=False,
**kwargs,
)

def test_plusieurs_noeuds_avertit(self) -> None:
"""La sortie n'utilise que le premier nœud : l'avertissement part au démarrage."""
messages: list[str] = []
sink = logger.add(lambda m: messages.append(m.record["message"]), level="WARNING")
try:
indexer = OpenSearchIndexer(
hosts=[{"host": "127.0.0.1", "port": 9200}, {"host": "127.0.0.1", "port": 9201}],
auth=None,
index_pattern="switch-logs-%Y.%m.%d",
use_ssl=False,
verify_certs=False,
)
asyncio.run(indexer.close())
finally:
logger.remove(sink)
assert any("seul le premier est utilisé" in message for message in messages)

def test_auth_transmis_a_la_sortie(self) -> None:
"""`auth` du connecteur devient `user`/`password` de la sortie."""

async def scenario() -> dict[str, Any]:
indexer = self._indexer(auth=("u", "p"))
try:
return dict(indexer.sortie.options)
finally:
await indexer.close()

options = asyncio.run(scenario())
assert (options["user"], options["password"]) == ("u", "p")

def test_client_partage_avec_la_sortie(self) -> None:
"""La couture `_client()` d'omprog renvoie LE client httpx de la sortie."""

async def scenario() -> bool:
indexer = self._indexer()
try:
client = await indexer._client()
return client is indexer.sortie._client_http()
finally:
await indexer.close()

assert asyncio.run(scenario())

def test_action_invalide_sans_dlq_renvoie_retryable(self) -> None:
"""Comportement historique sans DLQ : l'échec permanent reste RETRYABLE."""

async def scenario() -> SendOutcome:
indexer = self._indexer()
try:
return await indexer.send({"v": 1}, action="upsert")
finally:
await indexer.close()

assert asyncio.run(scenario()) is SendOutcome.RETRYABLE


class TestHealthCheckPeriodique:
def test_health_renvoie_la_version(self, tmp_path: Path) -> None:
bridge, fake = make_bridge(tmp_path)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading