jung icon indicating copy to clipboard operation
jung copied to clipboard

fix flaky test(testDAG) under TestMinimumSpanningTree

Open SpiceOwlf opened this issue 3 years ago • 5 comments

Hi, edu.uci.ics.jung.algorithms.shortestpath.TestMinimumSpanningTree.testDAG is expressing a non-deterministic behavior under NonDex(https://github.com/TestingResearchIllinois/NonDex), because MinimumSpanningTree is using hashset & hashmap for implementation. Thus the fix would be replacing hash-components with tree-components, which ensure the deterministic order. Please let me know if there are any problems or you want to discuss more about this fix.

SpiceOwlf avatar Nov 10 '21 17:11 SpiceOwlf

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 10 '21 17:11 CLAassistant

Good catch--thanks!

However, you need to use LinkedHashSet and LinkedHashMap to guarantee that it would work in general, because the Tree classes assume that the nodes have a natural ordering. Because the nodes used in the tests happen to have that property, it works fine there, but it would break code elsewhere.

If convenient, please update your patch; otherwise I'll take care of it.

jrtom avatar Nov 11 '21 02:11 jrtom

Hi, I changed TreeSet & TreeMap to LinkedHashSet & LinkedHashMap. However, this change will fail the maven test (TestMinimumSpanningTree.testDAG). Not sure what caused the problem.

SpiceOwlf avatar Nov 11 '21 03:11 SpiceOwlf

Hmm. I don't have time to look into this tonight in detail, but let me know if you spot the problem. What's the error you're seeing?

jrtom avatar Nov 11 '21 03:11 jrtom

Hi jrtom: Here is the log I got:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running edu.uci.ics.jung.algorithms.shortestpath.TestMinimumSpanningTree
graph.nodes()[B0, A, B1]
mst.nodes()[B0, B1, A]
graph.edges()[0, 1]
mst.edges()[]
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.13 sec <<< FAILURE!
.......
.......
.......
Results :

Failed tests:   testDAG(edu.uci.ics.jung.algorithms.shortestpath.TestMinimumSpanningTree): **expected:<[0, 1]> but was:<[]>**

SpiceOwlf avatar Nov 11 '21 03:11 SpiceOwlf

Thanks for your suggested fix. It turns out that there was an additional fix needed, which I supplied in #263, so this patch is no longer needed, but I appreciate you lending a hand. :)

jrtom avatar Jan 08 '23 22:01 jrtom