-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix] Allow setting sourceType in config file #19836
Conversation
@@ -449,6 +449,8 @@ void processArguments() throws Exception { | |||
|
|||
if (sourceType != null) { | |||
sourceConfig.setArchive(validateSourceType(sourceType)); | |||
} else if (sourceConfig.getSourceType() != null) { | |||
sourceConfig.setArchive(validateSourceType(sourceType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceConfig.setArchive(validateSourceType(sourceType)); | |
sourceConfig.setArchive(validateSourceType(sourceConfig.getSourceType())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@@ -412,6 +412,15 @@ public void testBatchSourceConfigMissingDiscoveryTriggererClassName() throws Exc | |||
expectedSourceConfig.setBatchSourceConfig(batchSourceConfig); | |||
testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig); | |||
} | |||
|
|||
@Test(expectedExceptions = ParameterException.class, expectedExceptionsMessageRegExp = "Invalid source type 'foo' " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a happy path test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it:
@Test
public void testCmdSourceConfigFileSourceType() throws Exception {
ConnectorDefinition mockDefinition = new ConnectorDefinition();
mockDefinition.setName("builtin");
when(source.getBuiltInSources()).thenReturn(List.of(mockDefinition));
SourceConfig sourceConfig = getSourceConfig();
sourceConfig.setSourceType("builtin");
SourceConfig exceptedConfig = getSourceConfig();
exceptedConfig.setSourceType("builtin");
exceptedConfig.setArchive("builtin://builtin");
testCmdSourceConfigFile(sourceConfig, exceptedConfig);
}
... while due to some dirty code inherit local run from cmd source the tests are hard to tune. That said, validateSourceType
is inherited by LocalSourceRunner
with total different manner.
The pr had no activity for 30 days, mark with Stale label. |
Signed-off-by: tison <wander4096@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -449,6 +449,8 @@ void processArguments() throws Exception { | |||
|
|||
if (sourceType != null) { | |||
sourceConfig.setArchive(validateSourceType(sourceType)); | |||
} else if (sourceConfig.getSourceType() != null) { | |||
sourceConfig.setArchive(validateSourceType(sourceType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@@ -412,6 +412,15 @@ public void testBatchSourceConfigMissingDiscoveryTriggererClassName() throws Exc | |||
expectedSourceConfig.setBatchSourceConfig(batchSourceConfig); | |||
testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig); | |||
} | |||
|
|||
@Test(expectedExceptions = ParameterException.class, expectedExceptionsMessageRegExp = "Invalid source type 'foo' " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it:
@Test
public void testCmdSourceConfigFileSourceType() throws Exception {
ConnectorDefinition mockDefinition = new ConnectorDefinition();
mockDefinition.setName("builtin");
when(source.getBuiltInSources()).thenReturn(List.of(mockDefinition));
SourceConfig sourceConfig = getSourceConfig();
sourceConfig.setSourceType("builtin");
SourceConfig exceptedConfig = getSourceConfig();
exceptedConfig.setSourceType("builtin");
exceptedConfig.setArchive("builtin://builtin");
testCmdSourceConfigFile(sourceConfig, exceptedConfig);
}
... while due to some dirty code inherit local run from cmd source the tests are hard to tune. That said, validateSourceType
is inherited by LocalSourceRunner
with total different manner.
/pulsarbot run-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/pulsarbot run-failure-checks |
The pr had no activity for 30 days, mark with Stale label. |
Merge the latest master and rerun... |
Merging... Thank you! |
Motivation
Currently, there is an inconsistency between sinks and sources. Sinks can be created by passing the whole config in the sinkConfig file:
But Sources cannot. If we do the equivalent:
To make it work, we currently have to explicitly pass in the type parameter:
Modifications
Add the
sourceType
toSourceConfig
so it can be passed through the config file too.Verifying this change
This change added tests and can be verified as follows:
TestCmdSources
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: alpreu#9