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 2 #16

Closed chrnndz3 closed 3 years ago

chrnndz3 commented 3 years ago

27 other 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.getFieldOrdinal(...), I've added annotations, PR: https://github.com/alibaba/innodb-java-reader/pull/14, to Employee class and Department class to retrieve the field ordinal using the field annotations instead of iterating through getDeclaredField() which is nondeterministic.

As per https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

codecov-io commented 3 years ago

Codecov Report

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

Impacted file tree graph

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

neoremind commented 3 years ago

@chrnndz3 Thanks for submitting the valuable PR, is it possible to accept just one of them? and would you close the redundant PRs?

chrnndz3 commented 3 years ago

Hi @neoremind, this fix will only work if the parent PR is accepted, https://github.com/alibaba/innodb-java-reader/pull/14. There are 45 flaky tests in total in SimpleSkTableReaderTest. https://github.com/alibaba/innodb-java-reader/pull/15 fixes 18 and this PR fixes the other 27 flaky tests. We decided to make a parent/common PR(#14) then followed by the child PRs (#15 and #16) so it can be much clear to understand instead of all in one PR. Hope this helps. Let me know if you have any other questions.

neoremind commented 3 years ago

LGTM, Thanks for contributing! 👍 @chrnndz3