Skip to content

Commit

Permalink
test: fix controller_id
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdreyer committed Jul 16, 2024
1 parent de55014 commit d66f9e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion kafka_consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ PHP_METHOD(RdKafka_KafkaConsumer, getControllerId)
return;
}

intern = get_kafka_object(getThis());
intern = get_object(getThis());
if (!intern) {
return;
}
Expand Down
18 changes: 6 additions & 12 deletions tests/controller_id.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,16 @@ RD_KAFKA_BUILD_VERSION < 0x000b0500 && die("skip librdkafka < 0.11.5");
require __DIR__ . '/integration-tests-check.php';

$conf = new RdKafka\Conf();
if (RD_KAFKA_VERSION >= 0x090000 && false !== getenv('TEST_KAFKA_BROKER_VERSION')) {
$conf->set('broker.version.fallback', getenv('TEST_KAFKA_BROKER_VERSION'));
}
$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));

$conf->setDrMsgCb(function ($rdkafka, $msg) {
var_dump($rdkafka, $msg);
});
echo (new RdKafka\Producer($conf))->getControllerId(0) . \PHP_EOL;
echo (new RdKafka\Consumer($conf))->getControllerId(0) . \PHP_EOL;

$producer = new RdKafka\Producer($conf);
$consumer = new RdKafka\Consumer($conf);
$kafkaConsumer = new RdKafka\KafkaConsumer($conf);
$conf = new RdKafka\Conf();
$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS'));
$conf->set('group.id', 'test');

echo $producer->getControllerId() . \PHP_EOL;
echo $consumer->getControllerId() . \PHP_EOL;
echo $kafkaConsumer->getControllerId() . \PHP_EOL;
echo (new RdKafka\KafkaConsumer($conf))->getControllerId(0) . \PHP_EOL;
--EXPECT--
1
1
Expand Down

0 comments on commit d66f9e3

Please sign in to comment.