You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Ismael Juma <is...@juma.me.uk> on 2018/10/01 03:32:10 UTC

[DISCUSS] Replacing EasyMock with Mockito in Kafka

Hi all,

As described in KAFKA-7438
<https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's development
has stagnated. This presents a number of issues:

1. Blocks us from running tests with newer Java versions, which is a
frequent occurrence give the new Java release cadence. It is the main
blocker in switching Jenkins from Java 10 to Java 11 at the moment.
2. Integration with newer testing libraries like JUnit 5 is slow to appear
(if it appears at all).
3. No API improvements. Mockito started as an EasyMock fork, but has
continued to evolve and, in my opinion, it's more intuitive now.

I think we should switch to Mockito for new tests and to incrementally
migrate the existing ones as time allows. To make the proposal concrete, I
went ahead and converted all the tests in the `clients` module:

https://github.com/apache/kafka/pull/5691

I think the updated tests are nicely readable. I also removed PowerMock
from the `clients` tests as we didn't really need it and its development
has also stagnated a few months ago. I think we can easily remove PowerMock
elsewhere with the exception of `Connect` where we may need to keep it for
a while.

Let me know your thoughts. Aside from the general future direction, I'd
like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
conflicts will creep in quickly.

Ismael

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Ted Yu <yu...@gmail.com>.
+1 to moving to Mockito

On Fri, Oct 5, 2018 at 12:11 PM Ron Dagostino <rn...@gmail.com> wrote:

> I have used Mockito and am a big fan -- I had never used EasyMock until
> recently.  The concept of record vs. replay mode in EasyMock really annoyed
> me -- I'm a fan of the "NO MODES" idea (
> https://en.wikipedia.org/wiki/Larry_Tesler), and when I encountered it in
> EasyMock in the context of Kafka development I just gritted my teeth and
> learned/used it as required.  I'm very pleased that Mockito is being
> seriously considered as a replacement.  Mockito  started as an EasyMock
> fork, I guess, and the project readily admits it is standing on the
> shoulders of giants in many respects, but I think one of the best things
> they ever did was jettison the concept of modes.
>
> +1 from me.
>
> Ron
>
> On Fri, Oct 5, 2018 at 10:00 AM Ismael Juma <is...@juma.me.uk> wrote:
>
> > So far, it seems like people are in favour. If no objections are
> presented
> > in the next couple of days, we will go ahead with the change.
> >
> > Ismael
> >
> > On Sun, 30 Sep 2018, 20:32 Ismael Juma, <is...@juma.me.uk> wrote:
> >
> > > Hi all,
> > >
> > > As described in KAFKA-7438
> > > <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's
> > > development has stagnated. This presents a number of issues:
> > >
> > > 1. Blocks us from running tests with newer Java versions, which is a
> > > frequent occurrence give the new Java release cadence. It is the main
> > > blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> > > 2. Integration with newer testing libraries like JUnit 5 is slow to
> > appear
> > > (if it appears at all).
> > > 3. No API improvements. Mockito started as an EasyMock fork, but has
> > > continued to evolve and, in my opinion, it's more intuitive now.
> > >
> > > I think we should switch to Mockito for new tests and to incrementally
> > > migrate the existing ones as time allows. To make the proposal
> concrete,
> > I
> > > went ahead and converted all the tests in the `clients` module:
> > >
> > > https://github.com/apache/kafka/pull/5691
> > >
> > > I think the updated tests are nicely readable. I also removed PowerMock
> > > from the `clients` tests as we didn't really need it and its
> development
> > > has also stagnated a few months ago. I think we can easily remove
> > PowerMock
> > > elsewhere with the exception of `Connect` where we may need to keep it
> > for
> > > a while.
> > >
> > > Let me know your thoughts. Aside from the general future direction, I'd
> > > like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> > > conflicts will creep in quickly.
> > >
> > > Ismael
> > >
> >
>

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Ismael Juma <is...@gmail.com>.
Agreed, I really liked the fact that Mockito has no "replay" concept.

Ismael

On Fri, 5 Oct 2018, 12:11 Ron Dagostino, <rn...@gmail.com> wrote:

> I have used Mockito and am a big fan -- I had never used EasyMock until
> recently.  The concept of record vs. replay mode in EasyMock really annoyed
> me -- I'm a fan of the "NO MODES" idea (
> https://en.wikipedia.org/wiki/Larry_Tesler), and when I encountered it in
> EasyMock in the context of Kafka development I just gritted my teeth and
> learned/used it as required.  I'm very pleased that Mockito is being
> seriously considered as a replacement.  Mockito  started as an EasyMock
> fork, I guess, and the project readily admits it is standing on the
> shoulders of giants in many respects, but I think one of the best things
> they ever did was jettison the concept of modes.
>
> +1 from me.
>
> Ron
>
> On Fri, Oct 5, 2018 at 10:00 AM Ismael Juma <is...@juma.me.uk> wrote:
>
> > So far, it seems like people are in favour. If no objections are
> presented
> > in the next couple of days, we will go ahead with the change.
> >
> > Ismael
> >
> > On Sun, 30 Sep 2018, 20:32 Ismael Juma, <is...@juma.me.uk> wrote:
> >
> > > Hi all,
> > >
> > > As described in KAFKA-7438
> > > <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's
> > > development has stagnated. This presents a number of issues:
> > >
> > > 1. Blocks us from running tests with newer Java versions, which is a
> > > frequent occurrence give the new Java release cadence. It is the main
> > > blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> > > 2. Integration with newer testing libraries like JUnit 5 is slow to
> > appear
> > > (if it appears at all).
> > > 3. No API improvements. Mockito started as an EasyMock fork, but has
> > > continued to evolve and, in my opinion, it's more intuitive now.
> > >
> > > I think we should switch to Mockito for new tests and to incrementally
> > > migrate the existing ones as time allows. To make the proposal
> concrete,
> > I
> > > went ahead and converted all the tests in the `clients` module:
> > >
> > > https://github.com/apache/kafka/pull/5691
> > >
> > > I think the updated tests are nicely readable. I also removed PowerMock
> > > from the `clients` tests as we didn't really need it and its
> development
> > > has also stagnated a few months ago. I think we can easily remove
> > PowerMock
> > > elsewhere with the exception of `Connect` where we may need to keep it
> > for
> > > a while.
> > >
> > > Let me know your thoughts. Aside from the general future direction, I'd
> > > like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> > > conflicts will creep in quickly.
> > >
> > > Ismael
> > >
> >
>

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Ron Dagostino <rn...@gmail.com>.
I have used Mockito and am a big fan -- I had never used EasyMock until
recently.  The concept of record vs. replay mode in EasyMock really annoyed
me -- I'm a fan of the "NO MODES" idea (
https://en.wikipedia.org/wiki/Larry_Tesler), and when I encountered it in
EasyMock in the context of Kafka development I just gritted my teeth and
learned/used it as required.  I'm very pleased that Mockito is being
seriously considered as a replacement.  Mockito  started as an EasyMock
fork, I guess, and the project readily admits it is standing on the
shoulders of giants in many respects, but I think one of the best things
they ever did was jettison the concept of modes.

+1 from me.

Ron

On Fri, Oct 5, 2018 at 10:00 AM Ismael Juma <is...@juma.me.uk> wrote:

> So far, it seems like people are in favour. If no objections are presented
> in the next couple of days, we will go ahead with the change.
>
> Ismael
>
> On Sun, 30 Sep 2018, 20:32 Ismael Juma, <is...@juma.me.uk> wrote:
>
> > Hi all,
> >
> > As described in KAFKA-7438
> > <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's
> > development has stagnated. This presents a number of issues:
> >
> > 1. Blocks us from running tests with newer Java versions, which is a
> > frequent occurrence give the new Java release cadence. It is the main
> > blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> > 2. Integration with newer testing libraries like JUnit 5 is slow to
> appear
> > (if it appears at all).
> > 3. No API improvements. Mockito started as an EasyMock fork, but has
> > continued to evolve and, in my opinion, it's more intuitive now.
> >
> > I think we should switch to Mockito for new tests and to incrementally
> > migrate the existing ones as time allows. To make the proposal concrete,
> I
> > went ahead and converted all the tests in the `clients` module:
> >
> > https://github.com/apache/kafka/pull/5691
> >
> > I think the updated tests are nicely readable. I also removed PowerMock
> > from the `clients` tests as we didn't really need it and its development
> > has also stagnated a few months ago. I think we can easily remove
> PowerMock
> > elsewhere with the exception of `Connect` where we may need to keep it
> for
> > a while.
> >
> > Let me know your thoughts. Aside from the general future direction, I'd
> > like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> > conflicts will creep in quickly.
> >
> > Ismael
> >
>

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Ismael Juma <is...@juma.me.uk>.
So far, it seems like people are in favour. If no objections are presented
in the next couple of days, we will go ahead with the change.

Ismael

On Sun, 30 Sep 2018, 20:32 Ismael Juma, <is...@juma.me.uk> wrote:

> Hi all,
>
> As described in KAFKA-7438
> <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's
> development has stagnated. This presents a number of issues:
>
> 1. Blocks us from running tests with newer Java versions, which is a
> frequent occurrence give the new Java release cadence. It is the main
> blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> 2. Integration with newer testing libraries like JUnit 5 is slow to appear
> (if it appears at all).
> 3. No API improvements. Mockito started as an EasyMock fork, but has
> continued to evolve and, in my opinion, it's more intuitive now.
>
> I think we should switch to Mockito for new tests and to incrementally
> migrate the existing ones as time allows. To make the proposal concrete, I
> went ahead and converted all the tests in the `clients` module:
>
> https://github.com/apache/kafka/pull/5691
>
> I think the updated tests are nicely readable. I also removed PowerMock
> from the `clients` tests as we didn't really need it and its development
> has also stagnated a few months ago. I think we can easily remove PowerMock
> elsewhere with the exception of `Connect` where we may need to keep it for
> a while.
>
> Let me know your thoughts. Aside from the general future direction, I'd
> like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> conflicts will creep in quickly.
>
> Ismael
>

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Rajini Sivaram <ra...@gmail.com>.
Hi Ismael,

Thanks for starting this discussion. I had a quick look at the PR and I
agree that the updated tests are more readable. So +1 from me.

On Tue, Oct 2, 2018 at 12:06 AM Colin McCabe <cm...@apache.org> wrote:

> +1.  It would be good to standardize on one (well-maintained) mocking
> library in the project :)
>
> best,
> Colin
>
>
> On Sun, Sep 30, 2018, at 20:32, Ismael Juma wrote:
> > Hi all,
> >
> > As described in KAFKA-7438
> > <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's
> development
> > has stagnated. This presents a number of issues:
> >
> > 1. Blocks us from running tests with newer Java versions, which is a
> > frequent occurrence give the new Java release cadence. It is the main
> > blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> > 2. Integration with newer testing libraries like JUnit 5 is slow to
> appear
> > (if it appears at all).
> > 3. No API improvements. Mockito started as an EasyMock fork, but has
> > continued to evolve and, in my opinion, it's more intuitive now.
> >
> > I think we should switch to Mockito for new tests and to incrementally
> > migrate the existing ones as time allows. To make the proposal concrete,
> I
> > went ahead and converted all the tests in the `clients` module:
> >
> > https://github.com/apache/kafka/pull/5691
> >
> > I think the updated tests are nicely readable. I also removed PowerMock
> > from the `clients` tests as we didn't really need it and its development
> > has also stagnated a few months ago. I think we can easily remove
> PowerMock
> > elsewhere with the exception of `Connect` where we may need to keep it
> for
> > a while.
> >
> > Let me know your thoughts. Aside from the general future direction, I'd
> > like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> > conflicts will creep in quickly.
> >
> > Ismael
>

Re: [DISCUSS] Replacing EasyMock with Mockito in Kafka

Posted by Colin McCabe <cm...@apache.org>.
+1.  It would be good to standardize on one (well-maintained) mocking library in the project :)

best,
Colin


On Sun, Sep 30, 2018, at 20:32, Ismael Juma wrote:
> Hi all,
> 
> As described in KAFKA-7438
> <https://issues.apache.org/jira/browse/KAFKA-7438>, EasyMock's development
> has stagnated. This presents a number of issues:
> 
> 1. Blocks us from running tests with newer Java versions, which is a
> frequent occurrence give the new Java release cadence. It is the main
> blocker in switching Jenkins from Java 10 to Java 11 at the moment.
> 2. Integration with newer testing libraries like JUnit 5 is slow to appear
> (if it appears at all).
> 3. No API improvements. Mockito started as an EasyMock fork, but has
> continued to evolve and, in my opinion, it's more intuitive now.
> 
> I think we should switch to Mockito for new tests and to incrementally
> migrate the existing ones as time allows. To make the proposal concrete, I
> went ahead and converted all the tests in the `clients` module:
> 
> https://github.com/apache/kafka/pull/5691
> 
> I think the updated tests are nicely readable. I also removed PowerMock
> from the `clients` tests as we didn't really need it and its development
> has also stagnated a few months ago. I think we can easily remove PowerMock
> elsewhere with the exception of `Connect` where we may need to keep it for
> a while.
> 
> Let me know your thoughts. Aside from the general future direction, I'd
> like to get the PR for KAFKA-7439 reviewed and merged soonish as merge
> conflicts will creep in quickly.
> 
> Ismael