You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Andy Chambers <ac...@gmail.com> on 2016/09/10 21:01:06 UTC

MockClientSupplier

Hi,

The MockClientSupplier looks like it would be useful for developers wishing
to write unit tests for kafka streams apps. Is it public? If so, can
someone help me out with the maven coordinates. Currently depending on
these maven coordinates

  [org.apache.kafka/kafka-streams "0.10.0.1"]
  [org.apache.kafka/kafka-clients "0.10.0.1"]
  [org.apache.kafka/kafka_2.11 "0.10.0.1"]

but none seem to include the class org.apache.kafka.test.MockClientSupplier

Cheers,
Andy

Re: MockClientSupplier

Posted by Guozhang Wang <wa...@gmail.com>.
Hello Andy,

You can just call KafkaStreams.toString(). I'm copying its java doc string
here:

"Produces a string representation contain useful information about Kafka
Streams

* Such as thread IDs, task IDs and a representation of the topology.
This is useful

* in debugging scenarios."


Guozhang


On Mon, Sep 12, 2016 at 2:56 AM, Andy Chambers <ac...@gmail.com>
wrote:

> Thanks Guozhang,
>
> Actually on inspection, the MockClientSupplier itself seems easy enough to
> replicate. But now I have a question about the MockConsumer. I expected to
> be able to use the MockConsumer to simulate input events but when I try to
> add a record, I get:
>
>    Cannot add records for a partition that is not assigned to the
>    consumer
>
> I'd have thought the app under test would have caused the mock consumer to
> subscribe to the input topic. I tried to verify this without even producing
> a record by checking the "subscription" method of the mock consumer but
> that returns an empty set even after the app streams have been started.
>
> Is there any way to inspect the topology of a streams app? I think that's
> what I'd really like to test. The transformations/aggregations themselves
> are obviously easier to test independently of kafka. It might be nice to
> just check they are all glued together correctly.
>
> Cheers,
> Andy
>
>
>
> On Sun, Sep 11, 2016 at 8:56 PM, Guozhang Wang <wa...@gmail.com> wrote:
>
> > Hello Andy,
> >
> > Unfortunately the included package `o.a.k.test` is not included in the
> > released maven.
> >
> > There are some discussions about moving these test fixtures into public
> > packages:
> >
> > https://issues.apache.org/jira/browse/KAFKA-3625
> >
> > Guozhang
> >
> > On Sat, Sep 10, 2016 at 2:01 PM, Andy Chambers <achambers.home@gmail.com
> >
> > wrote:
> >
> > > Hi,
> > >
> > > The MockClientSupplier looks like it would be useful for developers
> > wishing
> > > to write unit tests for kafka streams apps. Is it public? If so, can
> > > someone help me out with the maven coordinates. Currently depending on
> > > these maven coordinates
> > >
> > >   [org.apache.kafka/kafka-streams "0.10.0.1"]
> > >   [org.apache.kafka/kafka-clients "0.10.0.1"]
> > >   [org.apache.kafka/kafka_2.11 "0.10.0.1"]
> > >
> > > but none seem to include the class org.apache.kafka.test.
> > > MockClientSupplier
> > >
> > > Cheers,
> > > Andy
> > >
> >
> >
> >
> > --
> > -- Guozhang
> >
>



-- 
-- Guozhang

Re: MockClientSupplier

Posted by Andy Chambers <ac...@gmail.com>.
Thanks Guozhang,

Actually on inspection, the MockClientSupplier itself seems easy enough to
replicate. But now I have a question about the MockConsumer. I expected to
be able to use the MockConsumer to simulate input events but when I try to
add a record, I get:

   Cannot add records for a partition that is not assigned to the
   consumer

I'd have thought the app under test would have caused the mock consumer to
subscribe to the input topic. I tried to verify this without even producing
a record by checking the "subscription" method of the mock consumer but
that returns an empty set even after the app streams have been started.

Is there any way to inspect the topology of a streams app? I think that's
what I'd really like to test. The transformations/aggregations themselves
are obviously easier to test independently of kafka. It might be nice to
just check they are all glued together correctly.

Cheers,
Andy



On Sun, Sep 11, 2016 at 8:56 PM, Guozhang Wang <wa...@gmail.com> wrote:

> Hello Andy,
>
> Unfortunately the included package `o.a.k.test` is not included in the
> released maven.
>
> There are some discussions about moving these test fixtures into public
> packages:
>
> https://issues.apache.org/jira/browse/KAFKA-3625
>
> Guozhang
>
> On Sat, Sep 10, 2016 at 2:01 PM, Andy Chambers <ac...@gmail.com>
> wrote:
>
> > Hi,
> >
> > The MockClientSupplier looks like it would be useful for developers
> wishing
> > to write unit tests for kafka streams apps. Is it public? If so, can
> > someone help me out with the maven coordinates. Currently depending on
> > these maven coordinates
> >
> >   [org.apache.kafka/kafka-streams "0.10.0.1"]
> >   [org.apache.kafka/kafka-clients "0.10.0.1"]
> >   [org.apache.kafka/kafka_2.11 "0.10.0.1"]
> >
> > but none seem to include the class org.apache.kafka.test.
> > MockClientSupplier
> >
> > Cheers,
> > Andy
> >
>
>
>
> --
> -- Guozhang
>

Re: MockClientSupplier

Posted by Guozhang Wang <wa...@gmail.com>.
Hello Andy,

Unfortunately the included package `o.a.k.test` is not included in the
released maven.

There are some discussions about moving these test fixtures into public
packages:

https://issues.apache.org/jira/browse/KAFKA-3625

Guozhang

On Sat, Sep 10, 2016 at 2:01 PM, Andy Chambers <ac...@gmail.com>
wrote:

> Hi,
>
> The MockClientSupplier looks like it would be useful for developers wishing
> to write unit tests for kafka streams apps. Is it public? If so, can
> someone help me out with the maven coordinates. Currently depending on
> these maven coordinates
>
>   [org.apache.kafka/kafka-streams "0.10.0.1"]
>   [org.apache.kafka/kafka-clients "0.10.0.1"]
>   [org.apache.kafka/kafka_2.11 "0.10.0.1"]
>
> but none seem to include the class org.apache.kafka.test.
> MockClientSupplier
>
> Cheers,
> Andy
>



-- 
-- Guozhang