Skip to content

Commit 2b97cc8

Browse files
committed
Fix test failure introduced in #75917
In #75917 we introduced an assertion that relied on the order of the shards in the JSON representation of a `SnapshotsInProgress` but in fact we might end up with the shards in either order. This commit weakens the assertion to fix the test.
1 parent 15933c0 commit 2b97cc8

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

server/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.util.stream.Stream;
4343

4444
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
45+
import static org.hamcrest.Matchers.anyOf;
4546
import static org.hamcrest.Matchers.equalTo;
4647

4748
public class SnapshotsInProgressSerializationTests extends AbstractDiffableWireSerializationTestCase<Custom> {
@@ -398,17 +399,31 @@ public void testXContent() throws IOException {
398399
String json = Strings.toString(builder);
399400
assertThat(
400401
json,
401-
equalTo(
402-
"{\"snapshots\":[{\"repository\":\"repo\",\"snapshot\":\"name\",\"uuid\":\"uuid\","
403-
+ "\"include_global_state\":true,\"partial\":true,\"state\":\"SUCCESS\","
404-
+ "\"indices\":[{\"name\":\"index\",\"id\":\"uuid\"}],\"start_time\":\"1970-01-01T00:20:34.567Z\","
405-
+ "\"start_time_millis\":1234567,\"repository_state_id\":0,\"shards\":["
406-
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":0,\"state\":\"SUCCESS\","
407-
+ "\"generation\":\"shardgen\",\"node\":\"nodeId\","
408-
+ "\"result\":{\"generation\":\"shardgen\",\"size\":\"1b\",\"size_in_bytes\":1,\"segments\":1}},"
409-
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":1,\"state\":\"FAILED\","
410-
+ "\"generation\":\"fail-gen\",\"node\":\"nodeId\",\"reason\":\"failure-reason\"}"
411-
+ "],\"feature_states\":[],\"data_streams\":[]}]}"
402+
anyOf(
403+
equalTo(
404+
"{\"snapshots\":[{\"repository\":\"repo\",\"snapshot\":\"name\",\"uuid\":\"uuid\","
405+
+ "\"include_global_state\":true,\"partial\":true,\"state\":\"SUCCESS\","
406+
+ "\"indices\":[{\"name\":\"index\",\"id\":\"uuid\"}],\"start_time\":\"1970-01-01T00:20:34.567Z\","
407+
+ "\"start_time_millis\":1234567,\"repository_state_id\":0,\"shards\":["
408+
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":0,\"state\":\"SUCCESS\","
409+
+ "\"generation\":\"shardgen\",\"node\":\"nodeId\","
410+
+ "\"result\":{\"generation\":\"shardgen\",\"size\":\"1b\",\"size_in_bytes\":1,\"segments\":1}},"
411+
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":1,\"state\":\"FAILED\","
412+
+ "\"generation\":\"fail-gen\",\"node\":\"nodeId\",\"reason\":\"failure-reason\"}"
413+
+ "],\"feature_states\":[],\"data_streams\":[]}]}"
414+
), // or the shards might be in the other order:
415+
equalTo(
416+
"{\"snapshots\":[{\"repository\":\"repo\",\"snapshot\":\"name\",\"uuid\":\"uuid\","
417+
+ "\"include_global_state\":true,\"partial\":true,\"state\":\"SUCCESS\","
418+
+ "\"indices\":[{\"name\":\"index\",\"id\":\"uuid\"}],\"start_time\":\"1970-01-01T00:20:34.567Z\","
419+
+ "\"start_time_millis\":1234567,\"repository_state_id\":0,\"shards\":["
420+
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":1,\"state\":\"FAILED\","
421+
+ "\"generation\":\"fail-gen\",\"node\":\"nodeId\",\"reason\":\"failure-reason\"},"
422+
+ "{\"index\":{\"index_name\":\"index\",\"index_uuid\":\"uuid\"},\"shard\":0,\"state\":\"SUCCESS\","
423+
+ "\"generation\":\"shardgen\",\"node\":\"nodeId\","
424+
+ "\"result\":{\"generation\":\"shardgen\",\"size\":\"1b\",\"size_in_bytes\":1,\"segments\":1}}"
425+
+ "],\"feature_states\":[],\"data_streams\":[]}]}"
426+
)
412427
)
413428
);
414429
}

0 commit comments

Comments
 (0)