Fixed indice assertion to loop through expected keys (#64684)
* 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 <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
38c26ff337
commit
f891a0150a
|
@ -199,7 +199,11 @@ export default function({ getService }) {
|
||||||
'ilm', // data enricher
|
'ilm', // data enricher
|
||||||
'isRollupIndex', // 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -225,7 +229,11 @@ export default function({ getService }) {
|
||||||
'ilm', // data enricher
|
'ilm', // data enricher
|
||||||
'isRollupIndex', // 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
|
expect(body.length > 1).to.be(true); // to contrast it with the next test
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue