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

ISPN-11050 StreamDistPartitionHandlingTest.testUsingIteratorButPartit… #8026

Merged

Conversation

wburns
Copy link
Member

@wburns wburns commented Mar 10, 2020

…ionOccursAfterRetrievingRemoteValues random failures

https://issues.redhat.com/browse/ISPN-11050

@wburns
Copy link
Member Author

wburns commented Mar 10, 2020

This fixes failures in both testUsingIteratorButPartitionOccursAfterRetrievingRemoteValues and testUsingIteratorButPartitionOccursBeforeRetrievingRemoteValues. The former failed because the remote command may not be processed before the partition happened, thus it would still think it was parititioned (fixed by waiting before completion of publisher instead). The latter failed if the remote command completed before registering the whenComplete on its response thus running the response on the same thread, causing a deadlock (fixed by always waiting on a different thread).

*/
public static <C> C replaceComponentWithSpy(Cache<?,?> cache, Class<C> componentClass) {
C component = TestingUtil.extractComponent(cache, componentClass);
C spiedComponent = spy(component);
Copy link
Member

Choose a reason for hiding this comment

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

If at all possible, I'd rather create a mock that delegates to the existing component instead of using spy().

The instance created by spy() has all the annotations, so after copying the state of the existing component (without any synchronization), the component registry will call start() on the new instance, which may break things.

Of course, using mock() has the opposite problem: the component registry won't call stop() on it, which depending on component may hang the test during shutdown. For this reason I've usually written a custom mock class for the component I'm mocking, but it should be possible to use a generic AbstractMockComponent class that delegates injection/start/stop and then use mock(AbstractMockComponent.class, withSettings.additionalInterfaces(componentClass) to implement the needed interface.

And after writing all of this I realize it's probably too much for this PR, which is merely moving the method...
I'll put it on my TODO list and maybe get to it at some point :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

I personally feel that our components should work fine being stopped and restarted, but that may be just a pipe dream.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could make components restart properly without removing them from the registry and adding a new instance, but that wouldn't really help with spy(), because you're copying a component that has already been started and you're starting it again without calling stop() before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha 👍

…ionOccursAfterRetrievingRemoteValues random failures
@wburns wburns force-pushed the ISPN-11050_stream_part_handling_failures branch from 8c7e061 to 2df96f6 Compare March 12, 2020 18:53
@wburns
Copy link
Member Author

wburns commented Mar 12, 2020

Updated.

@danberindei danberindei merged commit a9314af into infinispan:master Mar 13, 2020
@danberindei
Copy link
Member

Merged, thanks Will!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants