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 #13

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/chrnndz3/innodb-java-reader/pull/1, 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.