Skip to content

Commit fe18102

Browse files
authored
Retrying firestore array transform tests
1 parent 2785e05 commit fe18102

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import org.junit.After;
2929
import org.junit.Before;
30+
import org.junit.Rule;
3031
import org.junit.Test;
3132
import org.junit.runner.RunWith;
3233

@@ -37,6 +38,9 @@
3738
*/
3839
@RunWith(AndroidJUnit4.class)
3940
public class ArrayTransformsTest {
41+
// TODO(b/114769487): These tests have been flaky in CI so temporarily retrying.
42+
@Rule public RetryRule retryRule = new RetryRule(3);
43+
4044
// A document reference to read and write to.
4145
private DocumentReference docRef;
4246

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

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
@RunWith(AndroidJUnit4.class)
3131
public class POJOTest {
32-
3332
public static class POJO {
3433

3534
double number;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2018 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.firestore;
16+
17+
import org.junit.rules.TestRule;
18+
import org.junit.runner.Description;
19+
import org.junit.runners.model.Statement;
20+
21+
public class RetryRule implements TestRule {
22+
private int retryCount;
23+
24+
public RetryRule(int retryCount) {
25+
this.retryCount = retryCount;
26+
}
27+
28+
public Statement apply(final Statement base, Description description) {
29+
return new Statement() {
30+
@Override
31+
public void evaluate() throws Throwable {
32+
Throwable caughtThrowable = null;
33+
34+
for (int i = 0; i < retryCount; i++) {
35+
System.out.println("Trying...." + i);
36+
try {
37+
base.evaluate();
38+
return;
39+
} catch (Throwable t) {
40+
caughtThrowable = t;
41+
}
42+
}
43+
44+
throw caughtThrowable;
45+
}
46+
};
47+
}
48+
}

0 commit comments

Comments
 (0)