From e29d3d51e24faf8aa16a600cd932613a15a8e6db Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Mon, 10 Jun 2024 15:00:34 +0200 Subject: [PATCH] Fix test --- .../cluster/metadata/DataStreamTests.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java index 0277855db9c4..9362fd87e07c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java @@ -353,24 +353,20 @@ public void testRemoveFailureStoreIndexThatDoesNotExist() { public void testRemoveFailureStoreWriteIndex() { DataStream original = createRandomDataStream(); + int indexToRemove = original.getFailureIndices().getIndices().size() - 1; - IllegalArgumentException e = expectThrows( - IllegalArgumentException.class, - () -> original.removeFailureStoreIndex( - original.getFailureIndices().getIndices().get(original.getFailureIndices().getIndices().size() - 1) - ) - ); - assertThat( - e.getMessage(), - equalTo( - String.format( - Locale.ROOT, - "cannot remove backing index [%s] of data stream [%s] because it is the write index of the failure store", - original.getFailureIndices().getIndices().get(original.getFailureIndices().getIndices().size() - 1).getName(), - original.getName() - ) - ) - ); + DataStream updated = original.removeFailureStoreIndex(original.getFailureIndices().getIndices().get(indexToRemove)); + assertThat(updated.getName(), equalTo(original.getName())); + assertThat(updated.getGeneration(), equalTo(original.getGeneration() + 1)); + assertThat(updated.getIndices().size(), equalTo(original.getIndices().size())); + assertThat(updated.getFailureIndices().getIndices().size(), equalTo(original.getFailureIndices().getIndices().size() - 1)); + assertThat(updated.getFailureIndices().isRolloverOnWrite(), equalTo(true)); + for (int k = 0; k < (original.getFailureIndices().getIndices().size() - 1); k++) { + assertThat( + updated.getFailureIndices().getIndices().get(k), + equalTo(original.getFailureIndices().getIndices().get(k)) + ); + }; } public void testAddBackingIndex() {