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 flaky test #12

Closed jlee759 closed 3 years ago

jlee759 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 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
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

codecov-io commented 3 years ago

Codecov Report

Merging #12 (b3379b7) into master (24a95d8) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #12   +/-   ##
=========================================
  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...b3379b7. Read the comment docs.

neoremind commented 3 years ago

@jlee759 thanks for submitting pull request, do you encounter failure due to field orderness?

jlee759 commented 3 years ago

@neoremind We use this tool called Nondex. We use it to detect and debugging wrong assumptions on under-determined Java APIs. Here’s the research paper that explains it in details and how it works: https://www.cs.cornell.edu/~legunsen/pubs/GyoriETAL16NonDexToolDemo.pdf