alibaba / innodb-java-reader

A library and command-line tool to access MySQL InnoDB data file directly in Java
Apache License 2.0
462 stars 115 forks source link

Fix Nondeterministic Ordering in Tests Part 1 #15

Closed chrnndz3 closed 3 years ago

chrnndz3 commented 3 years ago

18 tests from com.alibaba.innodb.java.reader.sk.SimpleSkTableReaderTest are flaky.

If java.lang.Object.getDeclaredFields() returns the fields in a different order multiple tests could fail. This PR ensures that the tests pass even if the order changes.

To guarantee the ordering of com.alibaba.innodb.java.reader.getAllRows(...), I've added annotations, PR: https://github.com/alibaba/innodb-java-reader/pull/14, to Employee class and Department class to sort the fields by their annotated values.

As per https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields-- "The elements in the returned array are not sorted and are not in any particular order."

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

codecov-io commented 3 years ago

Codecov Report

Merging #15 (526892c) into master (24a95d8) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #15   +/-   ##
=========================================
  Coverage     82.32%   82.32%           
  Complexity     1113     1113           
=========================================
  Files            91       91           
  Lines          4148     4148           
  Branches        554      554           
=========================================
  Hits           3415     3415           
  Misses          508      508           
  Partials        225      225           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 24a95d8...526892c. Read the comment docs.