Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two non deterministic test in MaterializedViewQueryQueryToolChestTest #17461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yugvajani
Copy link

@yugvajani yugvajani commented Nov 7, 2024

Fixed 2 non deterministic tests in MaterializedViewQueryQueryToolChestTest

  • testDecorateObjectMapperMaterializedViewQuery

  • testDecorateObjectMapper

Steps to reproduce

To reproduce the problem, first build the module materialized-view-selection:

mvn install -pl extensions-contrib/materialized-view-selection -am -DskipTests

Then, run the regular test:

For testDecorateObjectMapperMaterializedViewQuery

mvn -pl materialized-view-selection test -Dtest=org.apache.druid.query.materializedview.MaterializedViewQueryQueryToolChestTest#testDecorateObjectMapperMaterializedViewQuery

For testDecorateObjectMapper

mvn -pl materialized-view-selection test -Dtest=org.apache.druid.query.materializedview.MaterializedViewQueryQueryToolChestTest#testDecorateObjectMapper

To identify the flaky test, execute the following nondex command:

For testDecorateObjectMapperMaterializedViewQuery

mvn -pl materialized-view-selection edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.druid.query.materializedview.MaterializedViewQueryQueryToolChestTest#testDecorateObjectMapperMaterializedViewQuery

For testDecorateObjectMapper

mvn -pl materialized-view-selection edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.druid.query.materializedview.MaterializedViewQueryQueryToolChestTest#testDecorateObjectMapper

Description

The failure in the testDecorateObjectMapperMaterializedViewQuery test within MaterializedViewQueryQueryToolChestTest appears to be due to a mismatch in the JSON structure, specifically the order of fields within the event object. In this test, there is a comparison between an expected JSON structure and an actual result generated during the test. Here’s what’s happening:

Expected Output: {"alias":"automotive","rows":1,"idx":135}
Actual Output: {"alias":"automotive","idx":135,"rows":1}

The flaky behavior in the testDecorateObjectMapper test in MaterializedViewQueryQueryToolChestTest also appears to stem from the inconsistency in the ordering of fields within a JSON object. Here’s a closer look at the issue:

Expected JSON Structure: {"rows":1,"idx":118,"alias":"business"}
Actual JSON Structure: {"alias":"business","idx":118,"rows":1}

The fields in the event object (rows, idx, and alias) are in different orders in the expected vs. actual outputs. As in the previous test, this order discrepancy is likely causing a failure in the direct string comparison of JSON data.

Fix

The fix involves configuring the object mapper for deterministic output by sorting it.



This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant