-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: add flag to disable pull queries (MINOR) #3778
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,24 +30,57 @@ | |
import io.confluent.ksql.rest.server.resources.KsqlRestException; | ||
import io.confluent.ksql.rest.server.validation.CustomValidators; | ||
import io.confluent.ksql.statement.ConfiguredStatement; | ||
import io.confluent.ksql.util.KsqlConfig; | ||
import org.eclipse.jetty.http.HttpStatus.Code; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.runners.Enclosed; | ||
import org.junit.rules.ExpectedException; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: unused Mockito imports. |
||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
@RunWith(Enclosed.class) | ||
public class StaticQueryExecutorTest { | ||
|
||
@Rule | ||
public final TemporaryEngine engine = new TemporaryEngine(); | ||
public static class Disabled { | ||
@Rule | ||
public final TemporaryEngine engine = new TemporaryEngine() | ||
.withConfigs(ImmutableMap.of(KsqlConfig.KSQL_PULL_QUERIES_ENABLE_CONFIG, false)); | ||
|
||
@Rule | ||
public final ExpectedException expectedException = ExpectedException.none(); | ||
@Rule | ||
public final ExpectedException expectedException = ExpectedException.none(); | ||
|
||
@Test | ||
public void shouldThrowExceptionOnQueryEndpoint() { | ||
@Test | ||
public void shouldThrowExceptionIfConfigDisabled() { | ||
|
||
testForFailure( | ||
engine, | ||
expectedException, | ||
"Pull queries are disabled on this KSQL server" | ||
); | ||
} | ||
} | ||
|
||
public static class Enabled { | ||
@Rule | ||
public final TemporaryEngine engine = new TemporaryEngine(); | ||
|
||
@Rule | ||
public final ExpectedException expectedException = ExpectedException.none(); | ||
|
||
@Test | ||
public void shouldThrowExceptionOnQueryEndpoint() { | ||
testForFailure( | ||
engine, | ||
expectedException, | ||
"The following statement types should be issued to the websocket endpoint '/query'" | ||
); | ||
} | ||
} | ||
|
||
private static void testForFailure( | ||
TemporaryEngine engine, ExpectedException expectedException, String errorMessage | ||
) { | ||
// Given: | ||
final ConfiguredStatement<Query> query = ConfiguredStatement.of( | ||
PreparedStatement.of("SELECT * FROM test_table;", mock(Query.class)), | ||
|
@@ -59,7 +92,7 @@ public void shouldThrowExceptionOnQueryEndpoint() { | |
expectedException.expect(KsqlRestException.class); | ||
expectedException.expect(exceptionStatusCode(is(Code.BAD_REQUEST))); | ||
expectedException.expect(exceptionStatementErrorMessage(errorMessage(containsString( | ||
"The following statement types should be issued to the websocket endpoint '/query'" | ||
errorMessage | ||
)))); | ||
expectedException.expect(exceptionStatementErrorMessage(statement(containsString( | ||
"SELECT * FROM test_table")))); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's not just a matter of resubmitting the query with
EMIT CHANGES
, right? I thought push queries went to the/query
endpoint, whereas pull queries went to the/ksql
endpoint.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.
yes and no - the CLI will handle that for you. if you submit the query to the wrong endpoint, it will also complain and tell you which endpoint you should be hitting. since all this is changing with #3742, I'd rather not bake too much of it into the error message
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.
Fair enough. As long as our error messages if pull/push queries are submitted to the wrong endpoint are good enough for non-CLI users to know how to respond, that works for me.