Skip to content

Commit

Permalink
Fixed indice assertion to loop through expected keys (elastic#64684)
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]>
  • Loading branch information
John Dorlus and elasticmachine committed May 8, 2020
1 parent 88d9f17 commit be996ac
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,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 @@ -225,7 +229,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 be996ac

Please sign in to comment.