- Notifications
You must be signed in to change notification settings - Fork 50
feat: multiple dbs support #928
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
Changes from 10 commits
f82fcde cfcad89 fea25c3 fe83a52 e1f8115 660eacb c6de94a a58843f 3a02e75 5961f4e 35b4b5b dac5416 a8f7f72 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -30,4 +30,9 @@ env_vars: { | |
| env_vars: { | ||
| key: "SECRET_MANAGER_KEYS" | ||
| value: "java-it-service-account" | ||
| } | ||
| | ||
| 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. Let's also merge this PR with Contributor Author 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. will do - I will have a followup PR updating this branch, so stay tuned! | ||
| env_vars: { | ||
| key: "DATASTORE_PROJECT_ID" | ||
| value: "gcloud-devel" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -29,5 +29,55 @@ | |
| "allPublicMethods":true, | ||
| "allDeclaredConstructors" : true, | ||
| "allPublicConstructors" : true | ||
| } | ||
| }, | ||
| [ | ||
| ||
| { | ||
| "name":"com.google.api.client.auth.oauth2.TokenRequest", | ||
| "allDeclaredFields":true, | ||
| "queryAllDeclaredMethods":true | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.auth.oauth2.TokenResponse", | ||
| "allDeclaredFields":true, | ||
| "queryAllDeclaredMethods":true, | ||
| "methods":[ | ||
| {"name":"<init>","parameterTypes":[] }, | ||
| {"name":"setAccessToken","parameterTypes":["java.lang.String"] }, | ||
| {"name":"setExpiresInSeconds","parameterTypes":["java.lang.Long"] }, | ||
| {"name":"setTokenType","parameterTypes":["java.lang.String"] } | ||
| ] | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.http.GenericUrl", | ||
| "allDeclaredFields":true | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.json.GenericJson", | ||
| "allDeclaredFields":true, | ||
| "methods":[{"name":"<init>","parameterTypes":[] }] | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.json.webtoken.JsonWebSignature$Header", | ||
| "allDeclaredFields":true, | ||
| "queryAllDeclaredMethods":true | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.json.webtoken.JsonWebToken$Header", | ||
| "allDeclaredFields":true, | ||
| "queryAllDeclaredMethods":true | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.json.webtoken.JsonWebToken$Payload", | ||
| "allDeclaredFields":true, | ||
| "queryAllDeclaredMethods":true | ||
| }, | ||
| { | ||
| "name":"com.google.api.client.util.GenericData", | ||
| "allDeclaredFields":true | ||
| }, | ||
| { | ||
| "name":"com.google.protobuf.ExtensionRegistry", | ||
| "methods":[{"name":"getEmptyRegistry","parameterTypes":[] }] | ||
| } | ||
| ] | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * Copyright 2022 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.google.datastore.v1.client.it; | ||
| | ||
| import static com.google.datastore.v1.client.DatastoreHelper.makeFilter; | ||
| import static com.google.datastore.v1.client.DatastoreHelper.makeValue; | ||
| | ||
| import com.google.datastore.v1.Filter; | ||
| import com.google.datastore.v1.KindExpression; | ||
| import com.google.datastore.v1.PartitionId; | ||
| import com.google.datastore.v1.PropertyFilter; | ||
| import com.google.datastore.v1.Query; | ||
| import com.google.datastore.v1.client.Datastore; | ||
| import com.google.datastore.v1.client.DatastoreException; | ||
| import com.google.datastore.v1.client.DatastoreHelper; | ||
| import java.io.IOException; | ||
| import java.security.GeneralSecurityException; | ||
| import java.util.List; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| | ||
| public class ITDatastoreProtoClientTest { | ||
jainsahab marked this conversation as resolved. Show resolved Hide resolved | ||
| | ||
| private static Datastore DATASTORE; | ||
| | ||
| private static PartitionId PARTITION; | ||
| | ||
| private static final String KIND = "test-kind"; | ||
| private static final String PROJECT_ID = System.getenv(DatastoreHelper.PROJECT_ID_ENV_VAR); | ||
| | ||
| @Before | ||
| public void setUp() throws GeneralSecurityException, IOException { | ||
| DATASTORE = DatastoreHelper.getDatastoreFromEnv(); | ||
| } | ||
| | ||
| @Test | ||
| public void testQuerySplitterWithDefaultDb() throws DatastoreException { | ||
| Filter propertyFilter = | ||
| makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); | ||
| Query query = | ||
| Query.newBuilder() | ||
| .addKind(KindExpression.newBuilder().setName(KIND).build()) | ||
| .setFilter(propertyFilter) | ||
| .build(); | ||
| | ||
| PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).build(); | ||
| | ||
| List<Query> splits = | ||
| DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); | ||
| splits.forEach( | ||
| split -> { | ||
| Assert.assertEquals(KIND, split.getKind(0).getName()); | ||
| Assert.assertEquals(propertyFilter, split.getFilter()); | ||
| }); | ||
| } | ||
| | ||
| @Test | ||
| public void testQuerySplitterWithDb() throws DatastoreException { | ||
| Filter propertyFilter = | ||
| makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); | ||
| Query query = | ||
| Query.newBuilder() | ||
| .addKind(KindExpression.newBuilder().setName(KIND).build()) | ||
| .setFilter(propertyFilter) | ||
| .build(); | ||
| | ||
| PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).setDatabaseId("test-db").build(); | ||
| | ||
| List<Query> splits = | ||
| DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); | ||
| splits.forEach( | ||
| split -> { | ||
| Assert.assertEquals(KIND, split.getKind(0).getName()); | ||
| Assert.assertEquals(propertyFilter, split.getFilter()); | ||
| }); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.