Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fix - Graph vertices could appear in different orders #33709

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.elasticsearch.test.AbstractXContentTestCase;

import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
Expand Down Expand Up @@ -105,8 +107,17 @@ protected void assertEqualInstances( GraphExploreResponse expectedInstance, Gra
Connection[] expectedConns = expectedInstance.getConnections().toArray(new Connection[0]);
assertArrayEquals(expectedConns, newConns);

Vertex[] newVertices = newInstance.getVertices().toArray(new Vertex[0]);
//Sort the vertices lists before equality test (map insertion sequences can cause order differences)
Comparator<Vertex> comparator = new Comparator<Vertex>() {
@Override
public int compare(Vertex o1, Vertex o2) {
return o1.getId().toString().compareTo(o2.getId().toString());
}
};
Vertex[] newVertices = newInstance.getVertices().toArray(new Vertex[0]);
Vertex[] expectedVertices = expectedInstance.getVertices().toArray(new Vertex[0]);
Arrays.sort(newVertices, comparator);
Arrays.sort(expectedVertices, comparator);
assertArrayEquals(expectedVertices, newVertices);

ShardOperationFailedException[] newFailures = newInstance.getShardFailures();
Expand Down