Retry flaky tests for ReplicateToDatastoreAction (#1226)

* Retry flaky tests for ReplicateToDatastoreAction

The occassional failures seem to be caused by the test Datastore.
This commit is contained in:
Weimin Yu 2021-06-29 17:12:02 -04:00 committed by GitHub
parent 6d26f3cc0e
commit bfe720ba1b

View file

@ -46,6 +46,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junitpioneer.jupiter.RetryingTest;
public class ReplicateToDatastoreActionTest { public class ReplicateToDatastoreActionTest {
@ -97,7 +98,7 @@ public class ReplicateToDatastoreActionTest {
RegistryConfig.overrideCloudSqlReplicateTransactions(false); RegistryConfig.overrideCloudSqlReplicateTransactions(false);
} }
@Test @RetryingTest(4)
public void testReplication() { public void testReplication() {
TestEntity foo = new TestEntity("foo"); TestEntity foo = new TestEntity("foo");
TestEntity bar = new TestEntity("bar"); TestEntity bar = new TestEntity("bar");
@ -127,7 +128,7 @@ public class ReplicateToDatastoreActionTest {
assertThat(ofyTm().transact(() -> ofyTm().loadByKey(baz.key()))).isEqualTo(baz); assertThat(ofyTm().transact(() -> ofyTm().loadByKey(baz.key()))).isEqualTo(baz);
} }
@Test @RetryingTest(4)
public void testReplayFromLastTxn() { public void testReplayFromLastTxn() {
TestEntity foo = new TestEntity("foo"); TestEntity foo = new TestEntity("foo");
TestEntity bar = new TestEntity("bar"); TestEntity bar = new TestEntity("bar");
@ -149,7 +150,7 @@ public class ReplicateToDatastoreActionTest {
assertThat(ofyTm().transact(() -> ofyTm().loadByKeyIfPresent(foo.key()).isPresent())).isFalse(); assertThat(ofyTm().transact(() -> ofyTm().loadByKeyIfPresent(foo.key()).isPresent())).isFalse();
} }
@Test @RetryingTest(4)
public void testUnintentionalConcurrency() { public void testUnintentionalConcurrency() {
TestEntity foo = new TestEntity("foo"); TestEntity foo = new TestEntity("foo");
TestEntity bar = new TestEntity("bar"); TestEntity bar = new TestEntity("bar");
@ -184,7 +185,7 @@ public class ReplicateToDatastoreActionTest {
Level.WARNING, "Ignoring transaction 1, which appears to have already been applied."); Level.WARNING, "Ignoring transaction 1, which appears to have already been applied.");
} }
@Test @RetryingTest(4)
public void testMissingTransactions() { public void testMissingTransactions() {
// Write a transaction (should have a transaction id of 1). // Write a transaction (should have a transaction id of 1).
TestEntity foo = new TestEntity("foo"); TestEntity foo = new TestEntity("foo");