-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add sys.queries table. #18923
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
Merged
Merged
Add sys.queries table. #18923
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
803c698
Add sys.queries table.
gianm dc184da
Fix imports.
gianm bf3ad50
Add opencsv dependency.
gianm faf34fe
Fix tests and fix cancellation of ACCEPTED controllers.
gianm 9ba814d
Add QueriesTable test to SystemSchemaTest.
gianm 1263d8a
Merge branch 'master' into sys-queries
gianm 59b17e4
Updates.
gianm 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,15 +20,25 @@ | |
| package org.apache.druid.testing.embedded.auth; | ||
|
|
||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.java.util.http.client.HttpClient; | ||
| import org.apache.druid.security.basic.BasicSecurityDruidModule; | ||
| import org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate; | ||
| import org.apache.druid.server.DruidNode; | ||
| import org.apache.druid.server.security.ResourceAction; | ||
| import org.apache.druid.testing.embedded.EmbeddedDruidCluster; | ||
| import org.apache.druid.testing.embedded.EmbeddedDruidServer; | ||
| import org.apache.druid.testing.embedded.EmbeddedResource; | ||
| import org.jboss.netty.handler.codec.http.HttpMethod; | ||
| import org.jboss.netty.handler.codec.http.HttpResponseStatus; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Resource to enable the basic auth extension in embedded tests. | ||
| */ | ||
| public class EmbeddedBasicAuthResource implements EmbeddedResource | ||
| { | ||
| public static final String ADMIN_USER = "admin"; | ||
| public static final String ADMIN_PASSWORD = "priest"; | ||
| public static final String SYSTEM_PASSWORD = "warlock"; | ||
| public static final String SYSTEM_USER = "druid_system"; | ||
|
|
@@ -65,19 +75,100 @@ public void stop() | |
| { | ||
| // Do nothing | ||
| } | ||
|
|
||
| private String authenticatorProp(String name) | ||
| { | ||
| return StringUtils.format("druid.auth.authenticator.%s.%s", AUTHENTICATOR_NAME, name); | ||
| } | ||
|
|
||
| private String authorizerProp(String name) | ||
| { | ||
| return StringUtils.format("druid.auth.authorizer.%s.%s", AUTHORIZER_NAME, name); | ||
| } | ||
|
|
||
| private String escalatorProp(String name) | ||
| { | ||
| return StringUtils.format("druid.escalator.%s", name); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a user with specified permissions using the basic auth security API. | ||
| * | ||
| * @param adminClient HTTP client authenticated as admin | ||
| * @param coordinator the coordinator server to make API calls against | ||
| * @param username the username to create | ||
| * @param password the password for the user | ||
| * @param roleName the role name to create and assign | ||
| * @param permissions the permissions to grant to the role | ||
| */ | ||
| public static void createUserWithPermissions( | ||
|
Contributor
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. nice |
||
| HttpClient adminClient, | ||
| EmbeddedDruidServer<?> coordinator, | ||
| String username, | ||
| String password, | ||
| String roleName, | ||
| List<ResourceAction> permissions | ||
| ) | ||
| { | ||
| final DruidNode coordinatorDruidNode = coordinator.bindings().selfNode(); | ||
| final String baseUrl = StringUtils.format( | ||
| "%s://%s/druid-ext/basic-security", | ||
| coordinatorDruidNode.getServiceScheme(), | ||
| coordinatorDruidNode.getHostAndPortToUse() | ||
| ); | ||
|
|
||
| // Create user in authentication DB | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authentication/db/basic/users/%s", baseUrl, username), | ||
| null, | ||
| HttpResponseStatus.OK | ||
| ); | ||
|
|
||
| // Set password | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authentication/db/basic/users/%s/credentials", baseUrl, username), | ||
| new BasicAuthenticatorCredentialUpdate(password, 5000), | ||
| HttpResponseStatus.OK | ||
| ); | ||
|
|
||
| // Create user in authorization DB | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authorization/db/basic/users/%s", baseUrl, username), | ||
| null, | ||
| HttpResponseStatus.OK | ||
| ); | ||
|
|
||
| // Create role | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authorization/db/basic/roles/%s", baseUrl, roleName), | ||
| null, | ||
| HttpResponseStatus.OK | ||
| ); | ||
|
|
||
| // Assign role to user | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authorization/db/basic/users/%s/roles/%s", baseUrl, username, roleName), | ||
| null, | ||
| HttpResponseStatus.OK | ||
| ); | ||
|
|
||
| // Grant permissions | ||
| HttpUtil.makeRequest( | ||
| adminClient, | ||
| HttpMethod.POST, | ||
| StringUtils.format("%s/authorization/db/basic/roles/%s/permissions", baseUrl, roleName), | ||
| permissions, | ||
| HttpResponseStatus.OK | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
With this being off by default, I guess it would make me think as an operator that there is either a cost or a risk to turning it on. I don't think risk, but cost, maybe? Or is this just how we have operated with new sys tables in past, feature flag them, and once non-experimental remove the flag?
If there is a consideration an operator should take beyond "this is off by default cuz it is experimental" then I think we should add such a disclaimer here
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 was thinking it's because it only works with Dart, and Dart is experimental, so this should be experimental too by transitivity. I will add that to the docs.