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

test: do not mock config store in StandaloneExecutor integration test #4128

Merged
merged 3 commits into from
Dec 17, 2019

Conversation

vcrfxia
Copy link
Contributor

@vcrfxia vcrfxia commented Dec 12, 2019

Description

As described in #4114, the ksqlDB server from the latest release fails to start in headless mode. This bug eluded our integration tests for headless mode because the integration test currently mocks the KafkaConfigStore which updates the KSQL config passed to the StandaloneExecutor (the mock does not perform these updates). This PR switches the integration test to use an actual KafkaConfigStore instance, rather than a mock, to avoid similar bugs in the future.

Testing done

Test-only change.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@vcrfxia vcrfxia requested a review from a team as a code owner December 12, 2019 23:07
Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

LGTM!

@agavra agavra requested a review from a team December 12, 2019 23:09
@apurvam
Copy link
Contributor

apurvam commented Dec 12, 2019

thanks for the patch @vcrfxia . Can we backport this to 5.4 too?

@vcrfxia vcrfxia changed the base branch from master to 5.4.x December 13, 2019 02:37
@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 13, 2019

Retargeted the patch at 5.4.x and will merge once the build passes.

@stevenpyzhang
Copy link
Member

@vcrfxia since we're using an actual KafkaConfigStore, overrideBreakingConfigsWithOriginalValues is being called which is setting ksql.sink.paritions=4 which is failing the tests. This isn't a problem on master since the config has been removed, whereas the defaultLegacyValue is still 4 on 5.4

Probably just need to specify that config to 1 and it'll pass the tests.

@big-andy-coates
Copy link
Contributor

thanks for the patch @vcrfxia . Can we backport this to 5.4 too?

Why backport? It's a test only change. It's not as though someone is going to change how the config topic code works in 5.4....

@big-andy-coates
Copy link
Contributor

Is it worth removing any other mocks in this integration test while we're at it? They may open us to the same hole in testing in the future...

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 16, 2019

Is it worth removing any other mocks in this integration test while we're at it?

The only other mock in this integration test is the version checker. Not sure what we'd replace that mock with, and it's also mocked in our other integration tests.

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 16, 2019

Why backport? It's a test only change.

Because backporting the test fix has caught a bug! Turns out headless mode is broken on 5.4 for the reason the Jenkins build failed:

[2019-12-16 13:57:28,996] ERROR Failed to start KSQL Server with query file: ./queries.sql (io.confluent.ksql.rest.server.StandaloneExecutor:124)
io.confluent.ksql.exception.KafkaTopicExistsException: A Kafka topic with the name 'test' already exists, with different partition/replica configuration than required. KSQL expects 4 partitions (topic has 1), and 1 replication factor (topic has 1).
	at io.confluent.ksql.services.TopicValidationUtil.validateTopicProperties(TopicValidationUtil.java:55)
	at io.confluent.ksql.services.TopicValidationUtil.validateTopicProperties(TopicValidationUtil.java:37)
	at io.confluent.ksql.services.SandboxedKafkaTopicClient.validateTopicProperties(SandboxedKafkaTopicClient.java:154)
	at io.confluent.ksql.services.SandboxedKafkaTopicClient.createTopic(SandboxedKafkaTopicClient.java:86)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.confluent.ksql.util.LimitedProxyBuilder.lambda$buildForwader$8(LimitedProxyBuilder.java:234)
	at io.confluent.ksql.util.LimitedProxyBuilder$SandboxProxy.invoke(LimitedProxyBuilder.java:312)
	at com.sun.proxy.$Proxy30.createTopic(Unknown Source)
	at io.confluent.ksql.topic.TopicCreateInjector.createTopic(TopicCreateInjector.java:190)
	at io.confluent.ksql.topic.TopicCreateInjector.injectForCreateSource(TopicCreateInjector.java:129)
	at io.confluent.ksql.topic.TopicCreateInjector.inject(TopicCreateInjector.java:91)
	at io.confluent.ksql.topic.TopicCreateInjector.inject(TopicCreateInjector.java:75)
	at io.confluent.ksql.statement.InjectorChain.inject(InjectorChain.java:42)
	at io.confluent.ksql.rest.server.StandaloneExecutor$StatementExecutor.prepare(StandaloneExecutor.java:312)
	at io.confluent.ksql.rest.server.StandaloneExecutor$StatementExecutor.execute(StandaloneExecutor.java:288)
	at io.confluent.ksql.rest.server.StandaloneExecutor.executeStatements(StandaloneExecutor.java:206)
	at io.confluent.ksql.rest.server.StandaloneExecutor.validateStatements(StandaloneExecutor.java:190)
	at io.confluent.ksql.rest.server.StandaloneExecutor.processesQueryFile(StandaloneExecutor.java:168)
	at io.confluent.ksql.rest.server.StandaloneExecutor.start(StandaloneExecutor.java:118)
	at io.confluent.ksql.rest.server.KsqlServerMain.tryStartApp(KsqlServerMain.java:73)
	at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:59)

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 16, 2019

The fix is to update the legacy values for the sink number of partitions and replicas configs to null and also backport #4119. Just made both changes, so hopefully the next Jenkins build passes.

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 16, 2019

Actually, this is a bit of an odd fix since the intention of the legacy config values being non-null was so that existing queries issued prior to 5.3 (when the sink number of partitions and replicas were deprecated) will continue to validate the way they had been. I think this change is still sound since the new behavior (when the values are null) is to use existing values for number of partitions and replicas, and topics for existing queries exist by definition. However, maybe it's safer to limit this change to only set ksql.sink.replicas and ksql.sink.partitions to null in headless mode. Would be interested to hear what other members of @confluentinc/ksql think.

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 17, 2019

Talked to @rodesai who pointed out the fix of updating the legacy config values to null should be safe regarding compatibility for interactive mode since the sink number of partitions and replicas configs are only used by the TopicCreatorInjector before writing to the command topic and not after, so changing the legacy values for the configs won't cause imcompatibilities when reading (and replaying) from the command topic.

@apurvam
Copy link
Contributor

apurvam commented Dec 17, 2019

Talked to @rodesai who pointed out the fix of updating the legacy config values to null should be safe regarding compatibility for interactive mode since the sink number of partitions and replicas configs are only used by the TopicCreatorInjector before writing to the command topic and not after, so changing the legacy values for the configs won't cause imcompatibilities when reading (and replaying) from the command topic.

If I am reading this correctly, we are saying that if a user ran this in interactive mode pre 5.3, they would have their old values in the command topic, so the new defaults won't matter to them?

@apurvam
Copy link
Contributor

apurvam commented Dec 17, 2019

Did we do a manual test of non-interactive mode with different input topic configs in 5.4 as well?

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 17, 2019

Talked to @rodesai who pointed out the fix of updating the legacy config values to null should be safe regarding compatibility for interactive mode since the sink number of partitions and replicas configs are only used by the TopicCreatorInjector before writing to the command topic and not after, so changing the legacy values for the configs won't cause imcompatibilities when reading (and replaying) from the command topic.

If I am reading this correctly, we are saying that if a user ran this in interactive mode pre 5.3, they would have their old values in the command topic, so the new defaults won't matter to them?

That's actually not what I meant, but that's also true and another good reason this change is safe. I meant that for 5.4 in interactive mode, we only validate number of partitions and replicas at the time a command is received (i.e., before writing the command to the command topic) and not when replaying commands from the command topic as part of restarting the server, which means the default legacy values for the ksql.sink.partitions and ksql.sink.replicas configs (the ones that this PR changes from 4 and 1 to null) are not considered when replaying the command topic, and therefore this change can't affect how existing commands are replayed.

@vcrfxia
Copy link
Contributor Author

vcrfxia commented Dec 17, 2019

Did we do a manual test of non-interactive mode with different input topic configs in 5.4 as well?

Yup, assuming this means verifying that the KSQL server starts in non-interactive mode on 5.4 with this fix, if topics have properties other than 4 partitions and 1 replica.

I also manually verified that an upgrade from KSQL 5.2 to 5.4 in interactive mode works as expected, with topics that have properties other than 4 partitions and 1 replica.

@vcrfxia vcrfxia changed the title test: do not mock config store in StandaloneExecutor integration test (MINOR) test: do not mock config store in StandaloneExecutor integration test Dec 17, 2019
@vcrfxia vcrfxia merged commit e59a6fe into confluentinc:5.4.x Dec 17, 2019
@vcrfxia vcrfxia deleted the headless-integration-test branch December 17, 2019 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants