Skip to content

Commit f616cf3

Browse files
committed
Changed: Fix flaky tests for AB Testing
1 parent f46d200 commit f616cf3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/async/AsyncABTestingTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ public void createModifyAndDeleteABTests() throws Exception {
6464

6565
waitForCompletion(analytics.addABTest(abtest));
6666

67-
abTests = analytics.getABTests(0, 10).get();
68-
assertThat(abTests.getCount()).isEqualTo(1);
69-
assertThat(abTests.getTotal()).isEqualTo(1);
70-
assertThat(abTests.getAbtests()).hasSize(1);
67+
Boolean found = false;
68+
while (!found) {
69+
abTests = analytics.getABTests(0, 10).get();
70+
found =
71+
abTests.getCount() == 1 && abTests.getTotal() == 1 && abTests.getAbtests().size() == 1;
72+
Thread.sleep(1000);
73+
}
7174

7275
ABTest inserted = abTests.getAbtests().get(0);
7376
ABTestingHelpersTest.compareABTests(abtest, inserted);

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/sync/SyncABTestingTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public abstract class SyncABTestingTest extends SyncAlgoliaIntegrationTest {
2323

2424
@Test
25-
public void createModifyAndDeleteABTests() throws AlgoliaException {
25+
public void createModifyAndDeleteABTests() throws AlgoliaException, InterruptedException {
2626
Analytics analytics = createAnalytics();
2727
int offset = 0;
2828
int limit = 10;
@@ -77,7 +77,10 @@ public void createModifyAndDeleteABTests() throws AlgoliaException {
7777
assertThat(inserted.getStatus()).isEqualTo("stopped");
7878

7979
waitForCompletion(analytics.deleteABTest(inserted.getAbTestID()));
80-
abTests = analytics.getABTests(0, 10);
81-
assertThat(abTests.getCount()).isEqualTo(0);
80+
Boolean isEmpty = false;
81+
while (!isEmpty) {
82+
isEmpty = analytics.getABTests(0, 10).getCount() == 0;
83+
Thread.sleep(1000);
84+
}
8285
}
8386
}

0 commit comments

Comments
 (0)