RandomizedTimeSeriesIT use synthetic id randomly#142956
Conversation
Randomly use synthetic_id in RandomizedTimeSeriesIT. Fix assertion in VersionsAndSeqNoResolver. The uid is generated with Uid.encodeId(id), which can prepend BASE64_ESCAPE (e0xfd), see Uid.encodeBase64Id. When comparing to id encoded using Base64.getUrlDecoder().decode(id) directly, this would fail the assertion. Update assertion to use the same method of encoding as when the uid was first encoded.
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| assert uid.equals(new BytesRef(Base64.getUrlDecoder().decode(id))); | ||
| assert uid.equals(Uid.encodeId((id))); |
There was a problem hiding this comment.
Please shout if there was a specific reason why we validated against new BytesRef(Base64.getUrlDecoder().decode(id)) specifically here.
There was a problem hiding this comment.
I think I just reused the decoder that was in place (byte[] idAsBytes = Base64.getUrlDecoder().decode(id); from the following lines) when I added the if (useSyntheticId) condition, but that was a mistake.
In this method we're looking up a Lucene term which is encoded using Uid.encodeId() so I think your change indeed fixes the assertion. I'm surprized in never failed so far.
Nice catch!
| assert uid.equals(new BytesRef(Base64.getUrlDecoder().decode(id))); | ||
| assert uid.equals(Uid.encodeId((id))); |
There was a problem hiding this comment.
I think I just reused the decoder that was in place (byte[] idAsBytes = Base64.getUrlDecoder().decode(id); from the following lines) when I added the if (useSyntheticId) condition, but that was a mistake.
In this method we're looking up a Lucene term which is encoded using Uid.encodeId() so I think your change indeed fixes the assertion. I'm surprized in never failed so far.
Nice catch!
Randomly use synthetic_id in RandomizedTimeSeriesIT. Fix assertion in VersionsAndSeqNoResolver. The uid is generated with Uid.encodeId(id), which can prepend BASE64_ESCAPE (e0xfd), see Uid.encodeBase64Id. When comparing to id encoded using Base64.getUrlDecoder().decode(id) directly, this would fail the assertion. Update assertion to use the same method of encoding as when the uid was first encoded.
Randomly use synthetic_id in RandomizedTimeSeriesIT.
Fix assertion in VersionsAndSeqNoResolver.
The uid is generated with Uid.encodeId(id), which can prepend BASE64_ESCAPE (e0xfd), see Uid.encodeBase64Id. When comparing to id encoded using Base64.getUrlDecoder().decode(id) directly, this would fail the assertion. Update assertion to use the same method of encoding as when the uid was first encoded.