Skip to content

Commit

Permalink
change assert to avoid flaky in test
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <zaniu@amazon.com>
  • Loading branch information
zane-neo committed Nov 29, 2024
1 parent 70eb2b1 commit 0714b07
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -58,9 +59,8 @@ public void testCatIndexWithFewIndices() throws IOException {
String responseStr = TestHelper.httpEntityToString(response.getEntity());
String toolOutput = extractResult(responseStr);
String[] actualLines = toolOutput.split("\\n");
// plus 2 as there are one line of header and one line of system agent index, but sometimes the ml-config index will be created
// then there will be one more line.
assert actualLines.length == indices.size() + 2 || actualLines.length == indices.size() + 3;
long testIndexCount = Arrays.stream(actualLines).filter(x -> x.contains("test")).count();
assert testIndexCount == indices.size();
for (String index : indices) {
assert Objects.requireNonNull(toolOutput).contains(index);
}
Expand All @@ -72,7 +72,8 @@ public void testCatIndexWithMoreThan100Indices() throws IOException {
String responseStr = TestHelper.httpEntityToString(response.getEntity());
String toolOutput = extractResult(responseStr);
String[] actualLines = toolOutput.split("\\n");
assert actualLines.length == indices.size() + 2 || actualLines.length == indices.size() + 3;
long testIndexCount = Arrays.stream(actualLines).filter(x -> x.contains("test")).count();
assert testIndexCount == indices.size();
for (String index : indices) {
assert Objects.requireNonNull(toolOutput).contains(index);
}
Expand Down

0 comments on commit 0714b07

Please sign in to comment.