@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.
Files changed (293) hide show
  1. package/README.md +5 -5
  2. package/bench/seed.sh +0 -0
  3. package/binding.gyp +3 -3
  4. package/ci/prepublish.js +4 -3
  5. package/ci/update-version.js +123 -0
  6. package/config.d.ts +126 -10
  7. package/configure +0 -0
  8. package/deps/librdkafka/.semaphore/run-all-tests.yml +77 -0
  9. package/deps/librdkafka/.semaphore/semaphore-integration.yml +250 -0
  10. package/deps/librdkafka/.semaphore/semaphore.yml +67 -44
  11. package/deps/librdkafka/.semaphore/verify-linux-packages.yml +41 -0
  12. package/deps/librdkafka/CHANGELOG.md +471 -1
  13. package/deps/librdkafka/CONFIGURATION.md +29 -9
  14. package/deps/librdkafka/INTRODUCTION.md +909 -601
  15. package/deps/librdkafka/Makefile +2 -1
  16. package/deps/librdkafka/configure +0 -0
  17. package/deps/librdkafka/debian/rules +0 -0
  18. package/deps/librdkafka/dev-conf.sh +0 -0
  19. package/deps/librdkafka/examples/consumer.c +18 -8
  20. package/deps/librdkafka/examples/describe_consumer_groups.c +25 -6
  21. package/deps/librdkafka/examples/incremental_alter_configs.c +4 -5
  22. package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +26 -42
  23. package/deps/librdkafka/examples/openssl_engine_example.cpp +3 -4
  24. package/deps/librdkafka/examples/producer.cpp +2 -2
  25. package/deps/librdkafka/examples/user_scram.c +4 -5
  26. package/deps/librdkafka/examples/win_ssl_cert_store.cpp +4 -3
  27. package/deps/librdkafka/lds-gen.py +0 -0
  28. package/deps/librdkafka/mklove/Makefile.base +0 -0
  29. package/deps/librdkafka/packaging/RELEASE.md +8 -0
  30. package/deps/librdkafka/packaging/alpine/build-alpine.sh +0 -0
  31. package/deps/librdkafka/packaging/cp/README.md +4 -1
  32. package/deps/librdkafka/packaging/cp/check_features.c +12 -4
  33. package/deps/librdkafka/packaging/cp/verify-deb.sh +6 -6
  34. package/deps/librdkafka/packaging/cp/verify-packages.sh +52 -31
  35. package/deps/librdkafka/packaging/cp/verify-rpm.sh +6 -13
  36. package/deps/librdkafka/packaging/debian/docs +5 -0
  37. package/deps/librdkafka/packaging/debian/rules +0 -0
  38. package/deps/librdkafka/packaging/get_version.py +0 -0
  39. package/deps/librdkafka/packaging/homebrew/brew-update-pr.sh +0 -0
  40. package/deps/librdkafka/packaging/mingw-w64/{travis-before-install.sh → export-variables.sh} +0 -7
  41. package/deps/librdkafka/packaging/mingw-w64/semaphoreci-build.sh +1 -1
  42. package/deps/librdkafka/packaging/nuget/artifact.py +0 -0
  43. package/deps/librdkafka/packaging/nuget/cleanup-s3.py +0 -0
  44. package/deps/librdkafka/packaging/nuget/nuget.sh +0 -0
  45. package/deps/librdkafka/packaging/nuget/packaging.py +0 -0
  46. package/deps/librdkafka/packaging/nuget/push-to-nuget.sh +0 -0
  47. package/deps/librdkafka/packaging/nuget/release.py +0 -0
  48. package/deps/librdkafka/packaging/nuget/requirements.txt +3 -3
  49. package/deps/librdkafka/packaging/rpm/mock-on-docker.sh +0 -0
  50. package/deps/librdkafka/packaging/rpm/tests/run-test.sh +0 -0
  51. package/deps/librdkafka/packaging/rpm/tests/test-on-docker.sh +0 -0
  52. package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +3 -1
  53. package/deps/librdkafka/packaging/tools/build-deb-package.sh +0 -0
  54. package/deps/librdkafka/packaging/tools/build-debian.sh +0 -0
  55. package/deps/librdkafka/packaging/tools/build-manylinux.sh +0 -0
  56. package/deps/librdkafka/packaging/tools/build-release-artifacts.sh +0 -0
  57. package/deps/librdkafka/packaging/tools/distro-build.sh +0 -0
  58. package/deps/librdkafka/packaging/tools/gh-release-checksums.py +0 -0
  59. package/deps/librdkafka/packaging/tools/rdutcoverage.sh +0 -0
  60. package/deps/librdkafka/packaging/tools/run-in-docker.sh +28 -0
  61. package/deps/librdkafka/packaging/tools/run-integration-tests.sh +31 -0
  62. package/deps/librdkafka/packaging/tools/run-style-check.sh +4 -0
  63. package/deps/librdkafka/packaging/tools/style-format.sh +6 -5
  64. package/deps/librdkafka/packaging/tools/update_rpcs_max_versions.py +100 -0
  65. package/deps/librdkafka/service.yml +154 -0
  66. package/deps/librdkafka/src/generate_proto.sh +0 -0
  67. package/deps/librdkafka/src/rd.h +145 -2
  68. package/deps/librdkafka/src/rdaddr.h +6 -7
  69. package/deps/librdkafka/src/rdatomic.h +15 -11
  70. package/deps/librdkafka/src/rdavg.h +3 -2
  71. package/deps/librdkafka/src/rdbase64.c +33 -2
  72. package/deps/librdkafka/src/rdbase64.h +2 -0
  73. package/deps/librdkafka/src/rdendian.h +10 -9
  74. package/deps/librdkafka/src/rdhttp.c +418 -100
  75. package/deps/librdkafka/src/rdhttp.h +23 -5
  76. package/deps/librdkafka/src/rdkafka.c +299 -145
  77. package/deps/librdkafka/src/rdkafka.h +89 -6
  78. package/deps/librdkafka/src/rdkafka_admin.c +482 -105
  79. package/deps/librdkafka/src/rdkafka_admin.h +42 -0
  80. package/deps/librdkafka/src/rdkafka_broker.c +463 -312
  81. package/deps/librdkafka/src/rdkafka_broker.h +68 -10
  82. package/deps/librdkafka/src/rdkafka_buf.c +8 -5
  83. package/deps/librdkafka/src/rdkafka_buf.h +4 -3
  84. package/deps/librdkafka/src/rdkafka_cert.c +25 -1
  85. package/deps/librdkafka/src/rdkafka_cert.h +4 -3
  86. package/deps/librdkafka/src/rdkafka_cgrp.c +468 -143
  87. package/deps/librdkafka/src/rdkafka_cgrp.h +36 -2
  88. package/deps/librdkafka/src/rdkafka_conf.c +526 -102
  89. package/deps/librdkafka/src/rdkafka_conf.h +68 -4
  90. package/deps/librdkafka/src/rdkafka_feature.c +472 -35
  91. package/deps/librdkafka/src/rdkafka_feature.h +2 -0
  92. package/deps/librdkafka/src/rdkafka_fetcher.c +22 -2
  93. package/deps/librdkafka/src/rdkafka_fetcher.h +2 -2
  94. package/deps/librdkafka/src/rdkafka_int.h +84 -46
  95. package/deps/librdkafka/src/rdkafka_metadata.c +221 -136
  96. package/deps/librdkafka/src/rdkafka_metadata.h +15 -11
  97. package/deps/librdkafka/src/rdkafka_metadata_cache.c +279 -73
  98. package/deps/librdkafka/src/rdkafka_mock.c +795 -19
  99. package/deps/librdkafka/src/rdkafka_mock.h +119 -0
  100. package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1298 -132
  101. package/deps/librdkafka/src/rdkafka_mock_handlers.c +345 -49
  102. package/deps/librdkafka/src/rdkafka_mock_int.h +180 -61
  103. package/deps/librdkafka/src/rdkafka_msg.c +35 -19
  104. package/deps/librdkafka/src/rdkafka_msg.h +3 -3
  105. package/deps/librdkafka/src/rdkafka_msgset_writer.c +14 -10
  106. package/deps/librdkafka/src/rdkafka_offset.c +33 -5
  107. package/deps/librdkafka/src/rdkafka_op.c +1 -1
  108. package/deps/librdkafka/src/rdkafka_op.h +45 -21
  109. package/deps/librdkafka/src/rdkafka_partition.c +118 -23
  110. package/deps/librdkafka/src/rdkafka_partition.h +16 -7
  111. package/deps/librdkafka/src/rdkafka_proto.h +4 -1
  112. package/deps/librdkafka/src/rdkafka_protocol.h +1 -0
  113. package/deps/librdkafka/src/rdkafka_queue.c +125 -48
  114. package/deps/librdkafka/src/rdkafka_queue.h +19 -0
  115. package/deps/librdkafka/src/rdkafka_range_assignor.c +1 -1
  116. package/deps/librdkafka/src/rdkafka_request.c +336 -64
  117. package/deps/librdkafka/src/rdkafka_request.h +24 -1
  118. package/deps/librdkafka/src/rdkafka_sasl.c +5 -3
  119. package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +14 -10
  120. package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1166 -89
  121. package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +13 -3
  122. package/deps/librdkafka/src/rdkafka_sasl_plain.c +3 -3
  123. package/deps/librdkafka/src/rdkafka_sasl_scram.c +4 -3
  124. package/deps/librdkafka/src/rdkafka_ssl.c +306 -81
  125. package/deps/librdkafka/src/rdkafka_ssl.h +22 -0
  126. package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4 -0
  127. package/deps/librdkafka/src/rdkafka_telemetry.c +80 -23
  128. package/deps/librdkafka/src/rdkafka_telemetry_encode.c +5 -1
  129. package/deps/librdkafka/src/rdkafka_telemetry_encode.h +20 -20
  130. package/deps/librdkafka/src/rdkafka_topic.c +220 -137
  131. package/deps/librdkafka/src/rdkafka_topic.h +14 -8
  132. package/deps/librdkafka/src/rdkafka_transport.c +59 -47
  133. package/deps/librdkafka/src/rdkafka_transport.h +5 -0
  134. package/deps/librdkafka/src/rdkafka_txnmgr.c +6 -1
  135. package/deps/librdkafka/src/rdmap.c +6 -1
  136. package/deps/librdkafka/src/rdrand.c +11 -1
  137. package/deps/librdkafka/src/rdtime.h +48 -17
  138. package/deps/librdkafka/src/rdunittest.c +42 -25
  139. package/deps/librdkafka/src/rdunittest.h +2 -0
  140. package/deps/librdkafka/src/rdwin32.h +1 -1
  141. package/deps/librdkafka/src/regexp.c +47 -42
  142. package/deps/librdkafka/src/tinycthread_extra.c +45 -21
  143. package/deps/librdkafka/src/tinycthread_extra.h +7 -3
  144. package/deps/librdkafka/src-cpp/rdkafkacpp.h +28 -2
  145. package/deps/librdkafka/tests/0001-multiobj.c +4 -0
  146. package/deps/librdkafka/tests/0004-conf.c +103 -36
  147. package/deps/librdkafka/tests/0009-mock_cluster.c +1 -0
  148. package/deps/librdkafka/tests/0011-produce_batch.c +2 -1
  149. package/deps/librdkafka/tests/0016-client_swname.c +18 -3
  150. package/deps/librdkafka/tests/0017-compression.c +6 -8
  151. package/deps/librdkafka/tests/0018-cgrp_term.c +8 -3
  152. package/deps/librdkafka/tests/0021-rkt_destroy.c +1 -0
  153. package/deps/librdkafka/tests/0022-consume_batch.c +4 -1
  154. package/deps/librdkafka/tests/0026-consume_pause.c +12 -14
  155. package/deps/librdkafka/tests/0028-long_topicnames.c +1 -1
  156. package/deps/librdkafka/tests/0029-assign_offset.c +6 -8
  157. package/deps/librdkafka/tests/0030-offset_commit.c +2 -2
  158. package/deps/librdkafka/tests/0033-regex_subscribe.c +33 -17
  159. package/deps/librdkafka/tests/0034-offset_reset.c +25 -4
  160. package/deps/librdkafka/tests/0036-partial_fetch.c +1 -0
  161. package/deps/librdkafka/tests/0038-performance.c +1 -0
  162. package/deps/librdkafka/tests/0040-io_event.c +11 -5
  163. package/deps/librdkafka/tests/0041-fetch_max_bytes.c +1 -0
  164. package/deps/librdkafka/tests/0044-partition_cnt.c +3 -2
  165. package/deps/librdkafka/tests/0045-subscribe_update.c +284 -20
  166. package/deps/librdkafka/tests/0047-partial_buf_tmout.c +1 -0
  167. package/deps/librdkafka/tests/0048-partitioner.c +1 -1
  168. package/deps/librdkafka/tests/0050-subscribe_adds.c +1 -0
  169. package/deps/librdkafka/tests/0051-assign_adds.c +1 -0
  170. package/deps/librdkafka/tests/0052-msg_timestamps.c +22 -4
  171. package/deps/librdkafka/tests/0053-stats_cb.cpp +12 -20
  172. package/deps/librdkafka/tests/0055-producer_latency.c +176 -3
  173. package/deps/librdkafka/tests/0056-balanced_group_mt.c +6 -2
  174. package/deps/librdkafka/tests/0058-log.cpp +3 -3
  175. package/deps/librdkafka/tests/0059-bsearch.cpp +8 -4
  176. package/deps/librdkafka/tests/0061-consumer_lag.cpp +25 -5
  177. package/deps/librdkafka/tests/0067-empty_topic.cpp +3 -0
  178. package/deps/librdkafka/tests/0068-produce_timeout.c +21 -23
  179. package/deps/librdkafka/tests/0069-consumer_add_parts.c +3 -7
  180. package/deps/librdkafka/tests/0075-retry.c +38 -1
  181. package/deps/librdkafka/tests/0076-produce_retry.c +2 -0
  182. package/deps/librdkafka/tests/0077-compaction.c +8 -2
  183. package/deps/librdkafka/tests/0080-admin_ut.c +34 -4
  184. package/deps/librdkafka/tests/0081-admin.c +455 -155
  185. package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +4 -0
  186. package/deps/librdkafka/tests/0083-cb_event.c +8 -3
  187. package/deps/librdkafka/tests/0084-destroy_flags.c +14 -18
  188. package/deps/librdkafka/tests/0085-headers.cpp +4 -0
  189. package/deps/librdkafka/tests/0086-purge.c +40 -7
  190. package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +1 -1
  191. package/deps/librdkafka/tests/0089-max_poll_interval.c +12 -7
  192. package/deps/librdkafka/tests/0090-idempotence.c +1 -2
  193. package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +5 -7
  194. package/deps/librdkafka/tests/0092-mixed_msgver.c +6 -0
  195. package/deps/librdkafka/tests/0093-holb.c +8 -5
  196. package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +1 -0
  197. package/deps/librdkafka/tests/0097-ssl_verify.cpp +262 -70
  198. package/deps/librdkafka/tests/0098-consumer-txn.cpp +16 -16
  199. package/deps/librdkafka/tests/0099-commit_metadata.c +1 -1
  200. package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +1 -1
  201. package/deps/librdkafka/tests/0102-static_group_rebalance.c +317 -16
  202. package/deps/librdkafka/tests/0103-transactions.c +7 -7
  203. package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +1 -0
  204. package/deps/librdkafka/tests/0105-transactions_mock.c +18 -11
  205. package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +35 -14
  206. package/deps/librdkafka/tests/0107-topic_recreate.c +2 -2
  207. package/deps/librdkafka/tests/0109-auto_create_topics.cpp +86 -26
  208. package/deps/librdkafka/tests/0110-batch_size.cpp +1 -2
  209. package/deps/librdkafka/tests/0112-assign_unknown_part.c +3 -14
  210. package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +248 -104
  211. package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +3 -3
  212. package/deps/librdkafka/tests/0115-producer_auth.cpp +4 -1
  213. package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +7 -5
  214. package/deps/librdkafka/tests/0117-mock_errors.c +15 -5
  215. package/deps/librdkafka/tests/0118-commit_rebalance.c +41 -8
  216. package/deps/librdkafka/tests/0119-consumer_auth.cpp +20 -1
  217. package/deps/librdkafka/tests/0120-asymmetric_subscription.c +8 -3
  218. package/deps/librdkafka/tests/0125-immediate_flush.c +1 -1
  219. package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +323 -8
  220. package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +1 -0
  221. package/deps/librdkafka/tests/0132-strategy_ordering.c +12 -4
  222. package/deps/librdkafka/tests/0133-ssl_keys.c +28 -6
  223. package/deps/librdkafka/tests/0137-barrier_batch_consume.c +24 -14
  224. package/deps/librdkafka/tests/0139-offset_validation_mock.c +510 -2
  225. package/deps/librdkafka/tests/0140-commit_metadata.cpp +1 -1
  226. package/deps/librdkafka/tests/0142-reauthentication.c +37 -17
  227. package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +39 -40
  228. package/deps/librdkafka/tests/0146-metadata_mock.c +76 -15
  229. package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +952 -0
  230. package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +563 -0
  231. package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
  232. package/deps/librdkafka/tests/0150-telemetry_mock.c +9 -6
  233. package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
  234. package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
  235. package/deps/librdkafka/tests/0153-memberid.c +128 -0
  236. package/deps/librdkafka/tests/CMakeLists.txt +6 -0
  237. package/deps/librdkafka/tests/LibrdkafkaTestApp.py +34 -9
  238. package/deps/librdkafka/tests/autotest.sh +0 -0
  239. package/deps/librdkafka/tests/broker_version_tests.py +0 -0
  240. package/deps/librdkafka/tests/buildbox.sh +0 -0
  241. package/deps/librdkafka/tests/cleanup-checker-tests.sh +0 -0
  242. package/deps/librdkafka/tests/cluster_testing.py +0 -0
  243. package/deps/librdkafka/tests/delete-test-topics.sh +0 -0
  244. package/deps/librdkafka/tests/fixtures/oauthbearer/jwt_assertion_template.json +10 -0
  245. package/deps/librdkafka/tests/fixtures/ssl/client.keystore.intermediate.p12 +0 -0
  246. package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
  247. package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
  248. package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +42 -101
  249. package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
  250. package/deps/librdkafka/tests/fixtures/ssl/client2.key +41 -29
  251. package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +112 -37
  252. package/deps/librdkafka/tests/gen-ssl-certs.sh +0 -0
  253. package/deps/librdkafka/tests/interactive_broker_version.py +0 -0
  254. package/deps/librdkafka/tests/java/Makefile +2 -1
  255. package/deps/librdkafka/tests/java/run-class.sh +0 -0
  256. package/deps/librdkafka/tests/lz4_manual_test.sh +0 -0
  257. package/deps/librdkafka/tests/multi-broker-version-test.sh +0 -0
  258. package/deps/librdkafka/tests/parse-refcnt.sh +0 -0
  259. package/deps/librdkafka/tests/performance_plot.py +0 -0
  260. package/deps/librdkafka/tests/requirements.txt +1 -1
  261. package/deps/librdkafka/tests/run-all-tests.sh +79 -0
  262. package/deps/librdkafka/tests/run-consumer-tests.sh +0 -0
  263. package/deps/librdkafka/tests/run-producer-tests.sh +0 -0
  264. package/deps/librdkafka/tests/run-test-batches.py +157 -0
  265. package/deps/librdkafka/tests/run-test.sh +0 -0
  266. package/deps/librdkafka/tests/sasl_test.py +0 -0
  267. package/deps/librdkafka/tests/test.c +478 -18
  268. package/deps/librdkafka/tests/test.h +62 -13
  269. package/deps/librdkafka/tests/testcpp.cpp +6 -1
  270. package/deps/librdkafka/tests/testcpp.h +30 -2
  271. package/deps/librdkafka/tests/testshared.h +16 -2
  272. package/deps/librdkafka/tests/tools/stats/graph.py +0 -0
  273. package/deps/librdkafka/tests/tools/stats/to_csv.py +1 -1
  274. package/deps/librdkafka/tests/trivup/trivup-0.14.0.tar.gz +0 -0
  275. package/deps/librdkafka/tests/until-fail.sh +0 -0
  276. package/deps/librdkafka/tests/xxxx-metadata.cpp +1 -1
  277. package/deps/librdkafka/vcpkg.json +1 -1
  278. package/deps/librdkafka/win32/setup-msys2.ps1 +24 -8
  279. package/deps/librdkafka/win32/setup-vcpkg.ps1 +28 -6
  280. package/deps/librdkafka/win32/tests/tests.vcxproj +6 -0
  281. package/deps/librdkafka/win32/wingetopt.h +5 -4
  282. package/errors.d.ts +27 -1
  283. package/lib/error.js +29 -3
  284. package/make_docs.sh +0 -0
  285. package/package.json +12 -13
  286. package/run_docker.sh +0 -0
  287. package/src/callbacks.cc +6 -9
  288. package/src/callbacks.h +1 -5
  289. package/test/kafka-consumer-worker.js +10 -7
  290. package/test/kafka-consumer.spec.js +32 -21
  291. package/deps/librdkafka/.semaphore/project.yml +0 -43
  292. package/deps/librdkafka/.semaphore/project_public.yml +0 -20
  293. package/deps/librdkafka/win32/install-openssl.ps1 +0 -33
@@ -2,6 +2,7 @@
2
2
  * librdkafka - Apache Kafka C library
3
3
  *
4
4
  * Copyright (c) 2020-2022, Magnus Edenhill
5
+ * 2023, Confluent Inc.
5
6
  * All rights reserved.
6
7
  *
7
8
  * Redistribution and use in source and binary forms, with or without
@@ -58,9 +59,11 @@ class Toppar {
58
59
  }
59
60
 
60
61
  friend bool operator<(const Toppar &a, const Toppar &b) {
61
- if (a.partition < b.partition)
62
+ if (a.topic < b.topic)
62
63
  return true;
63
- return a.topic < b.topic;
64
+ if (a.topic > b.topic)
65
+ return false;
66
+ return a.partition < b.partition;
64
67
  }
65
68
 
66
69
  string str() const {
@@ -930,7 +933,8 @@ static void b_subscribe_with_cb_test(rd_bool_t close_consumer) {
930
933
  /* Failure case: test will time out. */
931
934
  if (Test::assignment_partition_count(c1, NULL) == 1 &&
932
935
  Test::assignment_partition_count(c2, NULL) == 1) {
933
- if (test_consumer_group_protocol_generic() &&
936
+ /* Callback count can vary in KIP-848 */
937
+ if (test_consumer_group_protocol_classic() &&
934
938
  !(rebalance_cb1.assign_call_cnt == expected_cb1_assign_call_cnt &&
935
939
  rebalance_cb2.assign_call_cnt == expected_cb2_assign_call_cnt))
936
940
  continue;
@@ -956,7 +960,8 @@ static void b_subscribe_with_cb_test(rd_bool_t close_consumer) {
956
960
  * triggered.
957
961
  */
958
962
 
959
- if (test_consumer_group_protocol_generic()) {
963
+ /* Callback count can vary in KIP-848 */
964
+ if (test_consumer_group_protocol_classic()) {
960
965
  /* The rebalance cb is always called on assign, even if empty. */
961
966
  if (rebalance_cb1.assign_call_cnt != expected_cb1_assign_call_cnt)
962
967
  Test::Fail(tostr() << "Expecting " << expected_cb1_assign_call_cnt
@@ -1029,7 +1034,8 @@ static void b_subscribe_with_cb_test(rd_bool_t close_consumer) {
1029
1034
  c1->close();
1030
1035
  c2->close();
1031
1036
 
1032
- if (test_consumer_group_protocol_generic()) {
1037
+ /* Callback count can vary in KIP-848 */
1038
+ if (test_consumer_group_protocol_classic()) {
1033
1039
  /* Closing the consumer should trigger rebalance_cb (revoke): */
1034
1040
  if (rebalance_cb1.revoke_call_cnt != 2)
1035
1041
  Test::Fail(tostr() << "Expecting 2 revoke calls on consumer 1, not: "
@@ -1405,6 +1411,13 @@ class GTestRebalanceCb : public RdKafka::RebalanceCb {
1405
1411
  static void g_incremental_assign_call_eager() {
1406
1412
  SUB_TEST();
1407
1413
 
1414
+ /* Only classic consumer group protocol supports EAGER protocol*/
1415
+ if (!test_consumer_group_protocol_classic()) {
1416
+ SUB_TEST_SKIP(
1417
+ "Skipping incremental assign call eager test as EAGER protocol is only "
1418
+ "supported in `classic` consumer group protocol");
1419
+ }
1420
+
1408
1421
  std::string topic_name = Test::mk_topic_name("0113-cooperative_rebalance", 1);
1409
1422
  test_create_topic(NULL, topic_name.c_str(), 1, 1);
1410
1423
 
@@ -1473,7 +1486,8 @@ static void h_delete_topic() {
1473
1486
  c->assignment(partitions);
1474
1487
 
1475
1488
  if (partitions.size() == 2 && !deleted) {
1476
- if (test_consumer_group_protocol_generic() &&
1489
+ /* Callback count can vary in KIP-848 */
1490
+ if (test_consumer_group_protocol_classic() &&
1477
1491
  rebalance_cb.assign_call_cnt != 1)
1478
1492
  Test::Fail(tostr() << "Expected 1 assign call, saw "
1479
1493
  << rebalance_cb.assign_call_cnt << "\n");
@@ -1537,7 +1551,8 @@ static void i_delete_topic_2() {
1537
1551
  Test::poll_once(c, 500);
1538
1552
 
1539
1553
  if (Test::assignment_partition_count(c, NULL) == 1 && !deleted) {
1540
- if (test_consumer_group_protocol_generic() &&
1554
+ /* Callback count can vary in KIP-848 */
1555
+ if (test_consumer_group_protocol_classic() &&
1541
1556
  rebalance_cb.assign_call_cnt != 1)
1542
1557
  Test::Fail(tostr() << "Expected one assign call, saw "
1543
1558
  << rebalance_cb.assign_call_cnt << "\n");
@@ -1644,7 +1659,8 @@ static void k_add_partition() {
1644
1659
  Test::poll_once(c, 500);
1645
1660
 
1646
1661
  if (Test::assignment_partition_count(c, NULL) == 1 && !subscribed) {
1647
- if (test_consumer_group_protocol_generic()) {
1662
+ /* Callback count can vary in KIP-848 */
1663
+ if (test_consumer_group_protocol_classic()) {
1648
1664
  if (rebalance_cb.assign_call_cnt != 1)
1649
1665
  Test::Fail(tostr() << "Expected 1 assign call, saw "
1650
1666
  << rebalance_cb.assign_call_cnt);
@@ -1657,7 +1673,8 @@ static void k_add_partition() {
1657
1673
  }
1658
1674
 
1659
1675
  if (Test::assignment_partition_count(c, NULL) == 2 && subscribed) {
1660
- if (test_consumer_group_protocol_generic()) {
1676
+ /* Callback count can vary in KIP-848 */
1677
+ if (test_consumer_group_protocol_classic()) {
1661
1678
  if (rebalance_cb.assign_call_cnt != 2)
1662
1679
  Test::Fail(tostr() << "Expected 2 assign calls, saw "
1663
1680
  << rebalance_cb.assign_call_cnt);
@@ -1673,7 +1690,8 @@ static void k_add_partition() {
1673
1690
  c->close();
1674
1691
  delete c;
1675
1692
 
1676
- if (test_consumer_group_protocol_generic()) {
1693
+ /* Callback count can vary in KIP-848 */
1694
+ if (test_consumer_group_protocol_classic()) {
1677
1695
  if (rebalance_cb.assign_call_cnt != 2)
1678
1696
  Test::Fail(tostr() << "Expected 2 assign calls, saw "
1679
1697
  << rebalance_cb.assign_call_cnt);
@@ -1730,7 +1748,8 @@ static void l_unsubscribe() {
1730
1748
 
1731
1749
  if (Test::assignment_partition_count(c1, NULL) == 2 &&
1732
1750
  Test::assignment_partition_count(c2, NULL) == 2) {
1733
- if (test_consumer_group_protocol_generic()) {
1751
+ /* Callback count can vary in KIP-848 */
1752
+ if (test_consumer_group_protocol_classic()) {
1734
1753
  if (rebalance_cb1.assign_call_cnt != expected_cb1_assign_call_cnt)
1735
1754
  Test::Fail(tostr() << "Expecting consumer 1's assign_call_cnt to be "
1736
1755
  << expected_cb1_assign_call_cnt
@@ -1748,7 +1767,8 @@ static void l_unsubscribe() {
1748
1767
 
1749
1768
  if (unsubscribed && Test::assignment_partition_count(c1, NULL) == 0 &&
1750
1769
  Test::assignment_partition_count(c2, NULL) == 4) {
1751
- if (test_consumer_group_protocol_generic()) {
1770
+ /* Callback count can vary in KIP-848 */
1771
+ if (test_consumer_group_protocol_classic()) {
1752
1772
  if (rebalance_cb1.assign_call_cnt != expected_cb1_assign_call_cnt)
1753
1773
  /* is now unsubscribed, so rebalance_cb will no longer be called. */
1754
1774
  Test::Fail(tostr() << "Expecting consumer 1's assign_call_cnt to be "
@@ -1779,7 +1799,8 @@ static void l_unsubscribe() {
1779
1799
  Test::Say("Closing consumer 2\n");
1780
1800
  c2->close();
1781
1801
 
1782
- if (test_consumer_group_protocol_generic()) {
1802
+ /* Callback count can vary in KIP-848 */
1803
+ if (test_consumer_group_protocol_classic()) {
1783
1804
  /* there should be no assign rebalance_cb calls on close */
1784
1805
  if (rebalance_cb1.assign_call_cnt != expected_cb1_assign_call_cnt)
1785
1806
  Test::Fail(tostr() << "Expecting consumer 1's assign_call_cnt to be "
@@ -1899,22 +1920,19 @@ static void n_wildcard() {
1899
1920
  Test::poll_once(c1, 500);
1900
1921
  Test::poll_once(c2, 500);
1901
1922
 
1902
- if (test_consumer_group_protocol_generic()) {
1903
- if (rebalance_cb1.assign_call_cnt != 0)
1904
- Test::Fail(
1905
- tostr() << "Expecting consumer 1's assign_call_cnt to be 0 not: "
1906
- << rebalance_cb1.assign_call_cnt);
1907
- if (rebalance_cb2.assign_call_cnt != 0)
1908
- Test::Fail(
1909
- tostr() << "Expecting consumer 2's assign_call_cnt to be 0 not: "
1910
- << rebalance_cb2.assign_call_cnt);
1911
- }
1923
+ if (rebalance_cb1.assign_call_cnt != 0)
1924
+ Test::Fail(tostr() << "Expecting consumer 1's assign_call_cnt to be 0 not: "
1925
+ << rebalance_cb1.assign_call_cnt);
1926
+ if (rebalance_cb2.assign_call_cnt != 0)
1927
+ Test::Fail(tostr() << "Expecting consumer 2's assign_call_cnt to be 0 not: "
1928
+ << rebalance_cb2.assign_call_cnt);
1912
1929
 
1913
1930
  bool done = false;
1914
1931
  bool created_topics = false;
1915
1932
  bool deleted_topic = false;
1916
1933
  int last_cb1_assign_call_cnt = 0;
1917
1934
  int last_cb2_assign_call_cnt = 0;
1935
+ int expected_lost_cnt = 0;
1918
1936
  while (!done) {
1919
1937
  Test::poll_once(c1, 500);
1920
1938
  Test::poll_once(c2, 500);
@@ -1925,6 +1943,8 @@ static void n_wildcard() {
1925
1943
  "Creating two topics with 2 partitions each that match regex\n");
1926
1944
  test_create_topic(NULL, topic_name_1.c_str(), 2, 1);
1927
1945
  test_create_topic(NULL, topic_name_2.c_str(), 2, 1);
1946
+ test_wait_topic_exists(NULL, topic_name_1.c_str(), 5000);
1947
+ test_wait_topic_exists(NULL, topic_name_2.c_str(), 5000);
1928
1948
  /* The consumers should autonomously discover these topics and start
1929
1949
  * consuming from them. This happens in the background - is not
1930
1950
  * influenced by whether we wait for the topics to be created before
@@ -1974,22 +1994,26 @@ static void n_wildcard() {
1974
1994
 
1975
1995
  if (Test::assignment_partition_count(c1, NULL) == 1 &&
1976
1996
  Test::assignment_partition_count(c2, NULL) == 1 && deleted_topic) {
1977
- if (test_consumer_group_protocol_generic()) {
1978
- /* accumulated in lost case as well */
1979
- TEST_ASSERT(rebalance_cb1.revoke_call_cnt == 1,
1980
- "Expecting C_1's revoke_call_cnt to be 1 not %d",
1981
- rebalance_cb1.revoke_call_cnt);
1982
- TEST_ASSERT(rebalance_cb2.revoke_call_cnt == 1,
1983
- "Expecting C_2's revoke_call_cnt to be 1 not %d",
1984
- rebalance_cb2.revoke_call_cnt);
1997
+ /* accumulated in lost case as well for the classic protocol*/
1998
+ TEST_ASSERT(rebalance_cb1.revoke_call_cnt == 1,
1999
+ "Expecting C_1's revoke_call_cnt to be 1 not %d",
2000
+ rebalance_cb1.revoke_call_cnt);
2001
+ TEST_ASSERT(rebalance_cb2.revoke_call_cnt == 1,
2002
+ "Expecting C_2's revoke_call_cnt to be 1 not %d",
2003
+ rebalance_cb2.revoke_call_cnt);
2004
+
2005
+ /* Deleted topics are not counted as lost in KIP-848.
2006
+ * Assignment changes are propogated through ConsumerGroupHeartbeat. */
2007
+ if (test_consumer_group_protocol_classic()) {
2008
+ expected_lost_cnt++;
1985
2009
  }
1986
2010
 
1987
- TEST_ASSERT(rebalance_cb1.lost_call_cnt == 1,
1988
- "Expecting C_1's lost_call_cnt to be 1 not %d",
1989
- rebalance_cb1.lost_call_cnt);
1990
- TEST_ASSERT(rebalance_cb2.lost_call_cnt == 1,
1991
- "Expecting C_2's lost_call_cnt to be 1 not %d",
1992
- rebalance_cb2.lost_call_cnt);
2011
+ TEST_ASSERT(rebalance_cb1.lost_call_cnt == expected_lost_cnt,
2012
+ "Expecting C_1's lost_call_cnt to be %d not %d",
2013
+ expected_lost_cnt, rebalance_cb1.lost_call_cnt);
2014
+ TEST_ASSERT(rebalance_cb2.lost_call_cnt == expected_lost_cnt,
2015
+ "Expecting C_2's lost_call_cnt to be %d not %d",
2016
+ expected_lost_cnt, rebalance_cb2.lost_call_cnt);
1993
2017
 
1994
2018
  /* Consumers will rejoin group after revoking the lost partitions.
1995
2019
  * this will result in an rebalance_cb assign (empty partitions).
@@ -2011,12 +2035,10 @@ static void n_wildcard() {
2011
2035
  last_cb1_assign_call_cnt = rebalance_cb1.assign_call_cnt;
2012
2036
  c1->close();
2013
2037
 
2014
- if (test_consumer_group_protocol_generic()) {
2015
- /* There should be no assign rebalance_cb calls on close */
2016
- TEST_ASSERT(rebalance_cb1.assign_call_cnt == last_cb1_assign_call_cnt,
2017
- "Expecting C_1's assign_call_cnt to be %d not %d",
2018
- last_cb1_assign_call_cnt, rebalance_cb1.assign_call_cnt);
2019
- }
2038
+ /* There should be no assign rebalance_cb calls on close */
2039
+ TEST_ASSERT(rebalance_cb1.assign_call_cnt == last_cb1_assign_call_cnt,
2040
+ "Expecting C_1's assign_call_cnt to be %d not %d",
2041
+ last_cb1_assign_call_cnt, rebalance_cb1.assign_call_cnt);
2020
2042
 
2021
2043
  /* Let C_2 catch up on the rebalance and get assigned C_1's partitions. */
2022
2044
  last_cb2_assign_call_cnt = rebalance_cb2.nonempty_assign_call_cnt;
@@ -2027,26 +2049,24 @@ static void n_wildcard() {
2027
2049
  last_cb2_assign_call_cnt = rebalance_cb2.assign_call_cnt;
2028
2050
  c2->close();
2029
2051
 
2030
- if (test_consumer_group_protocol_generic()) {
2031
- /* There should be no assign rebalance_cb calls on close */
2032
- TEST_ASSERT(rebalance_cb2.assign_call_cnt == last_cb2_assign_call_cnt,
2033
- "Expecting C_2's assign_call_cnt to be %d not %d",
2034
- last_cb2_assign_call_cnt, rebalance_cb2.assign_call_cnt);
2035
-
2036
- TEST_ASSERT(rebalance_cb1.revoke_call_cnt == 2,
2037
- "Expecting C_1's revoke_call_cnt to be 2 not %d",
2038
- rebalance_cb1.revoke_call_cnt);
2039
- TEST_ASSERT(rebalance_cb2.revoke_call_cnt == 2,
2040
- "Expecting C_2's revoke_call_cnt to be 2 not %d",
2041
- rebalance_cb2.revoke_call_cnt);
2042
- }
2043
-
2044
- TEST_ASSERT(rebalance_cb1.lost_call_cnt == 1,
2045
- "Expecting C_1's lost_call_cnt to be 1, not %d",
2046
- rebalance_cb1.lost_call_cnt);
2047
- TEST_ASSERT(rebalance_cb2.lost_call_cnt == 1,
2048
- "Expecting C_2's lost_call_cnt to be 1, not %d",
2049
- rebalance_cb2.lost_call_cnt);
2052
+ /* There should be no assign rebalance_cb calls on close */
2053
+ TEST_ASSERT(rebalance_cb2.assign_call_cnt == last_cb2_assign_call_cnt,
2054
+ "Expecting C_2's assign_call_cnt to be %d not %d",
2055
+ last_cb2_assign_call_cnt, rebalance_cb2.assign_call_cnt);
2056
+
2057
+ TEST_ASSERT(rebalance_cb1.revoke_call_cnt == 2,
2058
+ "Expecting C_1's revoke_call_cnt to be 2 not %d",
2059
+ rebalance_cb1.revoke_call_cnt);
2060
+ TEST_ASSERT(rebalance_cb2.revoke_call_cnt == 2,
2061
+ "Expecting C_2's revoke_call_cnt to be 2 not %d",
2062
+ rebalance_cb2.revoke_call_cnt);
2063
+
2064
+ TEST_ASSERT(rebalance_cb1.lost_call_cnt == expected_lost_cnt,
2065
+ "Expecting C_1's lost_call_cnt to be %d, not %d",
2066
+ expected_lost_cnt, rebalance_cb1.lost_call_cnt);
2067
+ TEST_ASSERT(rebalance_cb2.lost_call_cnt == expected_lost_cnt,
2068
+ "Expecting C_2's lost_call_cnt to be %d, not %d",
2069
+ expected_lost_cnt, rebalance_cb2.lost_call_cnt);
2050
2070
 
2051
2071
  delete c1;
2052
2072
  delete c2;
@@ -2119,7 +2139,8 @@ static void o_java_interop() {
2119
2139
 
2120
2140
  if (Test::assignment_partition_count(c, NULL) == 4 && java_pid != 0 &&
2121
2141
  !changed_subscription) {
2122
- if (test_consumer_group_protocol_generic() &&
2142
+ /* Callback count can vary in KIP-848 */
2143
+ if (test_consumer_group_protocol_classic() &&
2123
2144
  rebalance_cb.assign_call_cnt != 2)
2124
2145
  Test::Fail(tostr() << "Expecting consumer's assign_call_cnt to be 2, "
2125
2146
  "not "
@@ -2320,7 +2341,8 @@ static void t_max_poll_interval_exceeded(int variation) {
2320
2341
  << expected_cb1_lost_call_cnt
2321
2342
  << ", not: " << rebalance_cb1.lost_call_cnt);
2322
2343
 
2323
- if (test_consumer_group_protocol_generic()) {
2344
+ /* Callback count can vary in KIP-848 */
2345
+ if (test_consumer_group_protocol_classic()) {
2324
2346
  if (rebalance_cb1.nonempty_assign_call_cnt != expected_cb1_assign_call_cnt)
2325
2347
  Test::Fail(tostr() << "Expected consumer 1 non-empty assign count to be "
2326
2348
  << expected_cb1_assign_call_cnt << ", not: "
@@ -2608,9 +2630,9 @@ static void u_multiple_subscription_changes(bool use_rebalance_cb,
2608
2630
  /* Verify consumer assignments */
2609
2631
  int counts[N_CONSUMERS];
2610
2632
  map<Toppar, RdKafka::KafkaConsumer *> all_assignments;
2611
- Test::Say(tostr() << "Consumer assignments "
2612
- << "(subscription_variation " << subscription_variation
2613
- << ")" << (stabilized ? " (stabilized)" : "")
2633
+ Test::Say(tostr() << "Consumer assignments " << "(subscription_variation "
2634
+ << subscription_variation << ")"
2635
+ << (stabilized ? " (stabilized)" : "")
2614
2636
  << (use_rebalance_cb ? " (use_rebalance_cb)"
2615
2637
  : " (no rebalance cb)")
2616
2638
  << ":\n");
@@ -2657,9 +2679,8 @@ static void u_multiple_subscription_changes(bool use_rebalance_cb,
2657
2679
  Test::Say(tostr() << (counts[i] == exp_parts ? "" : _C_YEL) << "Consumer "
2658
2680
  << consumers[i]->name() << " has " << counts[i]
2659
2681
  << " assigned partitions (" << consumer_topics[i].size()
2660
- << " subscribed topic(s))"
2661
- << ", expecting " << exp_parts
2662
- << " assigned partitions\n");
2682
+ << " subscribed topic(s))" << ", expecting "
2683
+ << exp_parts << " assigned partitions\n");
2663
2684
 
2664
2685
  if (counts[i] != exp_parts)
2665
2686
  done = false;
@@ -2674,8 +2695,13 @@ static void u_multiple_subscription_changes(bool use_rebalance_cb,
2674
2695
 
2675
2696
  Test::Say("Disposing consumers\n");
2676
2697
  for (int i = 0; i < N_CONSUMERS; i++) {
2677
- TEST_ASSERT(!use_rebalance_cb || !rebalance_cbs[i].wait_rebalance,
2678
- "Consumer %d still waiting for rebalance", i);
2698
+ /* A consumer will not necessarily get a rebalance after a
2699
+ * subscription change with the consumer protocol */
2700
+ if (test_consumer_group_protocol_classic()) {
2701
+ TEST_ASSERT(!use_rebalance_cb || !rebalance_cbs[i].wait_rebalance,
2702
+ "Consumer %d still waiting for rebalance", i);
2703
+ }
2704
+
2679
2705
  if (i & 1)
2680
2706
  consumers[i]->close();
2681
2707
  delete consumers[i];
@@ -2801,18 +2827,28 @@ static void p_lost_partitions_heartbeat_illegal_generation_test() {
2801
2827
  RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS,
2802
2828
  rd_false /*don't expect lost*/, 5 + 2);
2803
2829
 
2804
- /* Fail heartbeats */
2805
- rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_Heartbeat, 5,
2806
- RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2807
- RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2808
- RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2809
- RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2810
- RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION);
2830
+ if (test_consumer_group_protocol_classic()) {
2831
+ /* Fail heartbeats */
2832
+ rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_Heartbeat, 5,
2833
+ RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2834
+ RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2835
+ RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2836
+ RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
2837
+ RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION);
2838
+ } else {
2839
+ /* Fail heartbeats */
2840
+ rd_kafka_mock_broker_push_request_error_rtts(
2841
+ mcluster, 1, RD_KAFKAP_ConsumerGroupHeartbeat, 2,
2842
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH, 0, RD_KAFKA_RESP_ERR_NO_ERROR,
2843
+ 1000);
2844
+ }
2811
2845
 
2812
2846
  expect_rebalance("lost partitions", c, RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS,
2813
2847
  rd_true /*expect lost*/, 10 + 2);
2814
2848
 
2815
2849
  rd_kafka_mock_clear_request_errors(mcluster, RD_KAFKAP_Heartbeat);
2850
+ rd_kafka_mock_clear_request_errors(mcluster,
2851
+ RD_KAFKAP_ConsumerGroupHeartbeat);
2816
2852
 
2817
2853
  expect_rebalance("rejoin after lost", c, RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS,
2818
2854
  rd_false /*don't expect lost*/, 10 + 2);
@@ -2994,6 +3030,78 @@ static void r_lost_partitions_commit_illegal_generation_test_local() {
2994
3030
  test_mock_cluster_destroy(mcluster);
2995
3031
  }
2996
3032
 
3033
+ /* Check commit is retried on FENCED_MEMBER_EPOCH, using new epoch taken
3034
+ * from HB. */
3035
+ static void t_consumer_group_consumer_retry_commit_on_fenced_member_epoch() {
3036
+ const char *bootstraps;
3037
+ rd_kafka_mock_cluster_t *mcluster;
3038
+ const char *groupid = "mygroup";
3039
+ const char *topic = "test";
3040
+ const int msgcnt = 100;
3041
+ rd_kafka_t *c;
3042
+ rd_kafka_conf_t *conf;
3043
+ rd_kafka_topic_partition_list_t *rktpars =
3044
+ rd_kafka_topic_partition_list_new(1);
3045
+
3046
+ SUB_TEST();
3047
+
3048
+ mcluster = test_mock_cluster_new(3, &bootstraps);
3049
+
3050
+ rd_kafka_mock_coordinator_set(mcluster, "group", groupid, 1);
3051
+
3052
+ /* Seed the topic with messages */
3053
+ test_produce_msgs_easy_v(topic, 0, 0, 0, msgcnt, 10, "bootstrap.servers",
3054
+ bootstraps, "batch.num.messages", "10",
3055
+ "security.protocol", "plaintext", NULL);
3056
+
3057
+ test_conf_init(&conf, NULL, 30);
3058
+ test_conf_set(conf, "bootstrap.servers", bootstraps);
3059
+ test_conf_set(conf, "security.protocol", "PLAINTEXT");
3060
+ test_conf_set(conf, "group.id", groupid);
3061
+ test_conf_set(conf, "auto.offset.reset", "earliest");
3062
+ test_conf_set(conf, "enable.auto.commit", "false");
3063
+ test_conf_set(conf, "partition.assignment.strategy", "cooperative-sticky");
3064
+
3065
+ c = test_create_consumer(groupid, rebalance_cb, conf, NULL);
3066
+
3067
+ test_consumer_subscribe(c, topic);
3068
+
3069
+ expect_rebalance("initial assignment", c,
3070
+ RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS,
3071
+ rd_false /*don't expect lost*/, 5 + 2);
3072
+
3073
+
3074
+ /* Consume some messages so that the commit has something to commit. */
3075
+ test_consumer_poll("consume", c, -1, -1, -1, msgcnt / 2, NULL);
3076
+
3077
+ /* Fail Commit */
3078
+ rd_kafka_mock_push_request_errors(mcluster, RD_KAFKAP_OffsetCommit, 5,
3079
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH,
3080
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH,
3081
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH,
3082
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH,
3083
+ RD_KAFKA_RESP_ERR_FENCED_MEMBER_EPOCH);
3084
+
3085
+ rd_kafka_commit(c, NULL, rd_false);
3086
+
3087
+ TEST_CALL_ERR__(rd_kafka_committed(c, rktpars, 2000));
3088
+
3089
+ /* Offsets should be committed with retries */
3090
+ TEST_ASSERT(rktpars->cnt == 1);
3091
+ TEST_ASSERT(rktpars->elems[0].offset == msgcnt / 2);
3092
+
3093
+ rd_kafka_topic_partition_list_destroy(rktpars);
3094
+
3095
+ TEST_SAY("Closing consumer\n");
3096
+ test_consumer_close(c);
3097
+
3098
+ TEST_SAY("Destroying consumer\n");
3099
+ rd_kafka_destroy(c);
3100
+
3101
+ TEST_SAY("Destroying mock cluster\n");
3102
+ test_mock_cluster_destroy(mcluster);
3103
+ }
3104
+
2997
3105
  /**
2998
3106
  * @brief Test that the consumer is destroyed without segfault if
2999
3107
  * it happens before first rebalance and there is no assignor
@@ -3064,8 +3172,11 @@ static void v_rebalance_cb(rd_kafka_t *rk,
3064
3172
  if (err == RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS) {
3065
3173
  test_consumer_incremental_assign("assign", rk, parts);
3066
3174
  } else {
3067
- test_consumer_incremental_unassign("unassign", rk, parts);
3068
-
3175
+ TEST_ASSERT(!rd_kafka_assignment_lost(rk),
3176
+ "Assignment must not be lost, "
3177
+ " that is a sign that an ILLEGAL_GENERATION error, "
3178
+ " during a commit happening during a rebalance is "
3179
+ "causing the assignment to be lost.");
3069
3180
  if (!*auto_commitp) {
3070
3181
  rd_kafka_resp_err_t commit_err;
3071
3182
 
@@ -3074,10 +3185,14 @@ static void v_rebalance_cb(rd_kafka_t *rk,
3074
3185
  rd_sleep(2);
3075
3186
  commit_err = rd_kafka_commit(rk, NULL, 0 /*sync*/);
3076
3187
  TEST_ASSERT(!commit_err || commit_err == RD_KAFKA_RESP_ERR__NO_OFFSET ||
3077
- commit_err == RD_KAFKA_RESP_ERR__DESTROY,
3188
+ commit_err == RD_KAFKA_RESP_ERR__DESTROY ||
3189
+ commit_err == RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
3078
3190
  "%s: manual commit failed: %s", rd_kafka_name(rk),
3079
3191
  rd_kafka_err2str(commit_err));
3080
3192
  }
3193
+
3194
+ /* Unassign must be done after manual commit. */
3195
+ test_consumer_incremental_unassign("unassign", rk, parts);
3081
3196
  }
3082
3197
  }
3083
3198
 
@@ -3091,11 +3206,23 @@ static void v_commit_cb(rd_kafka_t *rk,
3091
3206
  TEST_SAY("%s offset commit for %d offsets: %s\n", rd_kafka_name(rk),
3092
3207
  offsets ? offsets->cnt : -1, rd_kafka_err2name(err));
3093
3208
  TEST_ASSERT(!err || err == RD_KAFKA_RESP_ERR__NO_OFFSET ||
3209
+ err == RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION ||
3094
3210
  err == RD_KAFKA_RESP_ERR__DESTROY /* consumer was closed */,
3095
3211
  "%s offset commit failed: %s", rd_kafka_name(rk),
3096
3212
  rd_kafka_err2str(err));
3097
3213
  }
3098
3214
 
3215
+ /**
3216
+ * @brief Log callback for the v_.. test.
3217
+ */
3218
+ static void v_log_cb(const rd_kafka_t *rk,
3219
+ int level,
3220
+ const char *fac,
3221
+ const char *buf) {
3222
+ /* Slow down logging to make ILLEGAL_GENERATION errors caused by
3223
+ * manual commit more likely. */
3224
+ rd_usleep(1000, 0);
3225
+ }
3099
3226
 
3100
3227
  static void v_commit_during_rebalance(bool with_rebalance_cb,
3101
3228
  bool auto_commit) {
@@ -3120,9 +3247,7 @@ static void v_commit_during_rebalance(bool with_rebalance_cb,
3120
3247
  */
3121
3248
  p = test_create_producer();
3122
3249
 
3123
- test_create_topic(p, topic, partition_cnt, 1);
3124
-
3125
- test_wait_topic_exists(p, topic, 5000);
3250
+ test_create_topic_wait_exists(p, topic, partition_cnt, 1, 5000);
3126
3251
 
3127
3252
  for (i = 0; i < partition_cnt; i++) {
3128
3253
  test_produce_msgs2(p, topic, testid, i, i * msgcnt_per_partition,
@@ -3135,8 +3260,13 @@ static void v_commit_during_rebalance(bool with_rebalance_cb,
3135
3260
 
3136
3261
 
3137
3262
  test_conf_set(conf, "auto.offset.reset", "earliest");
3263
+ test_conf_set(conf, "debug", "consumer,cgrp,topic,fetch");
3138
3264
  test_conf_set(conf, "enable.auto.commit", auto_commit ? "true" : "false");
3139
3265
  test_conf_set(conf, "partition.assignment.strategy", "cooperative-sticky");
3266
+ if (!auto_commit)
3267
+ /* Slowing down logging is necessary only to make assignment lost
3268
+ * errors more evident. */
3269
+ rd_kafka_conf_set_log_cb(conf, v_log_cb);
3140
3270
  rd_kafka_conf_set_offset_commit_cb(conf, v_commit_cb);
3141
3271
  rd_kafka_conf_set_opaque(conf, (void *)&auto_commit);
3142
3272
 
@@ -3161,8 +3291,20 @@ static void v_commit_during_rebalance(bool with_rebalance_cb,
3161
3291
 
3162
3292
  /* Poll both consumers */
3163
3293
  for (i = 0; i < 10; i++) {
3164
- test_consumer_poll_once(c1, NULL, 1000);
3165
- test_consumer_poll_once(c2, NULL, 1000);
3294
+ int poll_result1, poll_result2;
3295
+ do {
3296
+ poll_result1 = test_consumer_poll_once(c1, NULL, 1000);
3297
+ poll_result2 = test_consumer_poll_once(c2, NULL, 1000);
3298
+
3299
+ if (poll_result1 == 1 && !auto_commit) {
3300
+ rd_kafka_resp_err_t err;
3301
+ TEST_SAY("Attempting manual commit after poll\n");
3302
+ err = rd_kafka_commit(c1, NULL, 0);
3303
+ TEST_ASSERT(!err || err == RD_KAFKA_RESP_ERR_ILLEGAL_GENERATION,
3304
+ "Expected not error or ILLEGAL_GENERATION, got: %s",
3305
+ rd_kafka_err2str(err));
3306
+ }
3307
+ } while (poll_result1 == 0 || poll_result2 == 0);
3166
3308
  }
3167
3309
 
3168
3310
  TEST_SAY("Closing consumers\n");
@@ -3189,7 +3331,7 @@ static void x_incremental_rebalances(void) {
3189
3331
  SUB_TEST();
3190
3332
  test_conf_init(&conf, NULL, 60);
3191
3333
 
3192
- test_create_topic(NULL, topic, 6, 1);
3334
+ test_create_topic_wait_exists(NULL, topic, 6, 1, 5000);
3193
3335
 
3194
3336
  test_conf_set(conf, "partition.assignment.strategy", "cooperative-sticky");
3195
3337
  for (i = 0; i < _NUM_CONS; i++) {
@@ -3215,7 +3357,7 @@ static void x_incremental_rebalances(void) {
3215
3357
  test_consumer_subscribe(c[1], topic);
3216
3358
  test_consumer_wait_assignment(c[1], rd_true /*poll*/);
3217
3359
  rd_sleep(3);
3218
- if (test_consumer_group_protocol_generic()) {
3360
+ if (test_consumer_group_protocol_classic()) {
3219
3361
  test_consumer_verify_assignment(c[0], rd_false /*fail later*/, topic, 3,
3220
3362
  topic, 4, topic, 5, NULL);
3221
3363
  test_consumer_verify_assignment(c[1], rd_false /*fail later*/, topic, 0,
@@ -3232,7 +3374,7 @@ static void x_incremental_rebalances(void) {
3232
3374
  test_consumer_subscribe(c[2], topic);
3233
3375
  test_consumer_wait_assignment(c[2], rd_true /*poll*/);
3234
3376
  rd_sleep(3);
3235
- if (test_consumer_group_protocol_generic()) {
3377
+ if (test_consumer_group_protocol_classic()) {
3236
3378
  test_consumer_verify_assignment(c[0], rd_false /*fail later*/, topic, 4,
3237
3379
  topic, 5, NULL);
3238
3380
  test_consumer_verify_assignment(c[1], rd_false /*fail later*/, topic, 1,
@@ -3265,9 +3407,18 @@ int main_0113_cooperative_rebalance_local(int argc, char **argv) {
3265
3407
 
3266
3408
  a_assign_rapid();
3267
3409
  p_lost_partitions_heartbeat_illegal_generation_test();
3268
- q_lost_partitions_illegal_generation_test(rd_false /*joingroup*/);
3269
- q_lost_partitions_illegal_generation_test(rd_true /*syncgroup*/);
3270
- r_lost_partitions_commit_illegal_generation_test_local();
3410
+ if (test_consumer_group_protocol_classic()) {
3411
+ /* These tests have no correspondence with
3412
+ * the consumer group protocol "consumer" */
3413
+ q_lost_partitions_illegal_generation_test(rd_false /*joingroup*/);
3414
+ q_lost_partitions_illegal_generation_test(rd_true /*syncgroup*/);
3415
+ }
3416
+ if (test_consumer_group_protocol_classic()) {
3417
+ r_lost_partitions_commit_illegal_generation_test_local();
3418
+ } else if (0) {
3419
+ /* FIXME: enable this once new errors are handled in OffsetCommit. */
3420
+ t_consumer_group_consumer_retry_commit_on_fenced_member_epoch();
3421
+ }
3271
3422
  s_no_segfault_before_first_rebalance();
3272
3423
  return 0;
3273
3424
  }
@@ -3298,10 +3449,7 @@ int main_0113_cooperative_rebalance(int argc, char **argv) {
3298
3449
  k_add_partition();
3299
3450
  l_unsubscribe();
3300
3451
  m_unsubscribe_2();
3301
- if (test_consumer_group_protocol_generic()) {
3302
- /* FIXME: should work with next ConsumerGroupHeartbeat version */
3303
- n_wildcard();
3304
- }
3452
+ n_wildcard();
3305
3453
  o_java_interop();
3306
3454
  for (i = 1; i <= 6; i++) /* iterate over 6 different test variations */
3307
3455
  s_subscribe_when_rebalancing(i);
@@ -3309,12 +3457,8 @@ int main_0113_cooperative_rebalance(int argc, char **argv) {
3309
3457
  t_max_poll_interval_exceeded(i);
3310
3458
  /* Run all 2*3 variations of the u_.. test */
3311
3459
  for (i = 0; i < 3; i++) {
3312
- if (test_consumer_group_protocol_generic()) {
3313
- /* FIXME: check this test, it should fail because of the callback number
3314
- */
3315
- u_multiple_subscription_changes(true /*with rebalance_cb*/, i);
3316
- u_multiple_subscription_changes(false /*without rebalance_cb*/, i);
3317
- }
3460
+ u_multiple_subscription_changes(true /*with rebalance_cb*/, i);
3461
+ u_multiple_subscription_changes(false /*without rebalance_cb*/, i);
3318
3462
  }
3319
3463
  v_commit_during_rebalance(true /*with rebalance callback*/,
3320
3464
  true /*auto commit*/);
@@ -44,7 +44,7 @@
44
44
  */
45
45
  static void do_test_sticky_partitioning(int sticky_delay) {
46
46
  std::string topic = Test::mk_topic_name(__FILE__, 1);
47
- Test::create_topic(NULL, topic.c_str(), 3, 1);
47
+ Test::create_topic_wait_exists(NULL, topic.c_str(), 3, 1, 5000);
48
48
 
49
49
  RdKafka::Conf *conf;
50
50
  Test::conf_init(&conf, NULL, 0);
@@ -148,8 +148,8 @@ static void do_test_sticky_partitioning(int sticky_delay) {
148
148
  /* When sticky.partitioning.linger.ms is long (greater than expected
149
149
  * length of run), one partition should be sticky and receive messages. */
150
150
  if (sticky_delay == 5000 && num_partitions_active > 1)
151
- Test::Fail(tostr() << "Expected only 1 partition to receive msgs"
152
- << " but " << num_partitions_active
151
+ Test::Fail(tostr() << "Expected only 1 partition to receive msgs" << " but "
152
+ << num_partitions_active
153
153
  << " partitions received msgs.");
154
154
 
155
155
  /* When sticky.partitioning.linger.ms is short (sufficiently smaller than