@platformatic/rdkafka 4.0.1 → 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 +8 -1
- package/ci/prepublish.js +4 -4
- 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/LICENSES.txt +592 -1
- 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/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 +10 -11
- 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
|
@@ -81,6 +81,7 @@ int main_0047_partial_buf_tmout(int argc, char **argv) {
|
|
|
81
81
|
|
|
82
82
|
rkt = test_create_producer_topic(rk, topic, "message.timeout.ms", "300",
|
|
83
83
|
NULL);
|
|
84
|
+
test_wait_topic_exists(rk, topic, 5000);
|
|
84
85
|
|
|
85
86
|
while (got_timeout_err == 0) {
|
|
86
87
|
test_produce_msgs_nowait(rk, rkt, 0, RD_KAFKA_PARTITION_UA, 0,
|
|
@@ -267,7 +267,7 @@ static void do_test_partitioners(void) {
|
|
|
267
267
|
int pi;
|
|
268
268
|
const char *topic = test_mk_topic_name(__FUNCTION__, 1);
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
test_create_topic_wait_exists(NULL, topic, part_cnt, 1, 5000);
|
|
271
271
|
|
|
272
272
|
for (pi = 0; ptest[pi].partitioner; pi++) {
|
|
273
273
|
do_test_partitioner(topic, ptest[pi].partitioner, _MSG_CNT,
|
|
@@ -74,6 +74,7 @@ test_no_duplicate_messages(const char *partition_assignment_strategy) {
|
|
|
74
74
|
rd_kafka_topic_t *rkt;
|
|
75
75
|
|
|
76
76
|
rkt = test_create_producer_topic(rk, topic[i], NULL);
|
|
77
|
+
test_wait_topic_exists(rk, topic[i], 5000);
|
|
77
78
|
|
|
78
79
|
test_produce_msgs(rk, rkt, testid, RD_KAFKA_PARTITION_UA,
|
|
79
80
|
(msgcnt / TOPIC_CNT) * i,
|
|
@@ -68,6 +68,7 @@ int main_0051_assign_adds(int argc, char **argv) {
|
|
|
68
68
|
rd_kafka_topic_t *rkt;
|
|
69
69
|
|
|
70
70
|
rkt = test_create_producer_topic(rk, topic[i], NULL);
|
|
71
|
+
test_wait_topic_exists(rk, topic[i], 5000);
|
|
71
72
|
|
|
72
73
|
test_produce_msgs(rk, rkt, testid, 0, (msgcnt / TOPIC_CNT) * i,
|
|
73
74
|
(msgcnt / TOPIC_CNT), NULL, 100);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -165,6 +166,7 @@ static void test_timestamps(const char *broker_tstype,
|
|
|
165
166
|
"--replication-factor 1 --partitions 1 "
|
|
166
167
|
"--config message.timestamp.type=%s",
|
|
167
168
|
topic, broker_tstype);
|
|
169
|
+
test_wait_topic_exists(NULL, topic, 5000);
|
|
168
170
|
|
|
169
171
|
TEST_SAY(_C_MAG "Producing %d messages to %s\n", msgcnt, topic);
|
|
170
172
|
produce_msgs(topic, 0, testid, msgcnt, broker_version, codec);
|
|
@@ -180,6 +182,7 @@ static void test_timestamps(const char *broker_tstype,
|
|
|
180
182
|
|
|
181
183
|
|
|
182
184
|
int main_0052_msg_timestamps(int argc, char **argv) {
|
|
185
|
+
rd_bool_t test_with_apache_kafka_since_4_0 = rd_false;
|
|
183
186
|
|
|
184
187
|
if (!test_can_create_topics(1))
|
|
185
188
|
return 0;
|
|
@@ -189,6 +192,13 @@ int main_0052_msg_timestamps(int argc, char **argv) {
|
|
|
189
192
|
return 0;
|
|
190
193
|
}
|
|
191
194
|
|
|
195
|
+
if (test_broker_version >= TEST_BRKVER(4, 0, 0, 0)) {
|
|
196
|
+
/* Code using `broker.version.fallback` and
|
|
197
|
+
* `api.version.request=false` won't work
|
|
198
|
+
* against Apache Kafka 4.0 */
|
|
199
|
+
test_with_apache_kafka_since_4_0 = rd_true;
|
|
200
|
+
}
|
|
201
|
+
|
|
192
202
|
/* Broker version limits the producer's feature set,
|
|
193
203
|
* for 0.9.0.0 no timestamp will be transmitted,
|
|
194
204
|
* but for 0.10.1.0 (or newer, api.version.request will be true)
|
|
@@ -207,13 +217,21 @@ int main_0052_msg_timestamps(int argc, char **argv) {
|
|
|
207
217
|
|
|
208
218
|
test_timestamps("CreateTime", "0.10.1.0", "none", &my_timestamp);
|
|
209
219
|
test_timestamps("LogAppendTime", "0.10.1.0", "none", &broker_timestamp);
|
|
210
|
-
|
|
211
|
-
|
|
220
|
+
if (!test_with_apache_kafka_since_4_0) {
|
|
221
|
+
test_timestamps("CreateTime", "0.9.0.0", "none",
|
|
222
|
+
&invalid_timestamp);
|
|
223
|
+
test_timestamps("LogAppendTime", "0.9.0.0", "none",
|
|
224
|
+
&broker_timestamp);
|
|
225
|
+
}
|
|
212
226
|
#if WITH_ZLIB
|
|
213
227
|
test_timestamps("CreateTime", "0.10.1.0", "gzip", &my_timestamp);
|
|
214
228
|
test_timestamps("LogAppendTime", "0.10.1.0", "gzip", &broker_timestamp);
|
|
215
|
-
|
|
216
|
-
|
|
229
|
+
if (!test_with_apache_kafka_since_4_0) {
|
|
230
|
+
test_timestamps("CreateTime", "0.9.0.0", "gzip",
|
|
231
|
+
&invalid_timestamp);
|
|
232
|
+
test_timestamps("LogAppendTime", "0.9.0.0", "gzip",
|
|
233
|
+
&broker_timestamp);
|
|
234
|
+
}
|
|
217
235
|
#endif
|
|
218
236
|
|
|
219
237
|
return 0;
|
|
@@ -324,17 +324,13 @@ static void verify_e2e_stats(const std::string &prod_stats,
|
|
|
324
324
|
exp_tot_rxmsg_bytes += rxbytes;
|
|
325
325
|
|
|
326
326
|
Test::Say(tostr() << "Producer partition: " << (*pp)["partition"].GetInt()
|
|
327
|
-
<< ": "
|
|
328
|
-
<< "
|
|
329
|
-
<< exp_parts[part].
|
|
330
|
-
<< "txbytes: " << txbytes << " vs "
|
|
331
|
-
<< exp_parts[part].totsize << "\n");
|
|
327
|
+
<< ": " << "txmsgs: " << txmsgs << " vs "
|
|
328
|
+
<< exp_parts[part].msgcnt << ", " << "txbytes: "
|
|
329
|
+
<< txbytes << " vs " << exp_parts[part].totsize << "\n");
|
|
332
330
|
Test::Say(tostr() << "Consumer partition: " << (*cp)["partition"].GetInt()
|
|
333
|
-
<< ": "
|
|
334
|
-
<< "
|
|
335
|
-
<< exp_parts[part].
|
|
336
|
-
<< "rxbytes: " << rxbytes << " vs "
|
|
337
|
-
<< exp_parts[part].totsize << "\n");
|
|
331
|
+
<< ": " << "rxmsgs: " << rxmsgs << " vs "
|
|
332
|
+
<< exp_parts[part].msgcnt << ", " << "rxbytes: "
|
|
333
|
+
<< rxbytes << " vs " << exp_parts[part].totsize << "\n");
|
|
338
334
|
}
|
|
339
335
|
|
|
340
336
|
/* Check top-level total stats */
|
|
@@ -349,16 +345,12 @@ static void verify_e2e_stats(const std::string &prod_stats,
|
|
|
349
345
|
int64_t tot_rxmsgs = c["rxmsgs"].GetInt();
|
|
350
346
|
int64_t tot_rxmsg_bytes = c["rxmsg_bytes"].GetInt();
|
|
351
347
|
|
|
352
|
-
Test::Say(tostr() << "Producer total: "
|
|
353
|
-
<< "
|
|
354
|
-
<< "
|
|
355
|
-
|
|
356
|
-
<<
|
|
357
|
-
|
|
358
|
-
<< "rxmsgs: " << tot_rxmsgs << " vs " << exp_tot_rxmsgs
|
|
359
|
-
<< ", "
|
|
360
|
-
<< "rxbytes: " << tot_rxmsg_bytes << " vs "
|
|
361
|
-
<< exp_tot_rxmsg_bytes << "\n");
|
|
348
|
+
Test::Say(tostr() << "Producer total: " << "txmsgs: " << tot_txmsgs << " vs "
|
|
349
|
+
<< exp_tot_txmsgs << ", " << "txbytes: " << tot_txmsg_bytes
|
|
350
|
+
<< " vs " << exp_tot_txmsg_bytes << "\n");
|
|
351
|
+
Test::Say(tostr() << "Consumer total: " << "rxmsgs: " << tot_rxmsgs << " vs "
|
|
352
|
+
<< exp_tot_rxmsgs << ", " << "rxbytes: " << tot_rxmsg_bytes
|
|
353
|
+
<< " vs " << exp_tot_rxmsg_bytes << "\n");
|
|
362
354
|
}
|
|
363
355
|
|
|
364
356
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
|
|
29
30
|
#include "test.h"
|
|
30
31
|
#include "rdkafka.h"
|
|
32
|
+
#include "../src/rdkafka_protocol.h"
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
#define _MSG_COUNT 10
|
|
@@ -146,10 +148,10 @@ static int verify_latency(struct latconf *latconf) {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
latconf->wakeups = tot_wakeups;
|
|
149
|
-
if (latconf->wakeups
|
|
151
|
+
if (latconf->wakeups > 1000) {
|
|
150
152
|
TEST_FAIL_LATER(
|
|
151
153
|
"%s: broker wakeups out of range: %d, "
|
|
152
|
-
"expected
|
|
154
|
+
"expected 5..1000",
|
|
153
155
|
latconf->name, latconf->wakeups);
|
|
154
156
|
fails++;
|
|
155
157
|
}
|
|
@@ -341,7 +343,7 @@ int main_0055_producer_latency(int argc, char **argv) {
|
|
|
341
343
|
}
|
|
342
344
|
|
|
343
345
|
/* Create topic without replicas to keep broker-side latency down */
|
|
344
|
-
|
|
346
|
+
test_create_topic_wait_exists(NULL, topic, 1, 1, 5000);
|
|
345
347
|
|
|
346
348
|
for (latconf = latconfs; latconf->name; latconf++)
|
|
347
349
|
test_producer_latency(topic, latconf);
|
|
@@ -364,3 +366,174 @@ int main_0055_producer_latency(int argc, char **argv) {
|
|
|
364
366
|
|
|
365
367
|
return 0;
|
|
366
368
|
}
|
|
369
|
+
|
|
370
|
+
static void dr_msg_cb_first_message(rd_kafka_t *rk,
|
|
371
|
+
const rd_kafka_message_t *rkmessage,
|
|
372
|
+
void *opaque) {
|
|
373
|
+
test_timing_t *t_produce = (test_timing_t *)rkmessage->_private;
|
|
374
|
+
TIMING_STOP(t_produce);
|
|
375
|
+
/* The reason for setting such a low value is that both the mcluster and
|
|
376
|
+
* the producer are running locally, and there is no linger. This
|
|
377
|
+
* prevents the test from passing spuriously. */
|
|
378
|
+
TIMING_ASSERT_LATER(t_produce, 0, 100);
|
|
379
|
+
|
|
380
|
+
TEST_ASSERT(rkmessage->err == RD_KAFKA_RESP_ERR_NO_ERROR,
|
|
381
|
+
"expected no error, got %s",
|
|
382
|
+
rd_kafka_err2str(rkmessage->err));
|
|
383
|
+
TEST_ASSERT(rkmessage->offset == 0);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Test producer latency of the first message to 50 different topics.
|
|
388
|
+
*
|
|
389
|
+
* Cases:
|
|
390
|
+
* 0: rd_kafka_produce
|
|
391
|
+
* 1: rd_kafka_producev
|
|
392
|
+
* 2: rd_kafka_produceva
|
|
393
|
+
* 3: rd_kafka_produce_batch
|
|
394
|
+
*/
|
|
395
|
+
static void test_producer_latency_first_message(int case_number) {
|
|
396
|
+
rd_kafka_t *rk;
|
|
397
|
+
rd_kafka_conf_t *conf;
|
|
398
|
+
const char *topic;
|
|
399
|
+
test_timing_t t_produce;
|
|
400
|
+
rd_kafka_resp_err_t err;
|
|
401
|
+
rd_kafka_mock_cluster_t *mcluster;
|
|
402
|
+
rd_kafka_resp_err_t err_produce;
|
|
403
|
+
const char *bootstrap_servers;
|
|
404
|
+
const char *case_name = NULL;
|
|
405
|
+
int i;
|
|
406
|
+
size_t cnt;
|
|
407
|
+
rd_kafka_mock_request_t **reqs = NULL;
|
|
408
|
+
int metadata_request_cnt = 0;
|
|
409
|
+
const int iterations = 50;
|
|
410
|
+
|
|
411
|
+
if (case_number == 0) {
|
|
412
|
+
case_name = "rd_kafka_produce";
|
|
413
|
+
} else if (case_number == 1) {
|
|
414
|
+
case_name = "rd_kafka_producev";
|
|
415
|
+
} else if (case_number == 2) {
|
|
416
|
+
case_name = "rd_kafka_produceva";
|
|
417
|
+
} else if (case_number == 3) {
|
|
418
|
+
case_name = "rd_kafka_produce_batch";
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
SUB_TEST("Starting test for %s", case_name);
|
|
422
|
+
mcluster = test_mock_cluster_new(1, &bootstrap_servers);
|
|
423
|
+
|
|
424
|
+
test_conf_init(&conf, NULL, 60);
|
|
425
|
+
test_conf_set(conf, "bootstrap.servers", bootstrap_servers);
|
|
426
|
+
test_conf_set(conf, "linger.ms", "0");
|
|
427
|
+
rd_kafka_conf_set_dr_msg_cb(conf, dr_msg_cb_first_message);
|
|
428
|
+
rk = test_create_handle(RD_KAFKA_PRODUCER, conf);
|
|
429
|
+
|
|
430
|
+
rd_kafka_mock_start_request_tracking(mcluster);
|
|
431
|
+
|
|
432
|
+
/* Run the case 50 times. */
|
|
433
|
+
for (i = 0; i < iterations; i++) {
|
|
434
|
+
topic = test_mk_topic_name("0055_producer_latency_mock", 1);
|
|
435
|
+
rd_kafka_mock_topic_create(mcluster, topic, 1, 1);
|
|
436
|
+
|
|
437
|
+
switch (case_number) {
|
|
438
|
+
case 0: {
|
|
439
|
+
char *payload = "value";
|
|
440
|
+
rd_kafka_topic_t *rkt =
|
|
441
|
+
rd_kafka_topic_new(rk, topic, NULL);
|
|
442
|
+
int res;
|
|
443
|
+
TIMING_START(&t_produce, "Produce message");
|
|
444
|
+
|
|
445
|
+
res = rd_kafka_produce(rkt, 0, RD_KAFKA_MSG_F_COPY,
|
|
446
|
+
payload, 5, NULL, 0, &t_produce);
|
|
447
|
+
rd_kafka_topic_destroy(rkt);
|
|
448
|
+
TEST_ASSERT(res == 0, "expected no error");
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
case 1: {
|
|
452
|
+
TIMING_START(&t_produce, "Produce message");
|
|
453
|
+
err_produce = rd_kafka_producev(
|
|
454
|
+
rk, RD_KAFKA_V_TOPIC(topic),
|
|
455
|
+
RD_KAFKA_V_PARTITION(0),
|
|
456
|
+
RD_KAFKA_V_VALUE("value", 5),
|
|
457
|
+
RD_KAFKA_V_OPAQUE((&t_produce)), RD_KAFKA_V_END);
|
|
458
|
+
TEST_ASSERT(err_produce == RD_KAFKA_RESP_ERR_NO_ERROR,
|
|
459
|
+
"expected no error, got %s",
|
|
460
|
+
rd_kafka_err2str(err_produce));
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case 2: {
|
|
464
|
+
rd_kafka_vu_t vus[3];
|
|
465
|
+
vus[0].vtype = RD_KAFKA_VTYPE_TOPIC;
|
|
466
|
+
vus[0].u.cstr = topic;
|
|
467
|
+
vus[1].vtype = RD_KAFKA_VTYPE_VALUE;
|
|
468
|
+
vus[1].u.mem.ptr = "value";
|
|
469
|
+
vus[1].u.mem.size = 5;
|
|
470
|
+
vus[2].vtype = RD_KAFKA_VTYPE_OPAQUE;
|
|
471
|
+
vus[2].u.ptr = &t_produce;
|
|
472
|
+
|
|
473
|
+
TIMING_START(&t_produce, "Produce message");
|
|
474
|
+
TEST_CALL_ERROR__(rd_kafka_produceva(rk, vus, 3));
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
case 3: {
|
|
478
|
+
rd_kafka_message_t rkmessages[1] = {0};
|
|
479
|
+
rd_kafka_topic_t *rkt =
|
|
480
|
+
rd_kafka_topic_new(rk, topic, NULL);
|
|
481
|
+
int res;
|
|
482
|
+
|
|
483
|
+
rkmessages[0].payload = "value";
|
|
484
|
+
rkmessages[0].len = 5;
|
|
485
|
+
rkmessages[0]._private = &t_produce;
|
|
486
|
+
|
|
487
|
+
TIMING_START(&t_produce, "Produce message");
|
|
488
|
+
res = rd_kafka_produce_batch(
|
|
489
|
+
rkt, 0, RD_KAFKA_MSG_F_COPY, rkmessages, 1);
|
|
490
|
+
rd_kafka_topic_destroy(rkt);
|
|
491
|
+
TEST_ASSERT(res == 1, "expected 1 msg enqueued, got %d",
|
|
492
|
+
res);
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
rd_kafka_poll(rk, 0);
|
|
497
|
+
err = rd_kafka_flush(rk, 10000);
|
|
498
|
+
TEST_ASSERT(err == RD_KAFKA_RESP_ERR_NO_ERROR,
|
|
499
|
+
"expected all messages to be flushed, got %s",
|
|
500
|
+
rd_kafka_err2str(err));
|
|
501
|
+
|
|
502
|
+
/* The topic_scan_all timer runs every 1 second. Originally, the
|
|
503
|
+
* issue was that the topic metadata was only fetched on the
|
|
504
|
+
* topic scan rather than when we were queueing the message.
|
|
505
|
+
* Running a loop and waiting 1ms between iterations means we
|
|
506
|
+
* will avoid passing tests due to coincidence. */
|
|
507
|
+
rd_usleep(1 * 1000ll, 0);
|
|
508
|
+
}
|
|
509
|
+
rd_kafka_destroy(rk);
|
|
510
|
+
|
|
511
|
+
reqs = rd_kafka_mock_get_requests(mcluster, &cnt);
|
|
512
|
+
for (i = 0; i < (int)cnt; i++) {
|
|
513
|
+
if (rd_kafka_mock_request_api_key(reqs[i]) ==
|
|
514
|
+
RD_KAFKAP_Metadata) {
|
|
515
|
+
metadata_request_cnt++;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
TEST_ASSERT(metadata_request_cnt == iterations,
|
|
519
|
+
"Expected exactly %d MetadataRequest, got %d", iterations,
|
|
520
|
+
metadata_request_cnt);
|
|
521
|
+
rd_kafka_mock_request_destroy_array(reqs, cnt);
|
|
522
|
+
rd_kafka_mock_stop_request_tracking(mcluster);
|
|
523
|
+
|
|
524
|
+
test_mock_cluster_destroy(mcluster);
|
|
525
|
+
|
|
526
|
+
TEST_LATER_CHECK();
|
|
527
|
+
SUB_TEST_PASS();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
int main_0055_producer_latency_mock(int argc, char **argv) {
|
|
531
|
+
TEST_SKIP_MOCK_CLUSTER(0);
|
|
532
|
+
|
|
533
|
+
int case_number;
|
|
534
|
+
for (case_number = 0; case_number < 4; case_number++) {
|
|
535
|
+
test_producer_latency_first_message(case_number);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return 0;
|
|
539
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -152,7 +153,8 @@ static void rebalance_cb(rd_kafka_t *rk,
|
|
|
152
153
|
case RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS:
|
|
153
154
|
assign_cnt++;
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
test_consumer_assign_by_rebalance_protocol("rebalance", rk,
|
|
157
|
+
partitions);
|
|
156
158
|
mtx_lock(&lock);
|
|
157
159
|
consumers_running = 1;
|
|
158
160
|
mtx_unlock(&lock);
|
|
@@ -177,7 +179,8 @@ static void rebalance_cb(rd_kafka_t *rk,
|
|
|
177
179
|
if (assign_cnt == 0)
|
|
178
180
|
TEST_FAIL("asymetric rebalance_cb");
|
|
179
181
|
assign_cnt--;
|
|
180
|
-
|
|
182
|
+
test_consumer_unassign_by_rebalance_protocol("rebalance", rk,
|
|
183
|
+
partitions);
|
|
181
184
|
mtx_lock(&lock);
|
|
182
185
|
consumers_running = 0;
|
|
183
186
|
mtx_unlock(&lock);
|
|
@@ -222,6 +225,7 @@ int main_0056_balanced_group_mt(int argc, char **argv) {
|
|
|
222
225
|
/* Produce messages */
|
|
223
226
|
rk_p = test_create_producer();
|
|
224
227
|
rkt_p = test_create_producer_topic(rk_p, topic, NULL);
|
|
228
|
+
test_wait_topic_exists(rk_p, topic, 5000);
|
|
225
229
|
|
|
226
230
|
for (partition = 0; partition < partition_cnt; partition++) {
|
|
227
231
|
test_produce_msgs(rk_p, rkt_p, testid, partition,
|
|
@@ -52,9 +52,9 @@ class myLogCb : public RdKafka::EventCb {
|
|
|
52
52
|
switch (event.type()) {
|
|
53
53
|
case RdKafka::Event::EVENT_LOG:
|
|
54
54
|
cnt_++;
|
|
55
|
-
Test::Say(tostr() << "Log: "
|
|
56
|
-
<< "
|
|
57
|
-
<< event.
|
|
55
|
+
Test::Say(tostr() << "Log: " << "level " << event.severity()
|
|
56
|
+
<< ", facility " << event.fac() << ", str "
|
|
57
|
+
<< event.str() << "\n");
|
|
58
58
|
if (state_ != _EXP_LOG)
|
|
59
59
|
Test::Fail(
|
|
60
60
|
"Received unexpected "
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2016-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
#include <iostream>
|
|
31
|
+
#include <ctime>
|
|
30
32
|
#include "testcpp.h"
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -110,7 +112,7 @@ class MyDeliveryReportCb : public RdKafka::DeliveryReportCb {
|
|
|
110
112
|
static void do_test_bsearch(void) {
|
|
111
113
|
RdKafka::Conf *conf, *tconf;
|
|
112
114
|
int msgcnt = 1000;
|
|
113
|
-
int64_t
|
|
115
|
+
int64_t timestamp_ms;
|
|
114
116
|
std::string errstr;
|
|
115
117
|
RdKafka::ErrorCode err;
|
|
116
118
|
MyDeliveryReportCb my_dr;
|
|
@@ -128,14 +130,16 @@ static void do_test_bsearch(void) {
|
|
|
128
130
|
delete conf;
|
|
129
131
|
delete tconf;
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
/* Start with now() - 1h */
|
|
134
|
+
timestamp_ms = std::time(0) * 1000LL - 3600LL * 1000LL;
|
|
135
|
+
|
|
132
136
|
for (int i = 0; i < msgcnt; i++) {
|
|
133
137
|
err = p->produce(topic, partition, RdKafka::Producer::RK_MSG_COPY,
|
|
134
|
-
(void *)topic.c_str(), topic.size(), NULL, 0,
|
|
138
|
+
(void *)topic.c_str(), topic.size(), NULL, 0, timestamp_ms,
|
|
135
139
|
i == 357 ? (void *)1 /*golden*/ : NULL);
|
|
136
140
|
if (err != RdKafka::ERR_NO_ERROR)
|
|
137
141
|
Test::Fail("Produce failed: " + RdKafka::err2str(err));
|
|
138
|
-
|
|
142
|
+
timestamp_ms += 100 + (i % 10);
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
if (p->flush(tmout_multip(5000)) != 0)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2016-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -39,18 +40,33 @@ static std::string topic;
|
|
|
39
40
|
|
|
40
41
|
class StatsCb : public RdKafka::EventCb {
|
|
41
42
|
public:
|
|
42
|
-
int64_t calc_lag;
|
|
43
|
-
int lag_valid;
|
|
43
|
+
int64_t calc_lag; // calculated lag
|
|
44
|
+
int lag_valid; // number of times lag has been valid
|
|
45
|
+
bool partitions_assigned; // partitions were assigned
|
|
46
|
+
bool skip_first; // skip first event after assignment
|
|
44
47
|
|
|
45
48
|
StatsCb() {
|
|
46
|
-
calc_lag
|
|
47
|
-
lag_valid
|
|
49
|
+
calc_lag = -1;
|
|
50
|
+
lag_valid = 0;
|
|
51
|
+
partitions_assigned = false;
|
|
52
|
+
skip_first = true;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/**
|
|
51
56
|
* @brief Event callback
|
|
52
57
|
*/
|
|
53
58
|
void event_cb(RdKafka::Event &event) {
|
|
59
|
+
if (!partitions_assigned) {
|
|
60
|
+
/* It means we won't find the topic in the stats JSON. */
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (skip_first) {
|
|
65
|
+
skip_first = false;
|
|
66
|
+
/* First JSON after assignment could be created before the assignment. */
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
if (event.type() == RdKafka::Event::EVENT_LOG) {
|
|
55
71
|
Test::Say(tostr() << "LOG-" << event.severity() << "-" << event.fac()
|
|
56
72
|
<< ": " << event.str() << "\n");
|
|
@@ -200,19 +216,23 @@ static void do_test_consumer_lag(bool with_txns) {
|
|
|
200
216
|
Test::conf_set(conf, "group.id", topic);
|
|
201
217
|
Test::conf_set(conf, "enable.auto.commit", "false");
|
|
202
218
|
Test::conf_set(conf, "auto.offset.reset", "earliest");
|
|
203
|
-
Test::conf_set(conf, "statistics.interval.ms", "
|
|
219
|
+
Test::conf_set(conf, "statistics.interval.ms", "500");
|
|
204
220
|
|
|
205
221
|
RdKafka::KafkaConsumer *c = RdKafka::KafkaConsumer::create(conf, errstr);
|
|
206
222
|
if (!c)
|
|
207
223
|
Test::Fail("Failed to create KafkaConsumer: " + errstr);
|
|
208
224
|
delete conf;
|
|
209
225
|
|
|
226
|
+
/* Execute callbacks for statistics enqueued before assignment. */
|
|
227
|
+
c->poll(0);
|
|
228
|
+
|
|
210
229
|
/* Assign partitions */
|
|
211
230
|
std::vector<RdKafka::TopicPartition *> parts;
|
|
212
231
|
parts.push_back(RdKafka::TopicPartition::create(topic, 0));
|
|
213
232
|
if ((err = c->assign(parts)))
|
|
214
233
|
Test::Fail("assign failed: " + RdKafka::err2str(err));
|
|
215
234
|
RdKafka::TopicPartition::destroy(parts);
|
|
235
|
+
stats.partitions_assigned = true;
|
|
216
236
|
|
|
217
237
|
/* Start consuming */
|
|
218
238
|
Test::Say("Consuming topic " + topic + "\n");
|
|
@@ -70,6 +70,9 @@ static void do_test_empty_topic_consumer() {
|
|
|
70
70
|
RdKafka::err2str(err));
|
|
71
71
|
delete md;
|
|
72
72
|
|
|
73
|
+
/* Await propagation to the whole cluster */
|
|
74
|
+
test_wait_topic_exists(consumer->c_ptr(), topic.c_str(), 1 * 1000);
|
|
75
|
+
|
|
73
76
|
/* Start consumer */
|
|
74
77
|
err = consumer->start(rkt, partition, RdKafka::Topic::OFFSET_BEGINNING);
|
|
75
78
|
if (err)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -28,26 +29,11 @@
|
|
|
28
29
|
|
|
29
30
|
#include "test.h"
|
|
30
31
|
|
|
31
|
-
#if WITH_SOCKEM
|
|
32
32
|
#include "rdkafka.h"
|
|
33
|
+
#include "../src/rdkafka_protocol.h"
|
|
33
34
|
|
|
34
35
|
#include <stdarg.h>
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
-
* Force produce requests to timeout to test error handling.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @brief Sockem connect, called from **internal librdkafka thread** through
|
|
42
|
-
* librdkafka's connect_cb
|
|
43
|
-
*/
|
|
44
|
-
static int connect_cb(struct test *test, sockem_t *skm, const char *id) {
|
|
45
|
-
|
|
46
|
-
/* Let delay be high to trigger the local timeout */
|
|
47
|
-
sockem_set(skm, "delay", 10000, NULL);
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
37
|
static int
|
|
52
38
|
is_fatal_cb(rd_kafka_t *rk, rd_kafka_resp_err_t err, const char *reason) {
|
|
53
39
|
/* Ignore connectivity errors since we'll be bringing down
|
|
@@ -95,17 +81,25 @@ int main_0068_produce_timeout(int argc, char **argv) {
|
|
|
95
81
|
rd_kafka_conf_t *conf;
|
|
96
82
|
rd_kafka_topic_t *rkt;
|
|
97
83
|
int msgcounter = 0;
|
|
84
|
+
const char *bootstraps;
|
|
85
|
+
|
|
86
|
+
TEST_SKIP_MOCK_CLUSTER(0);
|
|
87
|
+
|
|
88
|
+
rd_kafka_mock_cluster_t *mcluster =
|
|
89
|
+
test_mock_cluster_new(3, &bootstraps);
|
|
90
|
+
rd_kafka_mock_topic_create(mcluster, topic, 1, 3);
|
|
91
|
+
rd_kafka_mock_partition_set_leader(mcluster, topic, 0, 1);
|
|
98
92
|
|
|
99
93
|
testid = test_id_generate();
|
|
100
94
|
|
|
101
95
|
test_conf_init(&conf, NULL, 60);
|
|
96
|
+
test_conf_set(conf, "bootstrap.servers", bootstraps);
|
|
102
97
|
rd_kafka_conf_set_dr_msg_cb(conf, dr_msg_cb);
|
|
103
98
|
|
|
104
|
-
test_socket_enable(conf);
|
|
105
|
-
test_curr->connect_cb = connect_cb;
|
|
106
99
|
test_curr->is_fatal_cb = is_fatal_cb;
|
|
107
100
|
|
|
108
|
-
rk
|
|
101
|
+
rk = test_create_handle(RD_KAFKA_PRODUCER, conf);
|
|
102
|
+
/* message timeout should be less that rtt */
|
|
109
103
|
rkt = test_create_producer_topic(rk, topic, "message.timeout.ms",
|
|
110
104
|
"2000", NULL);
|
|
111
105
|
|
|
@@ -113,10 +107,13 @@ int main_0068_produce_timeout(int argc, char **argv) {
|
|
|
113
107
|
test_auto_create_topic_rkt(rk, rkt, tmout_multip(5000));
|
|
114
108
|
|
|
115
109
|
TEST_SAY("Producing %d messages that should timeout\n", msgcnt);
|
|
110
|
+
rd_kafka_mock_broker_push_request_error_rtts(
|
|
111
|
+
mcluster, 1, RD_KAFKAP_Produce, 1, RD_KAFKA_RESP_ERR_NO_ERROR,
|
|
112
|
+
6000);
|
|
113
|
+
|
|
116
114
|
test_produce_msgs_nowait(rk, rkt, testid, 0, 0, msgcnt, NULL, 0, 0,
|
|
117
115
|
&msgcounter);
|
|
118
116
|
|
|
119
|
-
|
|
120
117
|
TEST_SAY("Flushing..\n");
|
|
121
118
|
rd_kafka_flush(rk, 10000);
|
|
122
119
|
|
|
@@ -131,8 +128,9 @@ int main_0068_produce_timeout(int argc, char **argv) {
|
|
|
131
128
|
rd_kafka_topic_destroy(rkt);
|
|
132
129
|
rd_kafka_destroy(rk);
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
}
|
|
131
|
+
test_mock_cluster_destroy(mcluster);
|
|
136
132
|
|
|
133
|
+
TEST_LATER_CHECK();
|
|
137
134
|
|
|
138
|
-
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* librdkafka - Apache Kafka C library
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
5
6
|
* All rights reserved.
|
|
6
7
|
*
|
|
7
8
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -58,10 +59,7 @@ static void rebalance_cb(rd_kafka_t *rk,
|
|
|
58
59
|
rd_kafka_err2str(err));
|
|
59
60
|
test_print_partition_list(parts);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
rd_kafka_assign(rk, parts);
|
|
63
|
-
else if (err == RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS)
|
|
64
|
-
rd_kafka_assign(rk, NULL);
|
|
62
|
+
test_rebalance_cb(rk, err, parts, opaque);
|
|
65
63
|
|
|
66
64
|
*statep = err;
|
|
67
65
|
}
|
|
@@ -79,9 +77,7 @@ int main_0069_consumer_add_parts(int argc, char **argv) {
|
|
|
79
77
|
c2 = test_create_consumer(topic, rebalance_cb, NULL, NULL);
|
|
80
78
|
|
|
81
79
|
TEST_SAY("Creating topic %s with 2 partitions\n", topic);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
test_wait_topic_exists(c1, topic, 10 * 1000);
|
|
80
|
+
test_create_topic_wait_exists(c1, topic, 2, 1, 10 * 5000);
|
|
85
81
|
|
|
86
82
|
TEST_SAY("Subscribing\n");
|
|
87
83
|
test_consumer_subscribe(c1, topic);
|