Skip to content

Commit

Permalink
[Bugfix] Fix ICacheKeySerializerTests flakiness (opensearch-project#1…
Browse files Browse the repository at this point in the history
…4564)

* Fix testInvalidInput flakiness

Signed-off-by: Peter Alfonsi <petealft@amazon.com>

* Addressed andrross's comment

Signed-off-by: Peter Alfonsi <petealft@amazon.com>

* rerun security check

Signed-off-by: Peter Alfonsi <petealft@amazon.com>

---------

Signed-off-by: Peter Alfonsi <petealft@amazon.com>
Co-authored-by: Peter Alfonsi <petealft@amazon.com>
  • Loading branch information
peteralfonsi and Peter Alfonsi authored Jul 1, 2024
1 parent 8904557 commit f9512db
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ public void testInvalidInput() throws Exception {
ICacheKeySerializer<BytesReference> serializer = new ICacheKeySerializer<>(keySer);

Random rand = Randomness.get();
byte[] randomInput = new byte[1000];
rand.nextBytes(randomInput);

assertThrows(OpenSearchException.class, () -> serializer.deserialize(randomInput));
// The first thing the serializer reads is a VInt for the number of dimensions.
// This is an invalid input for StreamInput.readVInt(), so we are guaranteed to have an exception
assertThrows(OpenSearchException.class, () -> serializer.deserialize(new byte[] { -1, -1, -1, -1, -1 }));
}

public void testDimNumbers() throws Exception {
Expand Down

0 comments on commit f9512db

Please sign in to comment.