-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Setup integration tests against named db (#1374)
* Add ITBaseTest * setup new kokoro jobs * Add nightly job * push * Require it * Fix dependency
- Loading branch information
Showing
11 changed files
with
144 additions
and
102 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
# Configure the docker image for kokoro-trampoline. | ||
env_vars: { | ||
key: "TRAMPOLINE_IMAGE" | ||
value: "gcr.io/cloud-devrel-kokoro-resources/java8" | ||
} | ||
|
||
env_vars: { | ||
key: "JOB_TYPE" | ||
value: "integration" | ||
} | ||
|
||
env_vars: { | ||
key: "INTEGRATION_TEST_ARGS" | ||
value: "-DFIRESTORE_NAMED_DATABASE=test-db" | ||
} | ||
|
||
# TODO: remove this after we've migrated all tests and scripts | ||
env_vars: { | ||
key: "GCLOUD_PROJECT" | ||
value: "java-review" | ||
} | ||
|
||
env_vars: { | ||
key: "GOOGLE_CLOUD_PROJECT" | ||
value: "java-review" | ||
} | ||
|
||
env_vars: { | ||
key: "GOOGLE_APPLICATION_CREDENTIALS" | ||
value: "secret_manager/java-review_firestore-java-it" | ||
} | ||
|
||
env_vars: { | ||
key: "SECRET_MANAGER_KEYS" | ||
value: "java-review_firestore-java-it" | ||
} | ||
|
||
env_vars: { | ||
key: "ENABLE_BUILD_COP" | ||
value: "true" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
# Configure the docker image for kokoro-trampoline. | ||
env_vars: { | ||
key: "TRAMPOLINE_IMAGE" | ||
value: "gcr.io/cloud-devrel-kokoro-resources/java8" | ||
} | ||
|
||
env_vars: { | ||
key: "JOB_TYPE" | ||
value: "integration" | ||
} | ||
|
||
env_vars: { | ||
key: "INTEGRATION_TEST_ARGS" | ||
value: "-DFIRESTORE_NAMED_DATABASE=test-db" | ||
} | ||
|
||
env_vars: { | ||
key: "GCLOUD_PROJECT" | ||
value: "java-review" | ||
} | ||
|
||
env_vars: { | ||
key: "GOOGLE_APPLICATION_CREDENTIALS" | ||
value: "secret_manager/java-review_firestore-java-it" | ||
} | ||
|
||
env_vars: { | ||
key: "SECRET_MANAGER_KEYS" | ||
value: "java-review_firestore-java-it" | ||
} |
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
57 changes: 57 additions & 0 deletions
57
google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2023 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.cloud.firestore.it; | ||
|
||
import com.google.cloud.firestore.Firestore; | ||
import com.google.cloud.firestore.FirestoreOptions; | ||
import com.google.common.base.Preconditions; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public abstract class ITBaseTest { | ||
private static final Logger logger = Logger.getLogger(ITBaseTest.class.getName()); | ||
protected Firestore firestore; | ||
|
||
@Before | ||
public void before() { | ||
FirestoreOptions.Builder optionsBuilder = FirestoreOptions.newBuilder(); | ||
|
||
String namedDb = System.getProperty("FIRESTORE_NAMED_DATABASE"); | ||
if (namedDb != null) { | ||
logger.log(Level.INFO, "Integration test using named database " + namedDb); | ||
optionsBuilder = optionsBuilder.setDatabaseId(namedDb); | ||
} else { | ||
logger.log(Level.INFO, "Integration test using default database."); | ||
} | ||
|
||
firestore = optionsBuilder.build().getService(); | ||
} | ||
|
||
@After | ||
public void after() throws Exception { | ||
Preconditions.checkNotNull( | ||
firestore, | ||
"Error instantiating Firestore. Check that the service account credentials were properly set."); | ||
firestore.close(); | ||
firestore = null; | ||
} | ||
} |
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
Oops, something went wrong.