Skip to content

KAFKA-8006: Guard calls to init and close from global processor#6353

Merged
mjsax merged 2 commits intoapache:trunkfrom
ableegoldman:GuardGlobalStoreMethods
Mar 6, 2019
Merged

KAFKA-8006: Guard calls to init and close from global processor#6353
mjsax merged 2 commits intoapache:trunkfrom
ableegoldman:GuardGlobalStoreMethods

Conversation

@ableegoldman
Copy link
Copy Markdown
Member

Guards against users calling init() and close() on global stores accessed via global processor

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ableegoldman
Copy link
Copy Markdown
Member Author

@bbejeck bbejeck added the streams label Mar 1, 2019
@bbejeck bbejeck requested review from guozhangwang and mjsax March 1, 2019 23:27
Copy link
Copy Markdown
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

Overall LGTM. One nit for the unit tests.


@Test(expected = UnsupportedOperationException.class)
public void shouldNotAllowInit() {
globalContext.getStateStore(GLOBAL_STORE_NAME).init(null, null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is two methods calls, thus it should not be a one liner (test would pass if getStateStore() would throw UnsupportedOperationException.

Should be:

@Test
    public void shouldNotAllowInit() {
        final StateStore store = globalContext.getStateStore(GLOBAL_STORE_NAME);
        try {
            store.init(null, null);
            fail("Should have thrown UnsupportedOperationException.");
        } catch(final UnsupportedOperationException expected) { }

Similar below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ack

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 2, 2019

Actually, you should compare the tests in ProcessorContextImplTest -- they are quite sophisticated and it might be worth to replicate them here?

@ableegoldman
Copy link
Copy Markdown
Member Author

@mjsax Do you mean the tests in general or with regards to init & close specifically? I guess it's not clear to me what benefit the sophistication is really providing here..I felt it was better to do a straightforward test of the single functionality being tested, but am open to doing otherwise

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 2, 2019

Also, there is a dependency between this PR and #6173 and #6356. Depending which one we merge first, the other need to be updated.

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 3, 2019

Java 11 failed org.apache.kafka.streams.state.internals.RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapterTest.shouldForwardAllDbOptionsCalls
Java 8 failed

kafka.api.AdminClientIntegrationTest.testMinimumRequestTimeouts
kafka.api.ConsumerBounceTest.testRollingBrokerRestartsWithSmallerMaxGroupSizeConfigDisruptsBigGroup

retest this please

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 4, 2019

@ableegoldman The fancy test also verifies that only init() and close() are guarded and it's written to avoid test code duplication. But you raise a fair point that the fancy test is complex code. But it's already there so it might be worth do "copy and adapt" to the global case, too. Thoughts @guozhangwang @bbejeck? If we want to go with simpler test pattern, it might be worth to rewrite the existing fancy test to simplify it?

Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

I looked at ProcessorContextImplTest and I agree with @ableegoldman that it seems over-complicated, we do not need to follow its pattern and even better, simplify that one as well.

Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

Thanks for the input @guozhangwang!

Merging this now. We can do follow ups if we want to simplify existing test code.

@mjsax mjsax merged commit 8662efb into apache:trunk Mar 6, 2019
@ableegoldman ableegoldman deleted the GuardGlobalStoreMethods branch March 14, 2019 18:44
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…he#6353)

Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <guozhang@confluent.io>, Matthias J. Sax <matthias@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants