Skip to content

[BUG] - Nondeterminism in unit test TestInvocationPublishModelFactory due to JSON parameter ordering #4946

@anthonyx24

Description

@anthonyx24

Steps to Reproduce

The method createDefaultPublishModel() in TestInvocationPublishModelFactory compares JSONs to verify that the default object is properly created. However, since JSONs are unordered collections, when converted to strings the parameter order may not be preserved. This test uses a hard-coded JSON string as the expected correct value, but the test could fail if the parameters from the test object are stringified in a different order than the expected string. For another example of this issue being addressed, see this previous merged PR.

This test was flagged via the NonDex tool, which detects potentially unreliable tests due to underlying Java API assumptions. To see the Nondex output for this test, you can run:

mvn -pl metrics/metrics-core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest="org.apache.servicecomb.metrics.core.publish.TestInvocationPublishModelFactory#createDefaultPublishModel"

Expected Behavior

No response

Servicecomb Version

3.3.0

Additional Context

I have a potential fix in a PR, I'll be adding that to the discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions