Skip to content

Commit 0283543

Browse files
committed
Fit integration tests against different running matrix
1 parent 168a914 commit 0283543

File tree

14 files changed

+314
-27
lines changed

14 files changed

+314
-27
lines changed

.github/workflows/firestore_ci_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
heap-size: 4096M
8686
script: |
8787
adb logcat -v time > logcat.txt &
88-
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod"
88+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod" -PbackendEdition="standard"
8989
- name: Upload logs
9090
if: failure()
9191
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -177,7 +177,7 @@ jobs:
177177
heap-size: 4096M
178178
script: |
179179
adb logcat -v time > logcat.txt &
180-
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod"
180+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod" -PbackendEdition="standard"
181181
- name: Upload logs
182182
if: failure()
183183
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -240,7 +240,7 @@ jobs:
240240
heap-size: 4096M
241241
script: |
242242
adb logcat -v time > logcat.txt &
243-
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="nightly"
243+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="nightly" -PbackendEdition="enterprise" -PtargetDatabaseId="enterprise"
244244
- name: Upload logs
245245
if: failure()
246246
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -314,7 +314,7 @@ jobs:
314314
heap-size: 4096M
315315
script: |
316316
adb logcat -v time > logcat.txt &
317-
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="emulator"
317+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="emulator" -PbackendEdition="enterprise"
318318
- name: Upload logs
319319
if: failure()
320320
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

firebase-firestore/firebase-firestore.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ android {
7777
def targetBackend = findProperty("targetBackend") ?: "emulator"
7878
buildConfigField("String", "TARGET_BACKEND", "\"$targetBackend\"")
7979

80+
def backendEdition = findProperty("backendEdition") ?: "enterprise"
81+
buildConfigField("String", "BACKEND_EDITION", "\"$backendEdition\"")
82+
8083
def targetDatabaseId = findProperty('targetDatabaseId') ?: "enterprise"
8184
buildConfigField("String", "TARGET_DATABASE_ID", "\"$targetDatabaseId\"")
8285

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"project_info": {
3+
"project_number": "110336067267",
4+
"project_id": "firestore-pipeline-preview-1",
5+
"storage_bucket": "firestore-pipeline-preview-1.firebasestorage.app"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:110336067267:android:cb88bd89f566aa70838476",
11+
"android_client_info": {
12+
"package_name": "com.google.firebase.firestore"
13+
}
14+
},
15+
"oauth_client": [],
16+
"api_key": [
17+
{
18+
"current_key": "AIzaSyBTCYWO1TonIFajGuBmq-x1m4qiuPlBSOc"
19+
}
20+
],
21+
"services": {
22+
"appinvite_service": {
23+
"other_platform_oauth_client": []
24+
}
25+
}
26+
},
27+
{
28+
"client_info": {
29+
"mobilesdk_app_id": "1:110336067267:android:f228269c735c2332838476",
30+
"android_client_info": {
31+
"package_name": "com.google.pipeline.preview"
32+
}
33+
},
34+
"oauth_client": [],
35+
"api_key": [
36+
{
37+
"current_key": "AIzaSyBTCYWO1TonIFajGuBmq-x1m4qiuPlBSOc"
38+
}
39+
],
40+
"services": {
41+
"appinvite_service": {
42+
"other_platform_oauth_client": []
43+
}
44+
}
45+
}
46+
],
47+
"configuration_version": "1"
48+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"project_info": {
3+
"project_number": "323991545240",
4+
"project_id": "firestore-sdk-nightly",
5+
"storage_bucket": "firestore-sdk-nightly.appspot.com"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:323991545240:android:f67bff623cb940171cf7ed",
11+
"android_client_info": {
12+
"package_name": "com.example.myapplication"
13+
}
14+
},
15+
"oauth_client": [],
16+
"api_key": [
17+
{
18+
"current_key": "AIzaSyAGlVkolEukFeuqjj9OBPNp9Bzm-mBLL3Q"
19+
}
20+
],
21+
"services": {
22+
"appinvite_service": {
23+
"other_platform_oauth_client": []
24+
}
25+
}
26+
},
27+
{
28+
"client_info": {
29+
"mobilesdk_app_id": "1:323991545240:android:f4a81ec5cd3e109e1cf7ed",
30+
"android_client_info": {
31+
"package_name": "com.google.firebase.example.fireeats"
32+
}
33+
},
34+
"oauth_client": [],
35+
"api_key": [
36+
{
37+
"current_key": "AIzaSyAGlVkolEukFeuqjj9OBPNp9Bzm-mBLL3Q"
38+
}
39+
],
40+
"services": {
41+
"appinvite_service": {
42+
"other_platform_oauth_client": []
43+
}
44+
}
45+
},
46+
{
47+
"client_info": {
48+
"mobilesdk_app_id": "1:323991545240:android:ddaff272c5c1aeae1cf7ed",
49+
"android_client_info": {
50+
"package_name": "com.google.firebase.firestore"
51+
}
52+
},
53+
"oauth_client": [],
54+
"api_key": [
55+
{
56+
"current_key": "AIzaSyAGlVkolEukFeuqjj9OBPNp9Bzm-mBLL3Q"
57+
}
58+
],
59+
"services": {
60+
"appinvite_service": {
61+
"other_platform_oauth_client": []
62+
}
63+
}
64+
},
65+
{
66+
"client_info": {
67+
"mobilesdk_app_id": "1:323991545240:android:79bcc4086beedb9b1cf7ed",
68+
"android_client_info": {
69+
"package_name": "com.google.firestore"
70+
}
71+
},
72+
"oauth_client": [],
73+
"api_key": [
74+
{
75+
"current_key": "AIzaSyAGlVkolEukFeuqjj9OBPNp9Bzm-mBLL3Q"
76+
}
77+
],
78+
"services": {
79+
"appinvite_service": {
80+
"other_platform_oauth_client": []
81+
}
82+
}
83+
}
84+
],
85+
"configuration_version": "1"
86+
}

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/AggregationTest.java

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static com.google.firebase.firestore.AggregateField.average;
1818
import static com.google.firebase.firestore.AggregateField.count;
1919
import static com.google.firebase.firestore.AggregateField.sum;
20+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.getBackendEdition;
2021
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
2122
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
2223
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollectionWithDocs;
@@ -33,6 +34,7 @@
3334
import static org.junit.Assert.assertThrows;
3435
import static org.junit.Assert.assertTrue;
3536
import static org.junit.Assume.assumeFalse;
37+
import static org.junit.Assume.assumeTrue;
3638

3739
import androidx.test.ext.junit.runners.AndroidJUnit4;
3840
import com.google.android.gms.tasks.Task;
@@ -387,6 +389,10 @@ public void testCanGetCorrectTypeForAvg() {
387389

388390
@Test
389391
public void testCannotPerformMoreThanMaxAggregations() {
392+
assumeTrue(
393+
"Standard-only behavior",
394+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
395+
390396
CollectionReference collection = testCollectionWithDocs(testDocs1);
391397
AggregateField f1 = sum("pages");
392398
AggregateField f2 = average("pages");
@@ -534,12 +540,26 @@ public void testPerformsSumThatOverflowsMaxLong() {
534540
"b", map("author", "authorB", "title", "titleB", "rating", Long.MAX_VALUE));
535541
CollectionReference collection = testCollectionWithDocs(testDocs);
536542

537-
AggregateQuerySnapshot snapshot =
538-
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
539-
540-
Object sum = snapshot.get(sum("rating"));
541-
assertTrue(sum instanceof Double);
542-
assertEquals(sum, (double) Long.MAX_VALUE + (double) Long.MAX_VALUE);
543+
switch (getBackendEdition()) {
544+
case STANDARD:
545+
{
546+
AggregateQuerySnapshot snapshot =
547+
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
548+
549+
Object sum = snapshot.get(sum("rating"));
550+
assertTrue(sum instanceof Double);
551+
assertEquals(sum, (double) Long.MAX_VALUE + (double) Long.MAX_VALUE);
552+
break;
553+
}
554+
case ENTERPRISE:
555+
{
556+
assertThrows(
557+
RuntimeException.class,
558+
() -> {
559+
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
560+
});
561+
}
562+
}
543563
}
544564

545565
@Test
@@ -569,10 +589,20 @@ public void testPerformsSumThatIsNegative() {
569589
"d", map("author", "authorD", "title", "titleD", "rating", -10000));
570590
CollectionReference collection = testCollectionWithDocs(testDocs);
571591

572-
AggregateQuerySnapshot snapshot =
573-
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
574-
575-
assertEquals(snapshot.get(sum("rating")), -10101L);
592+
switch (getBackendEdition()) {
593+
case STANDARD:
594+
AggregateQuerySnapshot snapshot =
595+
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
596+
597+
assertEquals(snapshot.get(sum("rating")), -10101L);
598+
break;
599+
case ENTERPRISE:
600+
assertThrows(
601+
RuntimeException.class,
602+
() -> {
603+
waitFor(collection.aggregate(sum("rating")).get(AggregateSource.SERVER));
604+
});
605+
}
576606
}
577607

578608
@Test
@@ -645,7 +675,13 @@ public void testPerformsSumOverResultSetOfZeroDocuments() {
645675
.aggregate(sum("pages"))
646676
.get(AggregateSource.SERVER));
647677

648-
assertEquals(snapshot.get(sum("pages")), 0L);
678+
switch (getBackendEdition()) {
679+
case STANDARD:
680+
assertEquals(snapshot.get(sum("pages")), 0L);
681+
break;
682+
case ENTERPRISE:
683+
assertNull(snapshot.get(sum("pages")));
684+
}
649685
}
650686

651687
@Test
@@ -893,6 +929,9 @@ public void testAggregateErrorMessageShouldContainConsoleLinkIfMissingIndex() {
893929
+ "Firestore emulator does not use indexes and never fails with a 'missing index'"
894930
+ " error",
895931
isRunningAgainstEmulator());
932+
assumeTrue(
933+
"Mandatory index is a Standard-only behavior",
934+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
896935

897936
CollectionReference collection = testCollectionWithDocs(Collections.emptyMap());
898937
Query compositeIndexQuery = collection.whereEqualTo("field1", 42).whereLessThan("field2", 99);

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/CompositeIndexQueryTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static com.google.firebase.firestore.Filter.notInArray;
2626
import static com.google.firebase.firestore.Filter.or;
2727
import static com.google.firebase.firestore.testutil.CompositeIndexTestHelper.COMPOSITE_INDEX_TEST_COLLECTION;
28+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.getBackendEdition;
2829
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.nullList;
2930
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testFirestore;
3031
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
@@ -36,6 +37,7 @@
3637
import static org.junit.Assert.assertFalse;
3738
import static org.junit.Assert.assertNull;
3839
import static org.junit.Assert.assertTrue;
40+
import static org.junit.Assume.assumeTrue;
3941

4042
import androidx.test.ext.junit.runners.AndroidJUnit4;
4143
import com.google.firebase.firestore.Query.Direction;
@@ -199,6 +201,10 @@ public void testCanGetCorrectTypeForSum() {
199201

200202
@Test
201203
public void testPerformsAggregationWhenUsingArrayContainsAnyOperator() {
204+
assumeTrue(
205+
"Standard-only behavior",
206+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
207+
202208
CompositeIndexTestHelper testHelper = new CompositeIndexTestHelper();
203209

204210
Map<String, Map<String, Object>> testDocs =
@@ -821,6 +827,10 @@ public void testMultipleInequalityRejectsIfDocumentKeyIsNotTheLastOrderByField()
821827

822828
@Test
823829
public void testMultipleInequalityRejectsIfDocumentKeyAppearsOnlyInEqualityFilter() {
830+
assumeTrue(
831+
"Standard-only behavior",
832+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
833+
824834
CompositeIndexTestHelper testHelper = new CompositeIndexTestHelper();
825835

826836
CollectionReference collection = testHelper.withTestCollection();

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/CountTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.firebase.firestore;
1616

1717
import static com.google.common.truth.Truth.assertThat;
18+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.getBackendEdition;
1819
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
1920
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
2021
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollectionWithDocs;
@@ -30,6 +31,7 @@
3031
import static org.junit.Assert.assertThrows;
3132
import static org.junit.Assert.assertTrue;
3233
import static org.junit.Assume.assumeFalse;
34+
import static org.junit.Assume.assumeTrue;
3335

3436
import androidx.test.ext.junit.runners.AndroidJUnit4;
3537
import com.google.android.gms.tasks.Task;
@@ -268,6 +270,10 @@ public void testCountErrorMessageShouldContainConsoleLinkIfMissingIndex() {
268270
+ "does not use indexes and never fails with a 'missing index' error",
269271
isRunningAgainstEmulator());
270272

273+
assumeTrue(
274+
"Standard-only behavior",
275+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
276+
271277
CollectionReference collection = testCollectionWithDocs(Collections.emptyMap());
272278
Query compositeIndexQuery = collection.whereEqualTo("field1", 42).whereLessThan("field2", 99);
273279
AggregateQuery compositeIndexCountQuery = compositeIndexQuery.count();

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import static com.google.firebase.firestore.AccessHelper.getAsyncQueue;
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.checkOnlineAndOfflineResultsMatch;
19+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.getBackendEdition;
1920
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
2021
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.newTestSettings;
2122
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.provider;
@@ -1561,6 +1562,10 @@ public void snapshotListenerSortsQueryByDocumentIdsSameAsGetQuery() {
15611562

15621563
@Test
15631564
public void snapshotListenerSortsFilteredQueryByDocumentIdsSameAsGetQuery() {
1565+
assumeTrue(
1566+
"Standard-only behavior",
1567+
getBackendEdition() == IntegrationTestUtil.BackendEdition.STANDARD);
1568+
15641569
Map<String, Map<String, Object>> testDocs =
15651570
map(
15661571
"A", map("a", 1),

0 commit comments

Comments
 (0)