@platformatic/rdkafka 4.0.0 → 4.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/bench/seed.sh +0 -0
- package/binding.gyp +3 -3
- package/ci/prepublish.js +4 -3
- package/ci/update-version.js +123 -0
- package/config.d.ts +126 -10
- package/configure +0 -0
- package/deps/librdkafka/.semaphore/run-all-tests.yml +77 -0
- package/deps/librdkafka/.semaphore/semaphore-integration.yml +250 -0
- package/deps/librdkafka/.semaphore/semaphore.yml +67 -44
- package/deps/librdkafka/.semaphore/verify-linux-packages.yml +41 -0
- package/deps/librdkafka/CHANGELOG.md +471 -1
- package/deps/librdkafka/CONFIGURATION.md +29 -9
- package/deps/librdkafka/INTRODUCTION.md +909 -601
- package/deps/librdkafka/Makefile +2 -1
- package/deps/librdkafka/configure +0 -0
- package/deps/librdkafka/debian/rules +0 -0
- package/deps/librdkafka/dev-conf.sh +0 -0
- package/deps/librdkafka/examples/consumer.c +18 -8
- package/deps/librdkafka/examples/describe_consumer_groups.c +25 -6
- package/deps/librdkafka/examples/incremental_alter_configs.c +4 -5
- package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +26 -42
- package/deps/librdkafka/examples/openssl_engine_example.cpp +3 -4
- package/deps/librdkafka/examples/producer.cpp +2 -2
- package/deps/librdkafka/examples/user_scram.c +4 -5
- package/deps/librdkafka/examples/win_ssl_cert_store.cpp +4 -3
- package/deps/librdkafka/lds-gen.py +0 -0
- package/deps/librdkafka/mklove/Makefile.base +0 -0
- package/deps/librdkafka/packaging/RELEASE.md +8 -0
- package/deps/librdkafka/packaging/alpine/build-alpine.sh +0 -0
- package/deps/librdkafka/packaging/cp/README.md +4 -1
- package/deps/librdkafka/packaging/cp/check_features.c +12 -4
- package/deps/librdkafka/packaging/cp/verify-deb.sh +6 -6
- package/deps/librdkafka/packaging/cp/verify-packages.sh +52 -31
- package/deps/librdkafka/packaging/cp/verify-rpm.sh +6 -13
- package/deps/librdkafka/packaging/debian/docs +5 -0
- package/deps/librdkafka/packaging/debian/rules +0 -0
- package/deps/librdkafka/packaging/get_version.py +0 -0
- package/deps/librdkafka/packaging/homebrew/brew-update-pr.sh +0 -0
- package/deps/librdkafka/packaging/mingw-w64/{travis-before-install.sh → export-variables.sh} +0 -7
- package/deps/librdkafka/packaging/mingw-w64/semaphoreci-build.sh +1 -1
- package/deps/librdkafka/packaging/nuget/artifact.py +0 -0
- package/deps/librdkafka/packaging/nuget/cleanup-s3.py +0 -0
- package/deps/librdkafka/packaging/nuget/nuget.sh +0 -0
- package/deps/librdkafka/packaging/nuget/packaging.py +0 -0
- package/deps/librdkafka/packaging/nuget/push-to-nuget.sh +0 -0
- package/deps/librdkafka/packaging/nuget/release.py +0 -0
- package/deps/librdkafka/packaging/nuget/requirements.txt +3 -3
- package/deps/librdkafka/packaging/rpm/mock-on-docker.sh +0 -0
- package/deps/librdkafka/packaging/rpm/tests/run-test.sh +0 -0
- package/deps/librdkafka/packaging/rpm/tests/test-on-docker.sh +0 -0
- package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +3 -1
- package/deps/librdkafka/packaging/tools/build-deb-package.sh +0 -0
- package/deps/librdkafka/packaging/tools/build-debian.sh +0 -0
- package/deps/librdkafka/packaging/tools/build-manylinux.sh +0 -0
- package/deps/librdkafka/packaging/tools/build-release-artifacts.sh +0 -0
- package/deps/librdkafka/packaging/tools/distro-build.sh +0 -0
- package/deps/librdkafka/packaging/tools/gh-release-checksums.py +0 -0
- package/deps/librdkafka/packaging/tools/rdutcoverage.sh +0 -0
- package/deps/librdkafka/packaging/tools/run-in-docker.sh +28 -0
- package/deps/librdkafka/packaging/tools/run-integration-tests.sh +31 -0
- package/deps/librdkafka/packaging/tools/run-style-check.sh +4 -0
- package/deps/librdkafka/packaging/tools/style-format.sh +6 -5
- package/deps/librdkafka/packaging/tools/update_rpcs_max_versions.py +100 -0
- package/deps/librdkafka/service.yml +154 -0
- package/deps/librdkafka/src/generate_proto.sh +0 -0
- package/deps/librdkafka/src/rd.h +145 -2
- package/deps/librdkafka/src/rdaddr.h +6 -7
- package/deps/librdkafka/src/rdatomic.h +15 -11
- package/deps/librdkafka/src/rdavg.h +3 -2
- package/deps/librdkafka/src/rdbase64.c +33 -2
- package/deps/librdkafka/src/rdbase64.h +2 -0
- package/deps/librdkafka/src/rdendian.h +10 -9
- package/deps/librdkafka/src/rdhttp.c +418 -100
- package/deps/librdkafka/src/rdhttp.h +23 -5
- package/deps/librdkafka/src/rdkafka.c +299 -145
- package/deps/librdkafka/src/rdkafka.h +89 -6
- package/deps/librdkafka/src/rdkafka_admin.c +482 -105
- package/deps/librdkafka/src/rdkafka_admin.h +42 -0
- package/deps/librdkafka/src/rdkafka_broker.c +463 -312
- package/deps/librdkafka/src/rdkafka_broker.h +68 -10
- package/deps/librdkafka/src/rdkafka_buf.c +8 -5
- package/deps/librdkafka/src/rdkafka_buf.h +4 -3
- package/deps/librdkafka/src/rdkafka_cert.c +25 -1
- package/deps/librdkafka/src/rdkafka_cert.h +4 -3
- package/deps/librdkafka/src/rdkafka_cgrp.c +468 -143
- package/deps/librdkafka/src/rdkafka_cgrp.h +36 -2
- package/deps/librdkafka/src/rdkafka_conf.c +526 -102
- package/deps/librdkafka/src/rdkafka_conf.h +68 -4
- package/deps/librdkafka/src/rdkafka_feature.c +472 -35
- package/deps/librdkafka/src/rdkafka_feature.h +2 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +22 -2
- package/deps/librdkafka/src/rdkafka_fetcher.h +2 -2
- package/deps/librdkafka/src/rdkafka_int.h +84 -46
- package/deps/librdkafka/src/rdkafka_metadata.c +221 -136
- package/deps/librdkafka/src/rdkafka_metadata.h +15 -11
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +279 -73
- package/deps/librdkafka/src/rdkafka_mock.c +795 -19
- package/deps/librdkafka/src/rdkafka_mock.h +119 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1298 -132
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +345 -49
- package/deps/librdkafka/src/rdkafka_mock_int.h +180 -61
- package/deps/librdkafka/src/rdkafka_msg.c +35 -19
- package/deps/librdkafka/src/rdkafka_msg.h +3 -3
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +14 -10
- package/deps/librdkafka/src/rdkafka_offset.c +33 -5
- package/deps/librdkafka/src/rdkafka_op.c +1 -1
- package/deps/librdkafka/src/rdkafka_op.h +45 -21
- package/deps/librdkafka/src/rdkafka_partition.c +118 -23
- package/deps/librdkafka/src/rdkafka_partition.h +16 -7
- package/deps/librdkafka/src/rdkafka_proto.h +4 -1
- package/deps/librdkafka/src/rdkafka_protocol.h +1 -0
- package/deps/librdkafka/src/rdkafka_queue.c +125 -48
- package/deps/librdkafka/src/rdkafka_queue.h +19 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1 -1
- package/deps/librdkafka/src/rdkafka_request.c +336 -64
- package/deps/librdkafka/src/rdkafka_request.h +24 -1
- package/deps/librdkafka/src/rdkafka_sasl.c +5 -3
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +14 -10
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1166 -89
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +13 -3
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +3 -3
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +4 -3
- package/deps/librdkafka/src/rdkafka_ssl.c +306 -81
- package/deps/librdkafka/src/rdkafka_ssl.h +22 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +80 -23
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +5 -1
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +20 -20
- package/deps/librdkafka/src/rdkafka_topic.c +220 -137
- package/deps/librdkafka/src/rdkafka_topic.h +14 -8
- package/deps/librdkafka/src/rdkafka_transport.c +59 -47
- package/deps/librdkafka/src/rdkafka_transport.h +5 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +6 -1
- package/deps/librdkafka/src/rdmap.c +6 -1
- package/deps/librdkafka/src/rdrand.c +11 -1
- package/deps/librdkafka/src/rdtime.h +48 -17
- package/deps/librdkafka/src/rdunittest.c +42 -25
- package/deps/librdkafka/src/rdunittest.h +2 -0
- package/deps/librdkafka/src/rdwin32.h +1 -1
- package/deps/librdkafka/src/regexp.c +47 -42
- package/deps/librdkafka/src/tinycthread_extra.c +45 -21
- package/deps/librdkafka/src/tinycthread_extra.h +7 -3
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +28 -2
- package/deps/librdkafka/tests/0001-multiobj.c +4 -0
- package/deps/librdkafka/tests/0004-conf.c +103 -36
- package/deps/librdkafka/tests/0009-mock_cluster.c +1 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +2 -1
- package/deps/librdkafka/tests/0016-client_swname.c +18 -3
- package/deps/librdkafka/tests/0017-compression.c +6 -8
- package/deps/librdkafka/tests/0018-cgrp_term.c +8 -3
- package/deps/librdkafka/tests/0021-rkt_destroy.c +1 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +4 -1
- package/deps/librdkafka/tests/0026-consume_pause.c +12 -14
- package/deps/librdkafka/tests/0028-long_topicnames.c +1 -1
- package/deps/librdkafka/tests/0029-assign_offset.c +6 -8
- package/deps/librdkafka/tests/0030-offset_commit.c +2 -2
- package/deps/librdkafka/tests/0033-regex_subscribe.c +33 -17
- package/deps/librdkafka/tests/0034-offset_reset.c +25 -4
- package/deps/librdkafka/tests/0036-partial_fetch.c +1 -0
- package/deps/librdkafka/tests/0038-performance.c +1 -0
- package/deps/librdkafka/tests/0040-io_event.c +11 -5
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +1 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +3 -2
- package/deps/librdkafka/tests/0045-subscribe_update.c +284 -20
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +1 -0
- package/deps/librdkafka/tests/0048-partitioner.c +1 -1
- package/deps/librdkafka/tests/0050-subscribe_adds.c +1 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +1 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +22 -4
- package/deps/librdkafka/tests/0053-stats_cb.cpp +12 -20
- package/deps/librdkafka/tests/0055-producer_latency.c +176 -3
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +6 -2
- package/deps/librdkafka/tests/0058-log.cpp +3 -3
- package/deps/librdkafka/tests/0059-bsearch.cpp +8 -4
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +25 -5
- package/deps/librdkafka/tests/0067-empty_topic.cpp +3 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +21 -23
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +3 -7
- package/deps/librdkafka/tests/0075-retry.c +38 -1
- package/deps/librdkafka/tests/0076-produce_retry.c +2 -0
- package/deps/librdkafka/tests/0077-compaction.c +8 -2
- package/deps/librdkafka/tests/0080-admin_ut.c +34 -4
- package/deps/librdkafka/tests/0081-admin.c +455 -155
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +4 -0
- package/deps/librdkafka/tests/0083-cb_event.c +8 -3
- package/deps/librdkafka/tests/0084-destroy_flags.c +14 -18
- package/deps/librdkafka/tests/0085-headers.cpp +4 -0
- package/deps/librdkafka/tests/0086-purge.c +40 -7
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +1 -1
- package/deps/librdkafka/tests/0089-max_poll_interval.c +12 -7
- package/deps/librdkafka/tests/0090-idempotence.c +1 -2
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +5 -7
- package/deps/librdkafka/tests/0092-mixed_msgver.c +6 -0
- package/deps/librdkafka/tests/0093-holb.c +8 -5
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +1 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +262 -70
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +16 -16
- package/deps/librdkafka/tests/0099-commit_metadata.c +1 -1
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +1 -1
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +317 -16
- package/deps/librdkafka/tests/0103-transactions.c +7 -7
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +1 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +18 -11
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +35 -14
- package/deps/librdkafka/tests/0107-topic_recreate.c +2 -2
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +86 -26
- package/deps/librdkafka/tests/0110-batch_size.cpp +1 -2
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +3 -14
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +248 -104
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +3 -3
- package/deps/librdkafka/tests/0115-producer_auth.cpp +4 -1
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +7 -5
- package/deps/librdkafka/tests/0117-mock_errors.c +15 -5
- package/deps/librdkafka/tests/0118-commit_rebalance.c +41 -8
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +20 -1
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +8 -3
- package/deps/librdkafka/tests/0125-immediate_flush.c +1 -1
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +323 -8
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +1 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +12 -4
- package/deps/librdkafka/tests/0133-ssl_keys.c +28 -6
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +24 -14
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +510 -2
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +1 -1
- package/deps/librdkafka/tests/0142-reauthentication.c +37 -17
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +39 -40
- package/deps/librdkafka/tests/0146-metadata_mock.c +76 -15
- package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +952 -0
- package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +563 -0
- package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +9 -6
- package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
- package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
- package/deps/librdkafka/tests/0153-memberid.c +128 -0
- package/deps/librdkafka/tests/CMakeLists.txt +6 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +34 -9
- package/deps/librdkafka/tests/autotest.sh +0 -0
- package/deps/librdkafka/tests/broker_version_tests.py +0 -0
- package/deps/librdkafka/tests/buildbox.sh +0 -0
- package/deps/librdkafka/tests/cleanup-checker-tests.sh +0 -0
- package/deps/librdkafka/tests/cluster_testing.py +0 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +0 -0
- package/deps/librdkafka/tests/fixtures/oauthbearer/jwt_assertion_template.json +10 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.intermediate.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +42 -101
- package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +41 -29
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +112 -37
- package/deps/librdkafka/tests/gen-ssl-certs.sh +0 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +0 -0
- package/deps/librdkafka/tests/java/Makefile +2 -1
- package/deps/librdkafka/tests/java/run-class.sh +0 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +0 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +0 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +0 -0
- package/deps/librdkafka/tests/performance_plot.py +0 -0
- package/deps/librdkafka/tests/requirements.txt +1 -1
- package/deps/librdkafka/tests/run-all-tests.sh +79 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +0 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +0 -0
- package/deps/librdkafka/tests/run-test-batches.py +157 -0
- package/deps/librdkafka/tests/run-test.sh +0 -0
- package/deps/librdkafka/tests/sasl_test.py +0 -0
- package/deps/librdkafka/tests/test.c +478 -18
- package/deps/librdkafka/tests/test.h +62 -13
- package/deps/librdkafka/tests/testcpp.cpp +6 -1
- package/deps/librdkafka/tests/testcpp.h +30 -2
- package/deps/librdkafka/tests/testshared.h +16 -2
- package/deps/librdkafka/tests/tools/stats/graph.py +0 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +1 -1
- package/deps/librdkafka/tests/trivup/trivup-0.14.0.tar.gz +0 -0
- package/deps/librdkafka/tests/until-fail.sh +0 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +1 -1
- package/deps/librdkafka/vcpkg.json +1 -1
- package/deps/librdkafka/win32/setup-msys2.ps1 +24 -8
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +28 -6
- package/deps/librdkafka/win32/tests/tests.vcxproj +6 -0
- package/deps/librdkafka/win32/wingetopt.h +5 -4
- package/errors.d.ts +27 -1
- package/lib/error.js +29 -3
- package/make_docs.sh +0 -0
- package/package.json +12 -13
- package/run_docker.sh +0 -0
- package/src/callbacks.cc +6 -9
- package/src/callbacks.h +1 -5
- package/test/kafka-consumer-worker.js +10 -7
- package/test/kafka-consumer.spec.js +32 -21
- package/deps/librdkafka/.semaphore/project.yml +0 -43
- package/deps/librdkafka/.semaphore/project_public.yml +0 -20
- package/deps/librdkafka/win32/install-openssl.ps1 +0 -33
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* librdkafka - Apache Kafka C library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025, Confluent Inc.
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
|
9
|
+
*
|
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer.
|
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
* and/or other materials provided with the distribution.
|
|
15
|
+
*
|
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
17
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
19
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
20
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
#include "test.h"
|
|
30
|
+
|
|
31
|
+
#include "../src/rdkafka_proto.h"
|
|
32
|
+
|
|
33
|
+
#include <stdarg.h>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
static mtx_t log_lock;
|
|
37
|
+
static cnd_t log_cnd;
|
|
38
|
+
static rd_bool_t revocation_done = rd_false;
|
|
39
|
+
static int got_stale_member_epoch_error = 0;
|
|
40
|
+
static rd_bool_t trigger_consumer_close = rd_false;
|
|
41
|
+
static int ack_target_assignment_count = 0;
|
|
42
|
+
|
|
43
|
+
static void
|
|
44
|
+
log_cb(const rd_kafka_t *rk, int level, const char *fac, const char *buf) {
|
|
45
|
+
if (strstr(buf,
|
|
46
|
+
"assignment operations done in join-state "
|
|
47
|
+
"wait-incr-unassign-to-complete")) {
|
|
48
|
+
mtx_lock(&log_lock);
|
|
49
|
+
revocation_done = rd_true;
|
|
50
|
+
cnd_signal(&log_cnd);
|
|
51
|
+
mtx_unlock(&log_lock);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief A stale member error during an OffsetFetch should cause
|
|
57
|
+
* to retry the operation just after next ConsumerGroupHeartbeat
|
|
58
|
+
* response.
|
|
59
|
+
* The offset fetch eventually succeeds and the consumer can
|
|
60
|
+
* start from the committed offset.
|
|
61
|
+
*/
|
|
62
|
+
void do_test_OffsetFetch_stale_member_epoch_error(
|
|
63
|
+
rd_kafka_mock_cluster_t *mcluster,
|
|
64
|
+
const char *bootstraps) {
|
|
65
|
+
const char *topic = test_mk_topic_name(__FUNCTION__, 1);
|
|
66
|
+
rd_kafka_t *producer, *first_consumer, *second_consumer;
|
|
67
|
+
rd_kafka_conf_t *conf, *producer_conf;
|
|
68
|
+
uint64_t testid = test_id_generate();
|
|
69
|
+
const int msgcnt = 5;
|
|
70
|
+
test_msgver_t mv;
|
|
71
|
+
|
|
72
|
+
SUB_TEST_QUICK();
|
|
73
|
+
|
|
74
|
+
test_conf_init(&conf, NULL, 30);
|
|
75
|
+
test_conf_set(conf, "bootstrap.servers", bootstraps);
|
|
76
|
+
|
|
77
|
+
/* Producer */
|
|
78
|
+
producer_conf = rd_kafka_conf_dup(conf);
|
|
79
|
+
rd_kafka_conf_set_dr_msg_cb(producer_conf, test_dr_msg_cb);
|
|
80
|
+
producer = test_create_handle(RD_KAFKA_PRODUCER, producer_conf);
|
|
81
|
+
rd_kafka_mock_topic_create(mcluster, topic, 1, 2);
|
|
82
|
+
test_produce_msgs2(producer, topic, testid, 0, 0, msgcnt, NULL, 0);
|
|
83
|
+
rd_kafka_flush(producer, -1);
|
|
84
|
+
|
|
85
|
+
/* Consumer */
|
|
86
|
+
test_conf_set(conf, "auto.offset.reset", "earliest");
|
|
87
|
+
test_conf_set(conf, "group.protocol", "consumer");
|
|
88
|
+
first_consumer =
|
|
89
|
+
test_create_consumer(topic, NULL, rd_kafka_conf_dup(conf), NULL);
|
|
90
|
+
test_consumer_subscribe(first_consumer, topic);
|
|
91
|
+
test_consumer_poll("before consume error", first_consumer, testid, -1,
|
|
92
|
+
0, msgcnt, NULL);
|
|
93
|
+
test_consumer_close(first_consumer);
|
|
94
|
+
|
|
95
|
+
/* Produce again */
|
|
96
|
+
test_produce_msgs2(producer, topic, testid, 0, msgcnt, msgcnt, NULL, 0);
|
|
97
|
+
rd_kafka_flush(producer, -1);
|
|
98
|
+
|
|
99
|
+
/* Set OffsetFetch errors */
|
|
100
|
+
rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_OffsetFetch, 5,
|
|
101
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
102
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
103
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
104
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
105
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH);
|
|
106
|
+
|
|
107
|
+
/* Consume again*/
|
|
108
|
+
test_msgver_init(&mv, testid);
|
|
109
|
+
second_consumer = test_create_consumer(topic, NULL, conf, NULL);
|
|
110
|
+
test_consumer_subscribe(second_consumer, topic);
|
|
111
|
+
test_consumer_poll("receive second batch", second_consumer, testid, -1,
|
|
112
|
+
msgcnt, msgcnt, &mv);
|
|
113
|
+
test_msgver_verify("verify second batch", &mv, TEST_MSGVER_ALL, msgcnt,
|
|
114
|
+
msgcnt);
|
|
115
|
+
test_msgver_clear(&mv);
|
|
116
|
+
test_consumer_close(second_consumer);
|
|
117
|
+
|
|
118
|
+
/* Destroy */
|
|
119
|
+
rd_kafka_destroy(first_consumer);
|
|
120
|
+
rd_kafka_destroy(second_consumer);
|
|
121
|
+
rd_kafka_destroy(producer);
|
|
122
|
+
|
|
123
|
+
SUB_TEST_PASS();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
typedef enum do_test_OffsetCommit_manual_error_variation_s {
|
|
127
|
+
/** commit stored offsets */
|
|
128
|
+
TEST_MANUAL_COMMIT_ERROR_VARIATION_STORE_OFFSET_AUTOMATICALLY = 0,
|
|
129
|
+
/** commit passed offsets */
|
|
130
|
+
TEST_MANUAL_COMMIT_ERROR_VARIATION_STORE_OFFSET_MANUALLY = 1,
|
|
131
|
+
TEST_MANUAL_COMMIT_ERROR_VARIATION__CNT,
|
|
132
|
+
} do_test_OffsetCommit_manual_error_variation_t;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @brief Doing a manual commits that returns error \p expected_err
|
|
136
|
+
* should return the error to the caller, even if the error
|
|
137
|
+
* is a partition level error.
|
|
138
|
+
* These errors aren't retried.
|
|
139
|
+
*/
|
|
140
|
+
void do_test_OffsetCommit_manual_error(
|
|
141
|
+
rd_kafka_mock_cluster_t *mcluster,
|
|
142
|
+
const char *bootstraps,
|
|
143
|
+
rd_kafka_resp_err_t expected_err,
|
|
144
|
+
do_test_OffsetCommit_manual_error_variation_t variation) {
|
|
145
|
+
rd_kafka_t *consumer;
|
|
146
|
+
test_msgver_t mv;
|
|
147
|
+
rd_kafka_conf_t *conf;
|
|
148
|
+
const char *topic = test_mk_topic_name(__FUNCTION__, 1);
|
|
149
|
+
uint64_t testid = test_id_generate();
|
|
150
|
+
const int msgcnt = 5;
|
|
151
|
+
rd_kafka_resp_err_t err;
|
|
152
|
+
rd_kafka_topic_partition_list_t *to_commit = NULL;
|
|
153
|
+
|
|
154
|
+
SUB_TEST_QUICK();
|
|
155
|
+
|
|
156
|
+
rd_kafka_mock_topic_create(mcluster, topic, 1, 1);
|
|
157
|
+
|
|
158
|
+
test_conf_init(&conf, NULL, 30);
|
|
159
|
+
test_conf_set(conf, "bootstrap.servers", bootstraps);
|
|
160
|
+
test_conf_set(conf, "auto.offset.reset", "earliest");
|
|
161
|
+
test_conf_set(conf, "enable.auto.commit", "false");
|
|
162
|
+
test_conf_set(conf, "group.protocol", "consumer");
|
|
163
|
+
|
|
164
|
+
/* Seed the topic with messages */
|
|
165
|
+
test_produce_msgs_easy_v(topic, testid, 0, 0, msgcnt, 0,
|
|
166
|
+
"bootstrap.servers", bootstraps, NULL);
|
|
167
|
+
|
|
168
|
+
/* Consume same messages */
|
|
169
|
+
consumer = test_create_consumer(topic, NULL, conf, NULL);
|
|
170
|
+
test_consumer_subscribe(consumer, topic);
|
|
171
|
+
test_msgver_init(&mv, testid);
|
|
172
|
+
test_consumer_poll("receive first batch", consumer, testid, -1, 0,
|
|
173
|
+
msgcnt, &mv);
|
|
174
|
+
test_msgver_verify("verify first batch", &mv, TEST_MSGVER_ALL, 0,
|
|
175
|
+
msgcnt);
|
|
176
|
+
test_msgver_clear(&mv);
|
|
177
|
+
|
|
178
|
+
/* Set OffsetCommit errors */
|
|
179
|
+
rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_OffsetCommit, 1,
|
|
180
|
+
expected_err);
|
|
181
|
+
|
|
182
|
+
if (variation ==
|
|
183
|
+
TEST_MANUAL_COMMIT_ERROR_VARIATION_STORE_OFFSET_MANUALLY) {
|
|
184
|
+
/* Variation 1: pass offsets to commit */
|
|
185
|
+
to_commit = rd_kafka_topic_partition_list_new(1);
|
|
186
|
+
rd_kafka_topic_partition_list_add(to_commit, topic, 0)->offset =
|
|
187
|
+
msgcnt;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Sync commit */
|
|
191
|
+
err = rd_kafka_commit(consumer, to_commit, rd_false);
|
|
192
|
+
TEST_ASSERT(err == expected_err, "Expected error %s, got %s",
|
|
193
|
+
rd_kafka_err2name(expected_err), rd_kafka_err2name(err));
|
|
194
|
+
|
|
195
|
+
/* Retry it, this time it should work */
|
|
196
|
+
err = rd_kafka_commit(consumer, to_commit, rd_false);
|
|
197
|
+
TEST_ASSERT(err == RD_KAFKA_RESP_ERR_NO_ERROR,
|
|
198
|
+
"Expected error %s, got %s",
|
|
199
|
+
rd_kafka_err2name(RD_KAFKA_RESP_ERR_NO_ERROR),
|
|
200
|
+
rd_kafka_err2name(err));
|
|
201
|
+
|
|
202
|
+
RD_IF_FREE(to_commit, rd_kafka_topic_partition_list_destroy);
|
|
203
|
+
|
|
204
|
+
rd_kafka_destroy(consumer);
|
|
205
|
+
|
|
206
|
+
SUB_TEST_PASS();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Scenarios:
|
|
211
|
+
* during_revocation: the auto-commit is triggered by a revocation,
|
|
212
|
+
* otherwise it's triggered by the consumer close.
|
|
213
|
+
* session_times_out: Session times out giving UNKNOWN_MEMBER_ID, otherwise
|
|
214
|
+
* commit succeeds after last STALE_MEMBER_EPOCH. When
|
|
215
|
+
* session times out the auto-commit fails and messages
|
|
216
|
+
* are consumed again.
|
|
217
|
+
*/
|
|
218
|
+
typedef enum do_test_OffsetCommit_automatic_stale_member_epoch_error_variation_t {
|
|
219
|
+
/** during_revocation=false, session_times_out=false */
|
|
220
|
+
TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION_NO_REVOKE_NO_TIMEOUT = 0,
|
|
221
|
+
/** during_revocation=false, session_times_out=true */
|
|
222
|
+
TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION_NO_REVOKE_WITH_TIMEOUT =
|
|
223
|
+
1,
|
|
224
|
+
/** during_revocation=true, session_times_out=false */
|
|
225
|
+
TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION_REVOKE_NO_TIMEOUT = 2,
|
|
226
|
+
/** during_revocation=true, session_times_out=true */
|
|
227
|
+
TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION_REVOKE_WITH_TIMEOUT = 3,
|
|
228
|
+
TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION__CNT,
|
|
229
|
+
} do_test_OffsetCommit_automatic_stale_member_epoch_error_variation_t;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @brief When a partition is revoked, with auto-commit enabled,
|
|
233
|
+
* if the RPC returns STALE_MEMBER_EPOCH for one of the
|
|
234
|
+
* partitions, it should be retried until the member is
|
|
235
|
+
* fenced.
|
|
236
|
+
*/
|
|
237
|
+
void do_test_OffsetCommit_automatic_stale_member_epoch_error(
|
|
238
|
+
rd_kafka_mock_cluster_t *mcluster,
|
|
239
|
+
const char *bootstraps,
|
|
240
|
+
do_test_OffsetCommit_automatic_stale_member_epoch_error_variation_t
|
|
241
|
+
variation) {
|
|
242
|
+
rd_kafka_t *consumer;
|
|
243
|
+
test_msgver_t mv;
|
|
244
|
+
rd_kafka_conf_t *conf;
|
|
245
|
+
rd_kafka_topic_partition_list_t *target_assignment_partitions;
|
|
246
|
+
const char *topic = test_mk_topic_name(__FUNCTION__, 1);
|
|
247
|
+
uint64_t testid = test_id_generate();
|
|
248
|
+
const int msgcnt = 5;
|
|
249
|
+
const int session_timeout_ms = 3000;
|
|
250
|
+
const int heartbeat_interval_ms = 1000;
|
|
251
|
+
rd_bool_t during_revocation = (variation / 2) == 1;
|
|
252
|
+
rd_bool_t session_times_out = (variation % 2) == 1;
|
|
253
|
+
const char *debug_contexts[2] = {"cgrp", NULL};
|
|
254
|
+
|
|
255
|
+
SUB_TEST_QUICK("during_revocation=%s, session_times_out=%s",
|
|
256
|
+
RD_STR_ToF(during_revocation),
|
|
257
|
+
RD_STR_ToF(session_times_out));
|
|
258
|
+
|
|
259
|
+
rd_kafka_mock_topic_create(mcluster, topic, 2, 2);
|
|
260
|
+
rd_kafka_mock_coordinator_set(mcluster, "group", topic, 1);
|
|
261
|
+
rd_kafka_mock_set_group_consumer_session_timeout_ms(mcluster,
|
|
262
|
+
session_timeout_ms);
|
|
263
|
+
rd_kafka_mock_set_group_consumer_heartbeat_interval_ms(
|
|
264
|
+
mcluster, heartbeat_interval_ms);
|
|
265
|
+
|
|
266
|
+
test_conf_init(&conf, NULL, 30);
|
|
267
|
+
test_conf_set(conf, "bootstrap.servers", bootstraps);
|
|
268
|
+
test_conf_set(conf, "auto.offset.reset", "earliest");
|
|
269
|
+
test_conf_set(conf, "enable.auto.commit", "true");
|
|
270
|
+
test_conf_set(conf, "auto.commit.interval.ms", "1000");
|
|
271
|
+
test_conf_set(conf, "group.protocol", "consumer");
|
|
272
|
+
test_conf_set_log_interceptor(conf, log_cb, debug_contexts);
|
|
273
|
+
|
|
274
|
+
/* Seed the topic with messages */
|
|
275
|
+
test_produce_msgs_easy_v(topic, testid, 0, 0, 3, 0, "bootstrap.servers",
|
|
276
|
+
bootstraps, NULL);
|
|
277
|
+
test_produce_msgs_easy_v(topic, testid, 1, 0, 2, 0, "bootstrap.servers",
|
|
278
|
+
bootstraps, NULL);
|
|
279
|
+
|
|
280
|
+
/* Consume same messages */
|
|
281
|
+
consumer =
|
|
282
|
+
test_create_consumer(topic, NULL, rd_kafka_conf_dup(conf), NULL);
|
|
283
|
+
test_consumer_subscribe(consumer, topic);
|
|
284
|
+
test_msgver_init(&mv, testid);
|
|
285
|
+
test_consumer_poll_exact("receive first batch", consumer, testid, -1, 0,
|
|
286
|
+
msgcnt, rd_true, &mv);
|
|
287
|
+
test_msgver_verify("verify first batch", &mv, TEST_MSGVER_PER_PART, 0,
|
|
288
|
+
msgcnt);
|
|
289
|
+
test_msgver_clear(&mv);
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
rd_kafka_mock_clear_request_errors(mcluster, RD_KAFKAP_OffsetCommit);
|
|
293
|
+
|
|
294
|
+
/* First sequence of stale member epoch for 4 s */
|
|
295
|
+
rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_OffsetCommit, 4,
|
|
296
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
297
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
298
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
299
|
+
RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH);
|
|
300
|
+
|
|
301
|
+
if (during_revocation) {
|
|
302
|
+
/* Changing target assignment to partition 0 only,
|
|
303
|
+
* partition revoked and automatically committed,
|
|
304
|
+
* but the commit fails. */
|
|
305
|
+
target_assignment_partitions =
|
|
306
|
+
rd_kafka_topic_partition_list_new(1);
|
|
307
|
+
rd_kafka_topic_partition_list_add(target_assignment_partitions,
|
|
308
|
+
topic, 0);
|
|
309
|
+
test_mock_cluster_member_assignment(
|
|
310
|
+
mcluster, 1, consumer, target_assignment_partitions);
|
|
311
|
+
rd_kafka_topic_partition_list_destroy(
|
|
312
|
+
target_assignment_partitions);
|
|
313
|
+
|
|
314
|
+
mtx_lock(&log_lock);
|
|
315
|
+
while (!revocation_done)
|
|
316
|
+
cnd_timedwait_ms(&log_cnd, &log_lock, 500);
|
|
317
|
+
revocation_done = rd_false;
|
|
318
|
+
mtx_unlock(&log_lock);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (session_times_out) {
|
|
322
|
+
/* Simulate a session timeout after that */
|
|
323
|
+
rd_kafka_mock_broker_push_request_error_rtts(
|
|
324
|
+
mcluster, 1, RD_KAFKAP_OffsetCommit, 1,
|
|
325
|
+
RD_KAFKA_RESP_ERR_UNKNOWN_MEMBER_ID,
|
|
326
|
+
session_timeout_ms + heartbeat_interval_ms);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* Otherwise partition is committed before leaving the group */
|
|
330
|
+
test_consumer_close(consumer);
|
|
331
|
+
rd_kafka_destroy(consumer);
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
/* Reset mock assignor to automatic */
|
|
335
|
+
rd_kafka_mock_cgrp_consumer_target_assignment(mcluster, topic, NULL);
|
|
336
|
+
|
|
337
|
+
consumer = test_create_consumer(topic, NULL, conf, NULL);
|
|
338
|
+
test_consumer_subscribe(consumer, topic);
|
|
339
|
+
|
|
340
|
+
if (session_times_out) {
|
|
341
|
+
/* Messages are consumed again because the commit failed */
|
|
342
|
+
test_msgver_init(&mv, testid);
|
|
343
|
+
test_consumer_poll_exact("messages consumed again", consumer,
|
|
344
|
+
testid, -1, 0, msgcnt, rd_true, &mv);
|
|
345
|
+
test_msgver_verify("messages consumed again", &mv,
|
|
346
|
+
TEST_MSGVER_PER_PART, 0, msgcnt);
|
|
347
|
+
test_msgver_clear(&mv);
|
|
348
|
+
} else {
|
|
349
|
+
/* No message should be consumed after the autocommit */
|
|
350
|
+
test_consumer_poll_no_msgs("no messages", consumer, testid,
|
|
351
|
+
200);
|
|
352
|
+
}
|
|
353
|
+
test_consumer_close(consumer);
|
|
354
|
+
rd_kafka_destroy(consumer);
|
|
355
|
+
rd_kafka_mock_clear_request_errors(mcluster, RD_KAFKAP_OffsetCommit);
|
|
356
|
+
|
|
357
|
+
SUB_TEST_PASS();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
static void log_cb_closing_issue(const rd_kafka_t *rk,
|
|
361
|
+
int level,
|
|
362
|
+
const char *fac,
|
|
363
|
+
const char *buf) {
|
|
364
|
+
if (strstr(buf, "Acknowledging target assignment")) {
|
|
365
|
+
mtx_lock(&log_lock);
|
|
366
|
+
ack_target_assignment_count++;
|
|
367
|
+
if (ack_target_assignment_count == 2) {
|
|
368
|
+
trigger_consumer_close = rd_true;
|
|
369
|
+
cnd_signal(&log_cnd);
|
|
370
|
+
}
|
|
371
|
+
mtx_unlock(&log_lock);
|
|
372
|
+
}
|
|
373
|
+
if (strstr(buf, "unable to OffsetCommit") &&
|
|
374
|
+
strstr(buf, "Broker: The member epoch is stale")) {
|
|
375
|
+
mtx_lock(&log_lock);
|
|
376
|
+
got_stale_member_epoch_error++;
|
|
377
|
+
mtx_unlock(&log_lock);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @brief This test checks that when a consumer acknowledges revocations and
|
|
383
|
+
* sends a heartbeat just before leaving the group, the heartbeat response may
|
|
384
|
+
* still be in flight while the leave process begins. In this scenario, the
|
|
385
|
+
* heartbeat response must update the member epoch rather than being discarded.
|
|
386
|
+
* Otherwise, subsequent commit requests (which will be required for leaving)
|
|
387
|
+
* may fail with a stale member epoch error.
|
|
388
|
+
*
|
|
389
|
+
* Sequence of events:
|
|
390
|
+
* 1. Consumer is subscribed to topic1 and topic2 and has received messages
|
|
391
|
+
* 2. Consumer changes subscription to only topic1, this triggers revocation of
|
|
392
|
+
* topic2 partitions.
|
|
393
|
+
* 3. Consumer acknowledges the revocation and sends a heartbeat. The heartbeat
|
|
394
|
+
* response is delayed (simulated by mock). Due to this, the member epoch on
|
|
395
|
+
* the broker end is increased but the consumer has not received it yet.
|
|
396
|
+
* 4. Meanwhile, the consumer receives messages from topic1.
|
|
397
|
+
* 5. The consumer is closed, this triggers a leave group which includes an
|
|
398
|
+
* offset commit request for the received messages.
|
|
399
|
+
* 6. This triggers a stale member epoch error since the consumer is not aware
|
|
400
|
+
* of the increased member epoch on the broker end.
|
|
401
|
+
* 7. The stale member epoch error triggers ConsumerGroupHeartbeat request
|
|
402
|
+
* which receives to receive the latest member epoch.
|
|
403
|
+
* 8. The offset commit is retried and succeeds.
|
|
404
|
+
*/
|
|
405
|
+
void do_test_consumer_inflight_heartbeat_on_leave(
|
|
406
|
+
rd_kafka_mock_cluster_t *mcluster,
|
|
407
|
+
const char *bootstraps) {
|
|
408
|
+
|
|
409
|
+
char topic1[256], topic2[256];
|
|
410
|
+
rd_kafka_t *producer, *consumer;
|
|
411
|
+
rd_kafka_conf_t *conf, *producer_conf;
|
|
412
|
+
uint64_t testid = test_id_generate();
|
|
413
|
+
const int msgcnt = 5;
|
|
414
|
+
test_msgver_t mv;
|
|
415
|
+
const char *debug_contexts[3] = {"cgrp", NULL};
|
|
416
|
+
int64_t close_start, close_end;
|
|
417
|
+
const int session_timeout_ms = 3000;
|
|
418
|
+
const int heartbeat_rtt_ms = 200;
|
|
419
|
+
|
|
420
|
+
SUB_TEST_QUICK();
|
|
421
|
+
|
|
422
|
+
mtx_init(&log_lock, mtx_plain);
|
|
423
|
+
cnd_init(&log_cnd);
|
|
424
|
+
|
|
425
|
+
strcpy(topic1, test_mk_topic_name("topic1", 1));
|
|
426
|
+
strcpy(topic2, test_mk_topic_name("topic2", 1));
|
|
427
|
+
|
|
428
|
+
test_conf_init(&conf, NULL, 30);
|
|
429
|
+
test_conf_set(conf, "bootstrap.servers", bootstraps);
|
|
430
|
+
test_conf_set(conf, "group.protocol", "consumer");
|
|
431
|
+
test_conf_set(conf, "auto.offset.reset", "earliest");
|
|
432
|
+
test_conf_set(conf, "enable.auto.commit", "true");
|
|
433
|
+
test_conf_set(conf, "auto.commit.interval.ms", "2000");
|
|
434
|
+
test_conf_set(conf, "fetch.wait.max.ms", "100");
|
|
435
|
+
test_conf_set_log_interceptor(conf, log_cb_closing_issue,
|
|
436
|
+
debug_contexts);
|
|
437
|
+
|
|
438
|
+
rd_kafka_mock_coordinator_set(mcluster, "group", topic1, 1);
|
|
439
|
+
rd_kafka_mock_set_group_consumer_session_timeout_ms(mcluster,
|
|
440
|
+
session_timeout_ms);
|
|
441
|
+
rd_kafka_mock_set_group_consumer_heartbeat_interval_ms(mcluster, 500);
|
|
442
|
+
|
|
443
|
+
/* Producer Initialization */
|
|
444
|
+
producer_conf = rd_kafka_conf_dup(conf);
|
|
445
|
+
rd_kafka_conf_set_dr_msg_cb(producer_conf, test_dr_msg_cb);
|
|
446
|
+
producer = test_create_handle(RD_KAFKA_PRODUCER, producer_conf);
|
|
447
|
+
|
|
448
|
+
/* Create topic1 and produce few messages */
|
|
449
|
+
rd_kafka_mock_topic_create(mcluster, topic1, 1, 1);
|
|
450
|
+
test_produce_msgs2(producer, topic1, testid, 0, 0, msgcnt, NULL, 0);
|
|
451
|
+
rd_kafka_flush(producer, -1);
|
|
452
|
+
|
|
453
|
+
/* Create topic2 and produce few messages */
|
|
454
|
+
rd_kafka_mock_topic_create(mcluster, topic2, 1, 1);
|
|
455
|
+
test_produce_msgs2(producer, topic2, testid, 0, 0, msgcnt, NULL, 0);
|
|
456
|
+
rd_kafka_flush(producer, -1);
|
|
457
|
+
|
|
458
|
+
/* Consumer: subscribe to both topics */
|
|
459
|
+
TEST_SAY("Group id: %s\n", topic1);
|
|
460
|
+
consumer =
|
|
461
|
+
test_create_consumer(topic1, NULL, rd_kafka_conf_dup(conf), NULL);
|
|
462
|
+
test_consumer_subscribe_multi(consumer, 2, topic1, topic2);
|
|
463
|
+
|
|
464
|
+
/* Poll and verify messages produced to both topics */
|
|
465
|
+
test_msgver_init(&mv, testid);
|
|
466
|
+
test_consumer_poll("read from both topics", consumer, testid, -1, 0,
|
|
467
|
+
2 * msgcnt, &mv);
|
|
468
|
+
test_msgver_clear(&mv);
|
|
469
|
+
|
|
470
|
+
/* Change subscription to only topic1 to trigger revocation */
|
|
471
|
+
test_consumer_subscribe(consumer, topic1);
|
|
472
|
+
|
|
473
|
+
/* Set ConsumerGroupHeartbeat RTT to heartbeat_rtt_ms */
|
|
474
|
+
rd_kafka_mock_broker_push_request_error_rtts(
|
|
475
|
+
mcluster, 1, RD_KAFKAP_ConsumerGroupHeartbeat, 2,
|
|
476
|
+
RD_KAFKA_RESP_ERR_NO_ERROR, heartbeat_rtt_ms,
|
|
477
|
+
RD_KAFKA_RESP_ERR_NO_ERROR, heartbeat_rtt_ms);
|
|
478
|
+
|
|
479
|
+
/* Produce few more messages to topic1 so that we can trigger
|
|
480
|
+
auto-commit later which will give stale member epoch error */
|
|
481
|
+
test_produce_msgs2(producer, topic1, testid, 0, 0, msgcnt, NULL, 0);
|
|
482
|
+
rd_kafka_flush(producer, -1);
|
|
483
|
+
|
|
484
|
+
/* Wait for log callback to trigger consumer close after second
|
|
485
|
+
"Acknowledging target assignment" */
|
|
486
|
+
mtx_lock(&log_lock);
|
|
487
|
+
while (!trigger_consumer_close)
|
|
488
|
+
cnd_timedwait_ms(&log_cnd, &log_lock, 500);
|
|
489
|
+
mtx_unlock(&log_lock);
|
|
490
|
+
|
|
491
|
+
/* Poll and verify the produced messages */
|
|
492
|
+
test_msgver_init(&mv, testid);
|
|
493
|
+
test_consumer_poll("read topic1", consumer, testid, -1, 0, msgcnt, &mv);
|
|
494
|
+
test_msgver_clear(&mv);
|
|
495
|
+
|
|
496
|
+
/* Close consumer which will trigger leave group and auto-commit
|
|
497
|
+
The auto-commit will get stale member epoch error and will retry
|
|
498
|
+
after receiving the heartbeat response with the latest member
|
|
499
|
+
epoch */
|
|
500
|
+
close_start = test_clock();
|
|
501
|
+
test_consumer_close(consumer);
|
|
502
|
+
close_end = test_clock();
|
|
503
|
+
|
|
504
|
+
/* Verify that we got exactly one stale member epoch error */
|
|
505
|
+
mtx_lock(&log_lock);
|
|
506
|
+
TEST_ASSERT(got_stale_member_epoch_error == 1,
|
|
507
|
+
"Expected 1 stale member epoch error, got %d",
|
|
508
|
+
got_stale_member_epoch_error);
|
|
509
|
+
mtx_unlock(&log_lock);
|
|
510
|
+
|
|
511
|
+
/* Verify that the consumer closed within session timeout, if it reaches
|
|
512
|
+
session timeout which means that the member is kicked out of the
|
|
513
|
+
group. */
|
|
514
|
+
TEST_ASSERT((close_end - close_start) < session_timeout_ms * 1000,
|
|
515
|
+
"Consumer did not close within 2s, took %" PRId64 " us",
|
|
516
|
+
(close_end - close_start));
|
|
517
|
+
|
|
518
|
+
rd_kafka_destroy(consumer);
|
|
519
|
+
rd_kafka_destroy(producer);
|
|
520
|
+
|
|
521
|
+
mtx_destroy(&log_lock);
|
|
522
|
+
cnd_destroy(&log_cnd);
|
|
523
|
+
|
|
524
|
+
SUB_TEST_PASS();
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
int main_0148_offset_fetch_commit_error_mock(int argc, char **argv) {
|
|
528
|
+
rd_kafka_mock_cluster_t *mcluster;
|
|
529
|
+
const char *bootstraps;
|
|
530
|
+
int i;
|
|
531
|
+
|
|
532
|
+
TEST_SKIP_MOCK_CLUSTER(0);
|
|
533
|
+
|
|
534
|
+
if (test_consumer_group_protocol_classic()) {
|
|
535
|
+
TEST_SKIP(
|
|
536
|
+
"Test not meaningful with 'classic' consumer group "
|
|
537
|
+
"protocol\n");
|
|
538
|
+
return 0;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
mcluster = test_mock_cluster_new(3, &bootstraps);
|
|
542
|
+
|
|
543
|
+
do_test_OffsetFetch_stale_member_epoch_error(mcluster, bootstraps);
|
|
544
|
+
|
|
545
|
+
for (i = 0; i < TEST_MANUAL_COMMIT_ERROR_VARIATION__CNT; i++) {
|
|
546
|
+
do_test_OffsetCommit_manual_error(
|
|
547
|
+
mcluster, bootstraps, RD_KAFKA_RESP_ERR_STALE_MEMBER_EPOCH,
|
|
548
|
+
i);
|
|
549
|
+
do_test_OffsetCommit_manual_error(
|
|
550
|
+
mcluster, bootstraps, RD_KAFKA_RESP_ERR_UNKNOWN_MEMBER_ID,
|
|
551
|
+
i);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
for (i = 0; i < TEST_AUTO_COMMIT_STALE_MEMBER_EPOCH_VARIATION__CNT; i++)
|
|
555
|
+
do_test_OffsetCommit_automatic_stale_member_epoch_error(
|
|
556
|
+
mcluster, bootstraps, i);
|
|
557
|
+
|
|
558
|
+
do_test_consumer_inflight_heartbeat_on_leave(mcluster, bootstraps);
|
|
559
|
+
|
|
560
|
+
test_mock_cluster_destroy(mcluster);
|
|
561
|
+
|
|
562
|
+
return 0;
|
|
563
|
+
}
|