[CONTROLLER-587] Heisenbug in DataNormalizerTest Created: 29/Jun/14  Updated: 25/Jul/23  Resolved: 03/Jul/14

Status: Resolved
Project: controller
Component/s: mdsal
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Colin Dixon Assignee: Colin Dixon
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: Macintosh


External issue ID: 1256

 Description   

On MacOS 10.9.3 (verified on 3 machines) with Java 1.7, the DataNormalizerTest fails because the comparator provided in verifyLegacyNode() does not actually provide a total ordering of the childData and childNodes.

It appears as though Windows and Linux are immune.

This results in a build failure for sal-common-impl that looks like this:

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Tests run: 10, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.892 sec <<< FAILURE! - in org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest
testToLegacyNormalizedNode(org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest) Time elapsed: 0.068 sec <<< FAILURE!
java.lang.AssertionError: Child node QName expected:<(urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test?revision=2014-03-13)inner-list> but was:<(urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test?revision=2014-03-13)id>
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.failNotEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:126)
at org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest.verifyLegacyNode(DataNormalizerTest.java:437)
at org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest.verifyLegacyNode(DataNormalizerTest.java:441)
at org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizerTest.testToLegacyNormalizedNode(DataNormalizerTest.java:245)



 Comments   
Comment by Tony Tkacik [ 30/Jun/14 ]

This boils down that test expects ordering from HashMap (hashMap ordering
is pseudo-random and depends on previously allocated HashMap and their seeds).

Comment by Tony Tkacik [ 30/Jun/14 ]

Implementation of verify for composite nodes, assumes ordering even for elements
which are marked unordered (and uses hashmap in background)

Easy way to replicate this bug is just to modify QName#hashCode() to return 0 for hashCode.

Comment by Colin Dixon [ 30/Jun/14 ]

I created a partial (complete for the current unit tests) patch for this last night:
https://git.opendaylight.org/gerrit/#/c/8439/

Comment by Colin Dixon [ 03/Jul/14 ]

Since the code was in a Unit test and the submitted fix will generate exceptions if the assumptions it makes are violated, I've marked this as fixed since I don't think it could regress without failing in the verify stage.

Generated at Wed Feb 07 19:53:24 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.