rust-rdkafka icon indicating copy to clipboard operation
rust-rdkafka copied to clipboard

WIP: Mock cluster support

Open GregBowyer opened this issue 2 years ago • 6 comments

This is an attempt to expose the mock cluster somewhat directly. This allows for control over the mock cluster, giving end users the ability to alter behaviors for a degree of fault injection.

I fully expect the APIs to change, and I am probably not quite maintaining the full style of the project.

GregBowyer avatar May 02 '22 23:05 GregBowyer

Ping?

GregBowyer avatar May 25 '22 22:05 GregBowyer

I was just looking into adding support for mocking and found your PR.

Would you be willing to add support for rd_kafka_handle_mock_cluster() too? That seems to be the easiest way to me to use mocking, without much code modification in an existing app, ie:

  1. set test.mock.num.brokers to some number
  2. obtain the mock cluster with rd_kafka_handle_mock_cluster()
  3. get the bootstrap servers from the mock cluster with rd_kafka_mock_cluster_bootstraps()
  4. configure a counterpart producer/consumer to the app being tested

Probably this would be added on the Client type, ie. something like

fn Client::mock_cluster<'s>(&'s self) -> Option<MockCluster<'s>>;

which is annoying*, because your existing MockCluster is an owning type... ~~Maybe something similar to PathBuf and Path<'_> could be done where PathBuf dereferences to &Path?~~ edit: that probably can't be done... Feel free to LMK what you think...

EDIT: *) because rd_kafka_handle_mock_cluster() returns a pointer to a mock cluster that is (presumably) owned by that rd_kafka_t ...

vojtechkral avatar May 29 '22 14:05 vojtechkral

@GregBowyer here's a proposal: https://github.com/ticketmaster/rust-rdkafka/pull/1

vojtechkral avatar May 30 '22 12:05 vojtechkral

ping

vojtechkral avatar Jun 28 '22 10:06 vojtechkral

@vojtechkral did add your pr into the mix, it seems sensible

GregBowyer avatar Jul 26 '22 22:07 GregBowyer

@GregBowyer yes, thank you very much! I was meaning to ping the maintainer... but they're probably pretty busy...

vojtechkral avatar Jul 27 '22 09:07 vojtechkral

I'm afraid I'm not going to have time to look at this, but I'm 👍🏽 on adding it. Perhaps one of the other maintainers will be able to take a look.

benesch avatar Nov 13 '22 03:11 benesch

Closed in favor of https://github.com/fede1024/rust-rdkafka/pull/583 .

davidblewett avatar Jun 07 '23 21:06 davidblewett