From bd68acd9f95c8d4cd829b75c709ed94963c5aa9d Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 21 Sep 2022 20:22:54 -0400 Subject: [PATCH 1/3] ci: enable ITQueryCountTest in CI, since the project is whitelists for COUNT --- .../com/google/cloud/firestore/ITQueryCountTest.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java index b9e3a671e0..a069080696 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java @@ -47,21 +47,11 @@ public class ITQueryCountTest { @Rule public TestName testName = new TestName(); - private FirestoreOptions firestoreOptions; private Firestore firestore; - @Before - public void setUpFirestoreOptions() { - firestoreOptions = FirestoreOptions.newBuilder().build(); - // TODO(count) Remove the assumeTrue() below once count queries are supported in prod. - assumeTrue( - "Count queries are only supported in the Firestore Emulator (for now)", - firestoreOptions.getHost().startsWith("localhost")); - } - @Before public void setUpFirestore() { - firestore = firestoreOptions.getService(); + firestore = FirestoreOptions.newBuilder().build().getService(); Preconditions.checkNotNull( firestore, "Error instantiating Firestore. Check that the service account credentials were properly set."); From a7e90ddaf770f3f4a67072688ddefc28a1928f5d Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 21 Sep 2022 20:32:03 -0400 Subject: [PATCH 2/3] ITQueryCountTest.java: removed unused iport of assumeTrue --- .../test/java/com/google/cloud/firestore/ITQueryCountTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java index a069080696..9d7c4492bf 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java @@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat; import static java.util.Collections.singletonMap; import static org.junit.Assert.assertThrows; -import static org.junit.Assume.assumeTrue; import com.google.api.core.ApiFuture; import com.google.auto.value.AutoValue; From 17543221150e9d0aa3e2e752b5d3d77f1d4e079e Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 22 Sep 2022 00:09:30 -0400 Subject: [PATCH 3/3] Skip aggregateQueryInATransactionShouldLockTheCountedDocuments when running against prod (b/248152832) --- .../com/google/cloud/firestore/ITQueryCountTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java index 9d7c4492bf..3d93456c87 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ITQueryCountTest.java @@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static java.util.Collections.singletonMap; import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeTrue; import com.google.api.core.ApiFuture; import com.google.auto.value.AutoValue; @@ -215,6 +216,11 @@ public void aggregateQueryShouldWorkInATransaction() throws Exception { @Test public void aggregateQueryInATransactionShouldLockTheCountedDocuments() throws Exception { + assumeTrue( + "Skip this test when running against production because " + + "it appears that production is failing to lock the counted documents b/248152832", + isRunningAgainstFirestoreEmulator()); + CollectionReference collection = createEmptyCollection(); DocumentReference document = createDocumentInCollection(collection); CountDownLatch aggregateQueryExecutedSignal = new CountDownLatch(1); @@ -388,6 +394,11 @@ private static void await(ApiFuture future) throws InterruptedException { executor.shutdown(); } + /** Returns whether the tests are running against the Firestore emulator. */ + private boolean isRunningAgainstFirestoreEmulator() { + return firestore.getOptions().getHost().startsWith("localhost:"); + } + @AutoValue abstract static class CreatedCollectionInfo {