Skip to content

Commit

Permalink
Fixed indice assertion to loop through expected keys (#64684) (#65813)
Browse files Browse the repository at this point in the history
* Changed assertion to loop through expected keys and confirm that they are contained within the array. Also made sure that the two arrays have the same length. Those two assertions should make sure that the contents are the same no matter the order of the keys.

* Changed assertion to loop through expected keys and confirm that they are contained within the array. Also made sure that the two arrays have the same length. Those two assertions should make sure that the contents are the same no matter the order of the keys.

* Fixed typo in function.

* Changed assertion per conversation.

* Updated assertion on second test.

* Fixed assertion for equality that's not strict.

* Added comment to code to explain why the arrays were sorted.

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
John Dorlus and elasticmachine authored May 13, 2020
1 parent 76e47a1 commit 110a9c1
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ export default function({ getService }) {
'ilm', // data enricher
'isRollupIndex', // data enricher
];
expect(Object.keys(body[0])).to.eql(expectedKeys);
// We need to sort the keys before comparing then, because race conditions
// can cause enrichers to register in non-deterministic order.
const sortedExpectedKeys = expectedKeys.sort();
const sortedReceivedKeys = Object.keys(body[0]).sort();
expect(sortedReceivedKeys).to.eql(sortedExpectedKeys);
});
});

Expand All @@ -224,7 +228,11 @@ export default function({ getService }) {
'ilm', // data enricher
'isRollupIndex', // data enricher
];
expect(Object.keys(body[0])).to.eql(expectedKeys);
// We need to sort the keys before comparing then, because race conditions
// can cause enrichers to register in non-deterministic order.
const sortedExpectedKeys = expectedKeys.sort();
const sortedReceivedKeys = Object.keys(body[0]).sort();
expect(sortedReceivedKeys).to.eql(sortedExpectedKeys);
expect(body.length > 1).to.be(true); // to contrast it with the next test
});
});
Expand Down

0 comments on commit 110a9c1

Please sign in to comment.