Skip to content

Conversation

@annhchen89
Copy link
Contributor

What is the purpose of the change

Fixes nondeterministic tests in
org.apache.streampipes.extensions.management.connect.adapter.parser.json

.GeoJsonParserTest#getGuessSchema
.JsonArrayKeyParserTest#getGuessSchema
.JsonArrayParserTest#getGuessSchema
.JsonObjectParsersTest#getGuessSchema

The test previously performed a full assertEquals(expected, result) on the entire GuessSchema object.
However, GuessSchemaBuilder stores event samples in a HashMap:

this.samples = new HashMap<>();

Since HashMap does not guarantee key iteration order, the JSON generated in eventPreview may serialize fields in different orders, such as:

{"longitude": 6.94, "latitude": 51.43, "temperature": 5.0} or {"latitude": 51.43, "temperature": 5.0, "longitude": 6.94}

These variations are semantically identical but cause strict equality checks to fail, causing nondeterministic failures during repeated runs or under NonDex.

Reproduce Test

The non-deterministic behavior can be reliably reproduced with NonDex using:

mvn edu.illinois:nondex-maven-plugin:2.2.1:nondex \
  -Dtest=org.apache.streampipes.extensions.management.connect.adapter.parser.json.GeoJsonParserTest#getGuessSchema

The same issue also appears in:

.JsonArrayKeyParserTest#getGuessSchema
.JsonArrayParserTest#getGuessSchema
.JsonObjectParsersTest#getGuessSchema

This will intermittently produce failures depending on the map iteration order.

The Fix

Instead of asserting equality on the entire GuessSchema object, it now parses the JSON preview entries into Map<String, Object> then check equivalency using

assertEquals(expectedMap, actualMap);

This performs structural JSON comparison, ensuring correctness while ignoring nondeterministic key ordering.


PR introduces (a) breaking change(s): no

PR introduces (a) deprecation(s): no

@github-actions github-actions bot added java Pull requests that update Java code backend Everything that is related to the StreamPipes backend testing Relates to any kind of test (unit test, integration, or E2E test). labels Dec 10, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2026

Hello there 👋

We noticed that it's been some time since activity occurred on your pull request 🤔. In order to keep things moving forward, we're marking this PR as stale and giving you 7 days to respond before it's automatically closed ⏰.

Please take a moment to review your pull request and make any necessary updates or changes 👨‍💻. If you need more time or have any questions, please don't hesitate to let us know 💬.

Thank you for your contributions to our project, and we look forward to hearing back from you soon 🙏.

@github-actions github-actions bot added the stale Marks pull requests that are classified as `stale` by our bot. label Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Everything that is related to the StreamPipes backend java Pull requests that update Java code stale Marks pull requests that are classified as `stale` by our bot. testing Relates to any kind of test (unit test, integration, or E2E test).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant