Skip to content

Commit 1983d4d

Browse files
cosmo0920edsiper
authored andcommitted
tests: integration: Skip an avro registry test if avro encoder is off
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 2012922 commit 1983d4d

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

tests/integration/scenarios/out_kafka/tests/test_out_kafka_001.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from utils.data_utils import read_json_file
2323
from utils.memory_check import memory_check_enabled
24+
from utils.fluent_bit_manager import FluentBitStartupError
2425
from utils.test_service import FluentBitTestService
2526

2627

@@ -456,6 +457,44 @@ def _wait_for_log_text(log_file, pattern, timeout=10):
456457
raise TimeoutError(f"Timed out waiting for log pattern {pattern!r}")
457458

458459

460+
def _read_fluent_bit_log(service):
461+
if not service.service.flb or not service.service.flb.log_file:
462+
return ""
463+
464+
try:
465+
with open(service.service.flb.log_file, "r", encoding="utf-8", errors="replace") as log:
466+
return log.read()
467+
except FileNotFoundError:
468+
return ""
469+
470+
471+
def _start_or_skip_without_avro_encoder(service):
472+
try:
473+
service.start()
474+
except FluentBitStartupError as error:
475+
log_contents = _read_fluent_bit_log(service)
476+
error_message = str(error)
477+
unsupported_markers = [
478+
"unknown configuration property 'schema_registry_url'",
479+
"unknown configuration property 'schema_registry_subject'",
480+
"unknown configuration property 'schema_registry_version'",
481+
]
482+
483+
if any(marker in log_contents or marker in error_message
484+
for marker in unsupported_markers):
485+
try:
486+
service.stop()
487+
except Exception:
488+
pass
489+
pytest.skip("Kafka Avro Schema Registry requires FLB_AVRO_ENCODER=On")
490+
491+
try:
492+
service.stop()
493+
except Exception:
494+
pass
495+
raise
496+
497+
459498
def test_out_kafka_sends_json_payload():
460499
service = Service("out_kafka_basic.yaml")
461500
service.start()
@@ -538,7 +577,7 @@ def test_out_kafka_msgpack_format_sends_msgpack_payload():
538577

539578
def test_out_kafka_avro_resolves_schema_registry_subject():
540579
service = Service("out_kafka_avro_schema_registry.yaml", use_schema_registry=True)
541-
service.start()
580+
_start_or_skip_without_avro_encoder(service)
542581

543582
messages = service.wait_for_messages(1)
544583
service.stop()

0 commit comments

Comments
 (0)