From 6d02e12cea39a175ddda75b97432d6040dd59a46 Mon Sep 17 00:00:00 2001 From: Rich Ellis Date: Wed, 11 Jun 2025 10:17:56 +0100 Subject: [PATCH] test: fix intermittent failures Update assertions and assert message in ChangesFollowerTest testStart and testStop to validate 2 batches received. --- .../cloudant/features/ChangesFollowerTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/features/ChangesFollowerTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/features/ChangesFollowerTest.java index d9efe5c53..3a58f71a8 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/features/ChangesFollowerTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/features/ChangesFollowerTest.java @@ -1,5 +1,5 @@ /** - * © Copyright IBM Corporation 2022, 2023. All Rights Reserved. + * © Copyright IBM Corporation 2022, 2025. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -366,8 +366,10 @@ void testStart() { try { // Run for 5 seconds against an infinite stream long count = testFollowerOnThread(testFollower, ChangesFollower.Mode.LISTEN, false, Duration.ofSeconds(5L)); - // Even on a slow test machine we should at least get into the third batch, but hard to predict total changes - Assert.assertTrue(count > 2*ChangesFollower.BATCH_SIZE + 1, "There should be some changes."); + // Even on a slow test machine we should at least get two batches, but hard to predict total changes + long expectedMinChanges = 2 * ChangesFollower.BATCH_SIZE; + Assert.assertTrue(count >= expectedMinChanges, + String.format("Expected at least %d changes, but found only %d.", expectedMinChanges, count)); } catch(Exception e) { Assert.fail("There should be no exception.", e); } @@ -470,8 +472,10 @@ void testStop() { try { // Run for 5 seconds against an infinite stream long count = testFollowerOnThread(testFollower, ChangesFollower.Mode.FINITE, false, Duration.ofSeconds(5L)); - // Even on a slow test machine we should at least get into the third batch, but hard to predict total changes - Assert.assertTrue(count > 2*ChangesFollower.BATCH_SIZE + 1, "There should be some changes."); + // Even on a slow test machine we should at least get two batches, but hard to predict total changes + long expectedMinChanges = 2 * ChangesFollower.BATCH_SIZE; + Assert.assertTrue(count >= expectedMinChanges, + String.format("Expected at least %d changes, but found only %d.", expectedMinChanges, count)); } catch(Exception e) { Assert.fail("There should be no exception.", e); }