|
21 | 21 | ) |
22 | 22 | from utils.data_utils import read_json_file |
23 | 23 | from utils.memory_check import memory_check_enabled |
| 24 | +from utils.fluent_bit_manager import FluentBitStartupError |
24 | 25 | from utils.test_service import FluentBitTestService |
25 | 26 |
|
26 | 27 |
|
@@ -456,6 +457,44 @@ def _wait_for_log_text(log_file, pattern, timeout=10): |
456 | 457 | raise TimeoutError(f"Timed out waiting for log pattern {pattern!r}") |
457 | 458 |
|
458 | 459 |
|
| 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 | + |
459 | 498 | def test_out_kafka_sends_json_payload(): |
460 | 499 | service = Service("out_kafka_basic.yaml") |
461 | 500 | service.start() |
@@ -538,7 +577,7 @@ def test_out_kafka_msgpack_format_sends_msgpack_payload(): |
538 | 577 |
|
539 | 578 | def test_out_kafka_avro_resolves_schema_registry_subject(): |
540 | 579 | service = Service("out_kafka_avro_schema_registry.yaml", use_schema_registry=True) |
541 | | - service.start() |
| 580 | + _start_or_skip_without_avro_encoder(service) |
542 | 581 |
|
543 | 582 | messages = service.wait_for_messages(1) |
544 | 583 | service.stop() |
|
0 commit comments