Skip to content
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

ci: enable ITQueryCountTest in CI, since the project is whitelisted for COUNT #1040

Merged
merged 3 commits into from
Sep 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -226,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);
Expand Down Expand Up @@ -399,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 {

Expand Down