[
https://issues.apache.org/jira/browse/AVRO-4230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18059828#comment-18059828
]
Todd McDowell commented on AVRO-4230:
-------------------------------------
After discussions with [~mgrigorov] and [~jjatria], we decide this solution was
an anti-pattern. While the desire for deterministic output is sound, the
trade-off of reduced speed was not desired.
The solution for improved testing was to decode both the observed and expect
binary, and then compare the resulting Perl structures with is_deeply().
See [https://github.com/apache/avro/pull/3650] for the full discussion.
Cancelling this patch now.
> Avro::BinaryEncoder's encode_map generates non-deterministic output which
> makes writing unit tests more difficult
> -----------------------------------------------------------------------------------------------------------------
>
> Key: AVRO-4230
> URL: https://issues.apache.org/jira/browse/AVRO-4230
> Project: Apache Avro
> Issue Type: Improvement
> Components: perl
> Affects Versions: 1.12.1
> Reporter: Todd McDowell
> Priority: Minor
> Labels: pull-request-available
> Original Estimate: 2h
> Time Spent: 2.5h
> Remaining Estimate: 0h
>
> I was attempting to write unit tests for Perl code that was making use of
> Avro::BinaryEncoder. The code was specifically calling encode_map, which
> encodes a Perl hash into binary. However, since Perl's keys function does
> not guarantee a consistent order of the hash's keys, the expected value from
> encode_map occasionally fails to match the observed value, which causes the
> test to fail.
> I recommend sorting the keys of the data in encode_map before the encoding
> process to ensure a deterministic output from encode_map. I've already
> modified the code, but I needed to submit this issue before I could submit
> the pull request change based on the instructions I read. The deterministic
> output from encode_map will make testing simpler. I'll submit that change
> for review shortly.
> Thanks for your attention.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)