Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][test] remove WhiteBox on MockZooKeeper #17579

Merged
merged 1 commit into from
Sep 11, 2022

Conversation

tisonkun
Copy link
Member

@tisonkun tisonkun commented Sep 10, 2022

Master issue #16912

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 10, 2022
MockZooKeeper zk = createMockZooKeeperInstance(executor, readOpDelayMs);
ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());
return zk;
return createMockZooKeeperInstance(executor, readOpDelayMs);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli this change was added by you in #8590. I don't know why we need this WhiteBox based mock and after removing it and running several tests, it seems all green.

Could you share some background here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the older versions of Mockito or other mock frameworks needed it

@tisonkun
Copy link
Member Author

/pulsarbot run-failure-checks

@tisonkun tisonkun marked this pull request as ready for review September 11, 2022 00:48
@tisonkun tisonkun changed the title [improve][test] try remove whitebox on MockZooKeeper [improve][test] remove whitebox on MockZooKeeper Sep 11, 2022
@tisonkun tisonkun changed the title [improve][test] remove whitebox on MockZooKeeper [improve][test] remove WhiteBox on MockZooKeeper Sep 11, 2022
@tisonkun
Copy link
Member Author

cc @shoothzj @nicoloboschi

It's interesting that no test failed after remove the lines:

            ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
            Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());

I suppose that since the MockZooKeeper already mockup the interface, no caller will access cnxn field and thus it's unnecessary. However, it would be nice if the original author @eolivelli can give more background :)

MockZooKeeper zk = createMockZooKeeperInstance(executor, readOpDelayMs);
ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());
return zk;
return createMockZooKeeperInstance(executor, readOpDelayMs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the older versions of Mockito or other mock frameworks needed it

@eolivelli eolivelli merged commit c1434fd into apache:master Sep 11, 2022
@tisonkun tisonkun deleted the reduce-whitebox branch September 11, 2022 13:14
tisonkun added a commit to tisonkun/pulsar that referenced this pull request Sep 14, 2022
liangyepianzhou pushed a commit that referenced this pull request Dec 13, 2022
liangyepianzhou added a commit that referenced this pull request Dec 13, 2022
liangyepianzhou added a commit that referenced this pull request Dec 13, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 10, 2023
(cherry picked from commit c1434fd)
(cherry picked from commit f303a91)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 10, 2023
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 10, 2023
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 11, 2023
(cherry picked from commit c1434fd)
(cherry picked from commit f303a91)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 11, 2023
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jan 11, 2023
@Technoboy- Technoboy- added this to the 3.0.0 milestone Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants